我在logstash有麻烦。我编写了以下代码:
ruby {
code => 'separated = event.get("[request_url]").split("/")
separated.each_index {|x|
temp = "P" + x.to_s
event.set(temp, separated[x])}'
}
我得到了以下错误:
[2021-07-26T16:27:37,135][ERROR][logstash.filters.ruby ][main][23b8bf19dac851a85d8c4d86162422f06362d00bf13b156291eea5b597c7f7ec] Ruby exception occurred: undefined method `split' for nil:NilClass {:class=>"NoMethodError", :backtrace=>["(ruby filter code):2: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:1809: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'"]}
我不知道问题出在哪里!有人能帮我吗?
1条答案
按热度按时间7kjnsjlb1#
我应该在使用它之前测试这个值。因此,我将代码更改为:
错误被修正了。