How to pass ruby variable to logstash field?

Hi, I'm using ruby filter in my logstash conf file where it will produce some output into a variable which is json data, so that i will filter that data using json filter. But the problem is i can't able to pass that variable out side the ruby filter. Similialrly how should i pass my logstash field to ruby variable.

See for how to read from and write to event fields.

Hi @magnusbaeck, Thanks for your replay. That links provides only pass logstash fields to ruby, I also need to get ruby variables to logstash variables.

What do you mean by "Logstash variables"? Perhaps you can give an example.

The below is my sample code, where i'm passing input response to the filter. Here XYZ is a field name from the input.

"init => '@var'
code => "
require 'open-uri'
response = open('"@var"').read
puts response

Here response will get some JSON data, now i should apply json filter on response.

like json {
           source => "response"

but it is not working.

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