Split command in ruby by new line


I am trying to split the message where ever a new line exist by ruby filter.

The command in the ruby code I use:

message_array = event.get('message').split("\n")

But the logstash doesn't start because of it.

It looks like logstash doesn't support the "\n"

message_array = event.get('message').split(\""}

Any workaround?


Don't mix single and double quotes inside the Ruby code. You can't use the same kind of quote that you're using the delimit the Ruby code block.

Sure, great.

So what should I do?

What do I need to do in order to split the event in new lines?

Thanks in advanced,

As I said, use quotes consistently.

code => 'message_array = event.get("message").split("\n")'

Of course, to just split a string on newline characters you don't need a ruby filter, just use a mutate filter.


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