ELKstack-logstash 使用技巧小計

前言

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

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

input模塊

接收log4j類型日誌

input { ruby

log4j { elasticsearch

type => "log4j-json" ide

port=>12201 ui

} spa

} debug

filter模塊

深刻json化message內容

filter{ 日誌

json { code

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的值。

相關文章
相關標籤/搜索