I'm trying to conditionally set some fields in my pipeline:
filter {
if [log][file][path] == "/var/log/e2guardian/access.log" {
grok {
match => { "message" => "(?<e2_timestamp>\d\d\d\d\.\d\d\.\d\d \d\d:\d\d:\d\d)\t%{NOTSPACE:user.name}\t%{IP:client.address}\t%{NOTSPACE:url.full}\t%{NOTSPACE:event.action} ?(hw\d+: )?(?<why>[^\t]+)?\t%{WORD:http.request.method}\t%{NUMBER:http.request.bytes}\t\d+\t[^\t]+\t[^\t]+\t%{NUMBER:http.response.status_code}\t[^\t]+\t%{IP:client.ip}" }
}
if "_grokparsefailure" not in [tags] {
mutate {
remove_field => [ "message" ]
add_field => { "[event][category]" => [ "network", "web" ] }
add_field => { "[event][kind]" => "event" }
convert => { "[http][response][status_code]" => "integer" }
}
if [http][response][status_code] and [http][response][status_code] >= 200 and [http][response][status_code] < 400 {
mutate {
add_field => { "[event][type]" => [ "access", "connection", "allowed" ] }
add_field => { "[event][outcome]" => "success" }
}
} else {
mutate {
add_field => { "[event][type]" => [ "access", "connection", "denied" ] }
add_field => { "[event][outcome]" => "failure" }
}
}
}
date {
match => [ "e2_timestamp", "yyyy.MM.dd HH:mm:ss" ]
timezone => "%{[event][timezone]}"
remove_field => [ "e2_timestamp" ]
}
}
}
But entries with http.response.status code are still ending up with "denied" and "failure":
"http.response.status_code": "200",
"event": {
"category": [
"network",
"web"
],
"type": [
"access",
"connection",
"denied"
],
"outcome": "failure",
"timezone": "-06:00",
"kind": "event"
},