I have a log which contains json, i want to apply if condition on one of the fields of json. log format:
[2018-03-22T16:47:31.113] INFO {"code":200,"type": "everything looks good", "text":"Starting server at port => 5003"} {../../app.py:14:8}
I am trying to apply condition based on the code, that is if code is 200 then it should add a field "status" => "success".
filter {
grok {
match => { "message" => "\[(?<timestamf>%{TIMESTAMP_ISO8601})\] %{LOGLEVEL:loglevel} %{GREEDYDATA:json} %{GREEDYDATA:file}" }
}
date {
match => [ "timestamf", "ISO8601" ]
target => "timestamf"
}
if [json][code] == 200 {
mutate {
add_field => {
"Status" => "Success"
}
}
}
But its not working.