Hi,
I use Winlogbeat to transmit Windows Event Log. My Logstash Filter use for parsing the "message" in the Json.
The message content will like this, "RuleName: technique_id=T1047,technique_name=Windows Management Instrumentation." And, my purpose is splitting the message into three part, "RuleName, Technique_id and Technique_name." Here is my code. I write the filter in Ruby.
filter {
ruby {
code => '
# Initialize
rulename_input = " "
technique_id = " "
technique_name = " "
array = event.get("[message]").split("\n")
Message = array[1]
RuleName = Message.split(": ")
if RuleName[1] == " " or RuleName[1] == nil
rulename_input = " "
technique_id = " "
technique_name = " "
else
rulename_input = RuleName[1]
tech = RuleName[1].split(",")
tec = tech[0].split("=")
technique_id = tec[1]
tec = tech[1].split("=")
technique_name = tec[1]
end
event.set("RuleName",rulename_input)
event.set("Technique_id",technique_id)
event.set("Technique_name",technique_name)
'
}
}
The filter result is usually correct in most situation. Below is correct picture by Kibana.
But, if there are lots of event log send from Winlogbeat at the same time, it will be wrong. The wrong result as below:
How do I fix it?