Hi,
I'm struggling with parsing Fortigate logs. Right now I got up to the point where I got all log data within a field marked with { logdata }.
I'm using a grok filter and a KV filter after that. The problem with the KV filter is that if I don't apply a target logstash isn't doing anything. It runs, no errors etc. but no file is created. If I define I target the data gets written there and looks good but I just need to get rid of kv: { and } so everything is a separate field:value.
How can I create separate fields based on the data within { }?
Raw log
"@version":"1","host":"172.16.10.111","@timestamp":"2017-11-16T04:44:28.149Z","message":"<188>date=2017-11-16,time=04:44:26,devname=xxxxxxx,device_id=xxxxxxx,log_id=0038000007,type=traffic,subtype=other,pri=warning,vd=root,src=10.0.0.146,src_port=49156,src_int=\"wan1\",dst=255.255.255.255,dst_port=1947,dst_int=\"root\",SN=44832,status=deny,policyid=0,dst_country=\"Reserved\",src_country=\"Reserved\",service=MMS,proto=17,duration=16225,sent=0,rcvd=0,msg=\"iprope_in_check() check failed, drop\"","type":"fortilog"
Config
input {
udp {
port => 9910
type => "fortilog"
}
}
filter {
if [type] == "fortilog" {
grok {
match => ["message", "%{SYSLOG5424PRI:syslog_index}%{GREEDYDATA:message}"]
overwrite => [ "message" ]
tag_on_failure => [ "grok_failure" ]
}
kv {
source => "message"
value_split => "="
field_split => ","
target => "kv"
}
mutate {
remove_field => ["message"]
}
}
}
output {
if [type] == "fortilog" {
file {
path => "/home/test/Desktop/test/forti/test-%{+YYYY-MM-dd.HH}.gz"
gzip => true
}
}
}
Creates the following output
{"@timestamp":"2017-11-16T05:31:06.684Z","syslog_index":"<188>","syslog5424_pri":"188","@version":"1","host":"172.16.10.111","kv":{"date":"2017-11-16","src_int":"wan1","msg":"iprope_in_check() check failed, drop","dst":"10.0.0.255","type":"traffic","dst_int":"root","duration":"19023","policyid":"0","subtype":"other","devname":"xxxxxxxxxx","SN":"52890","dst_country":"Reserved","log_id":"0038000007","device_id":"xxxxxxxxxx","src":"10.0.0.208","pri":"warning","rcvd":"0","sent":"0","vd":"root","src_port":"17500","src_country":"Reserved","service":"17500/udp","proto":"17","dst_port":"17500","time":"05:31:01","status":"deny"},"type":"fortilog"}
How can I extract the data inside kv: { } into separate fields? I tried a json filter, another kv filter etc. but I just can't get it to work.