I have this code that used to be working in ELK 7.12 now that I've upgrade to 8.7.1 it gives a weird error in logstash
code =>
"
ip_src = Array.new
ip_src.push(IPAddr.new(event.get('OSA'),Socket::AF_INET))
i = 0
found = 0
@network_address.product(ip_src).each do |n, src|
if found > 1
return
end
if n.include?(src)
#event.set('[src_network_address]', n.to_s)
event.set('src_network_location', @network_location[i])
event.set('src_network_name', @network_name[i])
found += 1
end
i += 1
end
"
The error is
[ERROR] 2023-08-08 15:54:06.163 [[main]>worker7] ruby - Ruby exception occurred: undefined method `include?' for 2:Integer {:class=>"NoMethodError", :backtrace=>["(ruby filter code):14:in `block in filter_method'", "org/jruby/RubyArray.java:1865:in `each'", "(ruby filter code):10:in `block in filter_method'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-filter-ruby-3.1.8/lib/logstash/filters/ruby.rb:96:in `inline_script'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-filter-ruby-3.1.8/lib/logstash/filters/ruby.rb:89: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:1865:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:175:in `multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:133:in `multi_filter'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:304:in `block in start_workers'"]}
For some reason its complaining that the line with n.include? is unknown.
Is there a new syntax for this?
OSA= Original Source Address (its a v4 IP)
network_address is an array of IP/netwmask
I think the ,Socket::AF_INET should be inside the .new(), or you could just remove it. Socket::AF_INET is a constant with the value 2, so @network_addresses ends up as an array with 4 entries:
When you do the .product.each that ends up doing 2.include?, which throws the exception you are seeing.
If you change that to @network_address.push(IPAddr.new(row[0])) and adjust the sample messages so that they match your groks then you will get events like
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.