ELKstack-logstash 使用技巧小計

前言

logstash 使用的是最新的2.3版本,此模板僅爲參考,一切以官方文檔爲準

https://www.elastic.co/guide/en/logstash

input模塊

接收log4j類型日誌

input {

log4j {

type => "log4j-json"

port=>12201

}

}

filter模塊

深入json化message內容

filter{

json {

source => "message"

}

}

output模塊

輸出到es

output {

stdout{codec => rubydebug }

elasticsearch { hosts => ["sz-a-qhfaxes01-es-hw.qhfax.com"]

index => "dev-qhfaxweb-master-logs-%{+YYYY.MM.dd}"

document_type => "%{class}"

}

}

%{class}:class爲消息源中json的key值,使用%{}模板可以將變化的key帶入logstash模板中,使_type的值爲數據class的值。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章