logstash-plugins / logstash-output-datadog_metrics

Apache License 2.0
3 stars 18 forks source link

Can't parse the LogStash::Timestamp #3

Open slava-vishnyakov opened 9 years ago

slava-vishnyakov commented 9 years ago
NoMethodError: undefined method `gsub!' for "2015-06-09T12:50:04.000Z":LogStash::Timestamp
         _parse at /opt/logstash/vendor/jruby/lib/ruby/1.9/date/format.rb:839
          parse at /opt/logstash/vendor/jruby/lib/ruby/1.9/time.rb:265
       to_epoch at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-datadog_metrics-0.1.4/lib/logstash/outputs/datadog_metrics.rb:120
        receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-datadog_metrics-0.1.4/lib/logstash/outputs/datadog_metrics.rb:75
         handle at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/outputs/base.rb:88
    output_func at (eval):163
   outputworker at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/pipeline.rb:244
  start_outputs at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/pipeline.rb:166

Will provide a code for the error in a few minutes.

slava-vishnyakov commented 9 years ago
cat > /tmp/filter.txt << EOM
input { stdin {  } }

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}" }
  }
  date {
    match => [ "timestamp", "dd/MMM/YYYY:HH:mm:ss Z"]
  }
}

output {
  datadog_metrics {
      api_key => "..."
      metric_name => 'response_time'
      metric_type => "counter"
      metric_value => "1"      
  }
}
EOM

echo '1.2.3.4 - - [09/Jun/2015:15:50:04 +0300] "POST / HTTP/1.1" 499 0 "-" "-" "-"' | /opt/logstash/bin/logstash -e "$(cat /tmp/filter.txt)"

This code triggers the error

slava-vishnyakov commented 9 years ago

https://github.com/logstash-plugins/logstash-output-datadog_metrics/pull/1 solves it

devinrsmith commented 9 years ago

+1