0
我是Logstash的新手。目前我有一個logstash.conf文件,將錯誤日誌發送到zabbix項目。 我已經應用了一個自定義Grok過濾器來查找ERROR | Error | error關鍵字,並基於它將輸出重定向到zabbix項目。 但是,我希望logstash每當過濾器結果計算爲true時發送增量計數器,而不是簡單地發送相應的Log。 我該如何做到這一點?如何使用Logstash輸出將錯誤日誌的計數發送到zabbix?
這是我正在使用的日誌文件的片段。
input {
file {
path => "/root/sample.log"
type => "string"
}
}
# The filter part of this file is commented out to indicate that it is
# optional.
filter {
mutate {
add_field => { "[@metadata][error]" => "error" }
add_field => { "[@metadata][counter]" => "1" }
add_field => { "myhost" => "logstash" }
}
if "grokked" not in [tags] {
grok {
patterns_dir => ["/root/logstash-5.5.0/pattern"]
match => { "message" => "%{ERROR:log_level}" }
add_tag => ["ERROR", "grokked"]
}
}
}
output {
stdout { codec => rubydebug }
if "ERROR" in [tags]{
zabbix
{
zabbix_server_host => "192.168.56.102"
zabbix_host => "myhost"
zabbix_key => "[@metadata][error]"
#zabbix_value => "[@metadata][counter]"
}