When sending logs to zabbix, it gives an error.
[WARN ] 2021-10-05 [[main]>worker1] zabbix - Field referenced by message is missing
[WARN ] 2021-10-05 [[main]>worker1] zabbix - Zabbix server at monitoring-server.com rejected all items sent. {:zabbix_host=>"Log"}
My config:
input {
file {
path => "/var/log/logstash/test.log"
start_position => "beginning"
add_field => [ "[@metadata][zabbix_key]" , "trap" ]
add_field => [ "[@metadata][zabbix_host]" , "Log" ]
}
}
filter {
grok {
match => { "message" => "%{IPORHOST:clientip}%{SPACE}(?:-|(%{WORD}.%{WORD}))%{SPACE}%{USER:id}%{SPACE}\[%{HTTPDATE:timestamp}\]%{SPACE}%{BASE16FLOAT:request_time}%{SPACE}%{BASE16FLOAT:request_time_upstream}%{SPACE}\"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:rawrequest})\"%{SPACE}%{NUMBER:response}%{SPACE}(?:%{NUMBER:bytes}|-)%{SPACE}%{QS:referrer}%{SPACE}%{QS:agent}%{SPACE}%{QS:forwarder}" }
remove_field => "message"
remove_field => "host"
remove_field => "@timestamp"
remove_field => "path"
remove_field => "@version"
}
geoip {
source => "clientip"
target => "geoip"
database => "/etc/logstash/GeoLite2-City.mmdb"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate { convert => [ "[geoip][coordinates]", "float"] }
}
output {
stdout { codec => rubydebug }
zabbix {
zabbix_key => "[@metadata][zabbix_key]"
zabbix_host => "[@metadata][zabbix_host]"
zabbix_server_host => "monitoring-server.com"
zabbix_server_port => "10051"
zabbix_value => "message"
}
}
However, if you comment out
grok {
match
then logs will come to Zabbix but not parsed. It is necessary that the parsed log would come, or only if there is an error status of 500.
What is wrong with me? Thanks!