Why does event.tag inside ruby code throw an error?

trying a simple code to add a ruby filter which adds a tag to the event

ruby {
code => "
event.tag("test")
"
}

gives the error :
Expected one of #, {, } at line 31, column 20 (byte 473)

everything works fine if I remove the event.tag() function
I found it was being used in some blogs as well.


Has it been removed in version 5?

You can't have double quoted string inside a double quoted string.

Okay:

ruby { code => "event.tag('test')" }
ruby { code => 'event.tag("test")' }

Not okay:

ruby { code => "event.tag("test")" }
ruby { code => 'event.tag('test')' }

My bad. how did i miss that..... i checked the git history of event.rb and found that in the current version the def tag doesnt exist as it did in the older version. Didnt find it in the event docs . So thought it was removed. Thanks it works fine now.

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