Exception when trying to use mutate to convert an integer to boolean

First off, I am using 6.0.0-rc1 in docker. I'm using the jdbc input plugin to fetch some data out of mysql, and I need to convert an integer (tinyint in the schema) to boolean to suit my desired index type. The values in the database are always 0 or 1. My filter config is like so:

filter {
    mutate {
        convert => {
            "archived" => "boolean"
        }
    }
}

When I run logstash, I get the following error:

[ERROR][logstash.pipeline ] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {:pipeline_id=>"novasub-ingest", "exception"=>"undefined method empty?' for 0:Fixnum", "backtrace"=>["/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-mutate-3.1.6/lib/logstash/filters/mutate.rb:297:in convert_boolean'", "org/jruby/RubyMethod.java:115:in call'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-mutate-3.1.6/lib/logstash/filters/mutate.rb:271:in block in convert'", "org/jruby/RubyHash.java:1343:in each'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-mutate-3.1.6/lib/logstash/filters/mutate.rb:257:in convert'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-mutate-3.1.6/lib/logstash/filters/mutate.rb:218: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:48:in multi_filter'", "(eval):42:in block in filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:504:in block in filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb:228:in block in each'", "org/jruby/RubyHash.java:1343: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:501:in filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:477:in worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:439:in block in start_workers'"], :thread=>"#<Thread:0x5ed0a429@/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:290 sleep>"}

If I change my query to return "true" or "false" for that column, it works fine. If I set it to statically return 0 or 1, I get the error as well. Is this a mistake on my part?

This is a bug.

As a workaround you can first convert archived to a string and then do the bool conversion in another mutate filter.

1 Like

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