Hello,
I am trying to integrate a Ruby script into Logstash, but I am having a hard time... Basically, I have a field which I want to modify in Ruby and then give back to Logstash. What I'm having a hard time with is the communication between Logstash and Ruby.
For the record, here are the parts I use:
Logstash:
csv {
columns => [ "FUTURE_USE", "temp Receive time", "Serial number", "Type", "Subtype", "FUTURE_USE2", "temp Generated time", "Source IP", "Destination IP", "NAT source IP", "NAT destination IP", "Rule name", "Source user","Destination user", "Application", "Virtual system",
"Source zone", "Destination zone", "Source interface", "Destination interface", "Log forwarding profile", "temp Log creation time", "Session ID", "Repeat count", "Source port", "Destination port", "NAT source port", "NAT destination port", "Flag", "Protocol", "Action",
"Miscellaneous", "Thread ID", "Category", "Severity", "Direction", "Sequence number", "Action flags", "Source location", "Destination location", "FUTURE_USE3", "Content type", "PCAP ID", "Filedigest", "Cloud", "URL index", "User agent", "File type", "X-forwarded-for", "Referer", "Sender",
"Subject", "Recipient", "Report ID",
"Device Group Hierarchy Level 1", "Device Group Hierarchy Level 2", "Device Group Hierarchy Level 3", "Device Group Hierarchy Level 4", "Virtual system name", "Device name", "Action source", "FUTURE_USE4"]
}
ruby {
path => "/etc/logstash/conf.d/test.rb"
script_params => { "flag" => flag }
}
Ruby:
def register(params)
@flag = params["flag"]
end
def filter(event)
flags = {"PCAP" => 0x80000000, "IPV6" => 0x02000000 , "SSL Proxy" => 0x01000000 , "URL Filtering" => 0x00800000, "NAT" => 0x00400000 , "Captive Portal" => 0x00200000 , "X-Forwarded-For" => 0x00080000 , "Proxy Transaction" => 0x00040000 , "Container Page" => 0x00008000, "session has a temporary match on a rule for implicit application dependency handling" => 0x00002000, "symmetric return was used to forward traffic for this session" => 0x00000800 }
flags_to_return = Array.new()
flags.each do |key, value|
result = @flag & value
if value == result
flags_to_return.push(key)
end
end
return flags_to_return
end