Cannot use strftime in codecs


(Florin Andrei) #1

logstash-2.1.1

I am trying to use this codec to forward logs to a different app, using the tcp output plugin:

This is the output config:

  tcp {
    codec => logio {
      debug_output => "true"
    }
    host => "127.0.0.1"
    port => 28777
  }

But when I run logstash, it throws this error:

NoMethodError: undefined method `strftime' for "2016-01-29T19:49:47.856Z":LogStash::Timestamp
         encode at /opt/logstash-plugins/logstash/codecs/logio.rb:158
        receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-tcp-2.0.2/lib/logstash/outputs/tcp.rb:143
         handle at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.1-java/lib/logstash/outputs/base.rb:81
    output_func at (eval):274
   outputworker at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.1-java/lib/logstash/pipeline.rb:277
  start_outputs at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.1-java/lib/logstash/pipeline.rb:194

Obviously strftime doesn't work for some reason, on line 158 in the codec.

I've tried to use sprintf in that context, but it errors out again, saying it's a "private method".

How to format time data in a codec without strftime?


(system) #2