Logstash Ruby filter - init not working

I'm trying to initialize a variable in a ruby filter. It works properly with the code tag, but not when using a ruby file.
Here is my code:

  ruby {
    init => "@val = 5 "
    path => "script.rb"


def register(params)

def filter(event)
    puts @val
    return [event]

That is correct. The filter avoids evaluating the init option if the path option is set.

Once you know that it becomes clear that the documentation does imply it. The init option supplies inline code, not script code.

1 Like

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