Ruby plugin getting 'undefined method'

Hi,
I was wondering if anyone knew why I'm getting this exception for the following ruby code. It seems to not recognize the gsub method. Do I have to initialize it in order for LS to understand it?

ruby{
      code => {"
           a = event.get('Summary')
           a = a.gsub(/[^A-Za-z]/, '')
      "}
}

This is the error I'm getting:

[2017-02-21T08:27:53,959][ERROR][logstash.filters.ruby    ] Ruby exception occurred: undefined method `gsub' for #<Array:0x6f3945b6>
[2017-02-21T08:27:53,962][ERROR][logstash.filters.ruby    ] Ruby exception occurred: undefined method `gsub' for #<Array:0x4caf6a97>

Your Summary field appears to contain an array and you can't use gsub on arrays.

1 Like

Wow, thanks. I didn't see that another input was coming in that had arrays in the summary. Been trying to figure out what has been happening for the past few hours. Thank you :slight_smile:

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