How to use logstash keystore values in ruby script

When using an external ruby script parameters can be used with
path => "script.rb"
script_params => {
"url_host_port" => "http://localhost:9200"
"url_username" => "{es_user}" "url_password" => "{es_password}"

How can I do the same with an 'inline' script?
Can I just use {es_user} and {es_password} in the script directly?

Regards Hans

Use the event API.

It is still not clear to me.
Can I just reference : event.get("es_user" ) then if es_user is defined in the keystore of logstash?
Or via @metadata
The documentation is very concise.

Regards Hans

If [es_user] is a field on the event then in script.rb you can fetch its value using event.get("es_user")

Sorry there is a misunderstanding.
I want to use logstash keystore values in the inline script.
Just as my example in my first post.

Parameters can be passed to a ruby script (external).
How can I do it with an inline ruby script?

Regards Hans

Sorry, I missed that you were referring to the keystore. If the keystore substitutions are done by event.sprintf() then you could try using that. I'm not in a position to test that tonight.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.