Logstash Split Filter Error

  • System: CentOS 7
  • Logstash Version: 5.5
  • Config:
     if [stats] {

          # check type of stats if is array 
         
          ruby {
              code => 'case event.get("[stats]")
                      when Hash
                          event.tag("stats_object")
                      else
                          event.tag("stats_array")
                      end
                      '
          }

          ruby {
             code => "event.set('stats.length',event.get('stats').length)"
          }

          if [stats.length] == 0 {
              mutate {
                add_tag => ["zero_array"]
              }
          }
          
          if "stats_object" in [tags] {
             json{
                source =>"stats"
                skip_on_invalid_json => "true"
             }
          }

          # if it is an array, it needs to be split into seperated messages
          if "stats_array" in [tags] and [stats.length] > 0 {
               
               split {
                   field => "stats"
               }

               mutate {
                   add_tag => ["array_split"]
               }
          }
      }
  • Error:
[2018-10-28T22:50:41,365][ERROR][logstash.pipeline ] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. 

{"exception"=>"undefined method `empty?' for nil:NilClass", "backtrace"=>["/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-split-3.1.4/lib/logstash/filters/split.rb:89:in `filter'", "org/jruby/RubyArray.java:1613:in `each'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-split-3.1.4/lib/logstash/filters/split.rb:88: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 `multi_filter'", "org/jruby/RubyArray.java:1613: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:46:in `multi_filter'", "(eval):1277991:in `initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):1277988:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):1278024:in `initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):1278017:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):1278044:in `initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):1278037:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):74718:in `filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:399:in `filter_batch'", "org/jruby/RubyProc.java:281:in `call'", "/usr/share/logstash/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb:228:in `each'", "org/jruby/RubyHash.java:1342:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb:227:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:398:in `filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:379:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:342:in `start_workers'"]}

[2018-10-28T22:50:41,538][FATAL][logstash.runner ] An unexpected error occurred! {:error=>#<NoMethodError: undefined method `empty?' for nil:NilClass>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-split-3.1.4/lib/logstash/filters/split.rb:89:in `filter'", "org/jruby/RubyArray.java:1613:in `each'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-split-3.1.4/lib/logstash/filters/split.rb:88: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 `multi_filter'", "org/jruby/RubyArray.java:1613: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:46:in `multi_filter'", "(eval):1277991:in `initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):1277988:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):1278024:in `initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):1278017:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):1278044:in `initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):1278037:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):74718:in `filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:399:in `filter_batch'", "org/jruby/RubyProc.java:281:in `call'", "/usr/share/logstash/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb:228:in `each'", "org/jruby/RubyHash.java:1342:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb:227:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:398:in `filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:379:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:342:in `start_workers'"]}

What could be the reason for this kind of failure?

Seems like it is caused by a bug in the split filter, where sometimes an array containing null values was not handled properly. It's apparently fixed on version 3.1.6 as per https://github.com/logstash-plugins/logstash-filter-split/pull/31

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