Hi All,
I have written a ruby filter to check if a pattern present in a message and drop the event if pattern is not present.
I'm getting below mentioned error after updating the logstash configuration,
[2018-07-17T23:27:55,117][ERROR][logstash.filters.ruby ] Could not process event: no implicit conversion of LogStash::Event into String {:script_path=>"/etc/logstash/conf.d/extra/scripts/avips.rb", :class=>"TypeError", :backtrace=>["org/jruby/RubyRegexp.java:1107:in
match'", "/etc/logstash/conf.d/extra/scripts/avips.rb:5:in filter'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-ruby-3.1.4/lib/logstash/filters/ruby/script/context.rb:55:in
execute_filter'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-ruby-3.1.4/lib/logstash/filters/ruby/script.rb:30:in execute'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-ruby-3.1.4/lib/logstash/filters/ruby.rb:98:in
file_script'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-ruby-3.1.4/lib/logstash/filters/ruby.rb:84:in filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:145:in
do_filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:164:in block in multi_filter'", "org/jruby/RubyArray.java:1734:in
each'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:161:in multi_filter'", "/usr/share/logstash/logstash-core/lib/logstash/filter_delegator.rb:47:in
multi_filter'", "(eval):8476:in block in initialize'", "org/jruby/RubyArray.java:1734:in
each'", "(eval):8473:in block in initialize'", "(eval):1519:in
block in filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:445:in filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:424:in
worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:386:in block in start_workers'"]}
Below is the code written in ruby file.
`
def register(params)
end
def filter(event)
if /^.([sid:\s\d+]).$/.match(event)
return event
else
return nil
end
end
`
Below is the logstash filter code
filter { if "av" in [tags] and "test" in [tags] { ruby { path => "/etc/logstash/conf.d/extra/scripts/avips.rb" add_tag => ["ips"] } } }