Hi there!
I have a json input which looks like this:
[{
"Action": "COUNT",
"Timestamp": "2018-05-02T13:09:58Z",
"Request": {
"Country": "ES",
"URI": "/uploadMultiplePhotos.aspx",
"Headers": [{
> "Name": "Host",
> "Value": "www.example.net"
}, {
"Name": "Content-Length",
"Value": "226245"
}, {
"Name": "origin",
"Value": "https://www.example.net"
}, {
"Name": "user-agent",
"Value": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
}, {
"Name": "content-type",
"Value": "multipart/form-data; boundary=----WebKitFormBoundaryBnMGtRJgyfhSDZt3"
}, {
"Name": "accept",
"Value": "application/json"
}, {
"Name": "cache-control",
"Value": "no-cache"
}, {
"Name": "x-requested-with",
"Value": "XMLHttpRequest"
}, {
"Name": "x-ajax",
"Value": "example"
}, {
"Name": "referer",
"Value": "https://www.example.net/bla.aspx"
}, {
"Name": "accept-encoding",
"Value": "gzip, deflate, br"
}, {
"Name": "accept-language",
"Value": "es-ES,es;q=0.8"
}, {
"Name": "cookie",
"Value": "GREEDY"
}],
"ClientIP": "8.8.8.8",
"Method": "POST",
"HTTPVersion": "HTTP/2.0"
},
"Weight": 1
}]
and the logstash conf like this:
input {
file {
path => "/somepath/waf/*.log"
codec => "json"
discover_interval => 2
}
}
filter {
json {
source => "message"
}
date {
match => ["[Timestamp]", "ISO8601"]
target => "@timestamp"
remove_field => "timestamp"
}
split {
field => "[Request][Headers]"
}
}
output {
elasticsearch {
hosts => "https://someelk:443"
index => "waf-%{+YYYY.MM.dd}"
ssl_certificate_verification => "false"
}
}
Everything works except because Json array Name and Value are added as fields, but what i need is the "Name" key value added as fields and the "Value" key value xD as the Name field values
Ex of result wanted: a new field called Request.Header.Host and its value to be www.example.net
Any hints? Sorry that might be an easy one....
Thanks!