Returning Multiple Events from Ruby Plugin

I need to parse some incoming messages where for network reasons, one event as seen by Logstash is really a concatenation of multiple events. To do that I'm trying to use the ruby plugin, breaking the initial message into pieces, with the idea, at least, of passing those on to the remainder of the pipeline. The syntax is more complicated than the split filter plug-in can handle, but the goal is essentially the same.

The documentation for the ruby plugin (3.1.5 -- the version I am using) says I need to use to create events, however in Logstash 7.6.1, at least, this generates an error:

Could not process event: undefined local variable or method `new_event_block' for #<LogStash::Filters::Ruby::Script::ExecutionContext:0x47f06865>

As an alternative, I tried creating an array containing the events and just returning that, but what happens in practice is that the array just grows and grows, and is never passed to the rest of the pipeline.

What's the best way to do this? Is the documentation simply wrong, or is some additional undocumented setup needed before I can use new_event_block?


So just to follow up, I still don't know why the documented new_event_block method fails. That looks like a Logstash bug. However I was able to solve the problem by another route, writing a codec that gets passed in to the tcp input plugin instead of using the ruby filter plugin. That seems to work well.

1 Like

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