Hi everyone,
I'm preparing a Logstash configuration which use Grok to extract fields from incoming messages and Ruby to process those fields.
Below is a simple version of my configuration, I want to extract the Timestamp and Server values from the incoming messages, then pass those parameters to a Ruby script (named ruby_process.rb) via "script_params"
grok {
match => [ "message", "%{TIMESTAMP_ISO8601:timestamp}, %{WORD:server} %{WORD:state}" ]
}ruby {
path => "E:\logstash-6.1.2\config\scripts\ruby_process.rb"
script_params => {"server" => "event.get('server')"
"timestamp" => "event.get('timestamp')"
}
}
In ruby_process.rb, I read the Server and Timestamp params into Ruby variables
def register(params)
@server = params["server"]
@epoc = params["timestamp"]
end
But it just doesn't work, the value of @server is the literal string "event.get('server')", not the value itself. I have looked around the Google but found no example for this usecase