I have the next ruby code
ruby {
code => '
m = event.get("ip_port").scan(/(\d+.\d+.\d+.\d+):(\d+)->(\d+.\d+.\d+.\d+):(\d+)/)
w = ; x = ; y = ; z =
m.each { |a|
w << a[0].to_fo
x << a[1].to_fo
y << a[2].to_fo
z << a[3].to_fo
}
event.set("ip_source", w)
event.set("port_source", x)
event.set("ip_dest", y)
event.set("port_dest", z)
'
}
And when I'm starting logstash, I have the next error
[2021-12-14T11:41:21,638][ERROR][logstash.filters.ruby ][main][30b39e8ec7a579953c0bbedb55fc148d9456eb0655c801b2bb6f8d7595851567] Ruby exception occurred: undefined method scan' for nil:NilClass {:class=>"NoMethodError", :backtrace=>["(ruby filter code):3:in
block in filter_method'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.7/lib/logstash/filters/ruby.rb:93:in inline_script'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.7/lib/logstash/filters/ruby.rb:86:in
filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:159:in do_filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:178:in
block in multi_filter'", "org/jruby/RubyArray.java:1820:in each'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:175:in
multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:134:in multi_filter'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:295:in
block in start_workers'"]}
Could you help me to fix the error?