Hi All,
It's about barracuda FW log with the following entry
+02:00 Security XXX Block: type=FWD|proto=TCP|srcIF=eth0|srcIP=0.0.0.0|srcPort=58570|srcMAC=00:00:00:00:00:00|dstIP=0.0.0.0|dstPort=3002|dstService=exlm-agent|dstIF=|rule=L2GIS:<no-match>|info=Block no Rule Match|srcNAT=0.0.0.0|dstNAT=0.0.0.0|duration=0|count=1|receivedBytes=0|sentBytes=0|receivedPackets=0|sentPackets=0|user=|protocol=|application=|target=|content=|urlcat=
As you can see urlcat (the last field) end with nil, null or empty, not exactly sure.
My rubydebug output filter returns
The part of the regex I use for parsing is:
urlcat=(?<UrlCategory>[\w\s\d()]+|)
I tried with mutate and ruby to substitute the empty field with NA but it wont work.
I tried
ruby { code => "if event.get('URLCategory').nil?; event.set('tags', 'null-value');end" }
if "null-value" in [tags] { mutate { update => { "URLCategory" => "NA" } } }
ruby { code => "event['URLCategory'] = 'empty' if event['URLCategory'] == nil;" }
mutate { gsub => ["URLCategory", " ", "NA"] }
ruby {
code => '
event.to.hash.each { |k, v|
if v == '' # Also ""
event.set(k, "NA")
end
}
'
}
ruby {
code => "if event.get('location').nil?; event.set('tags','null-value');end"
}
if "null-value" in [tags] { do something }
ruby {
code => '
event.to.hash.each { |k, v|
if v.nil? # Also v.empty? and v == nil, ""
event.set(k, "NA")
end
}
'
}
Funny thing is that every other field that ends with | i did with ruby and it works just fine substituting | with N/A
ruby {
code => '
event.to_hash.each { |k, v|
if v == "|"
event.set(k, "N/A")
end
}
'
}
Could you please help.