logstash/logstash — pull request #224 by kamorin (2012-10-19 01:29:21+00:00)
Title: MongoDB output Datetime support

I tried making the change to Event class and returning Time object. However I'm getting

"exception":"undefined method `parse' for Time:Class" "backtrace":["file:/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/event.rb:82:in `ruby_timestamp'","file:/opt/logstash/logstash-1.1.1-monolithic.jar!/logstash/outputs/mongodb.rb:48:in

time is already included? Is this a problem with time.rb logstash class?

Thanks

===

Doing "Time.now' throws away the real timestamp of the event.

For this patch, it's probably worth adding a new method 'ruby_timestamp' to the LogStash::Event class, similar to unix_timestamp method, but instead of returning unix epoch return a Time object. The parsing stuff is already in there so it should be mostly a copy-paste effort.

After that you can override the timestamp as you wish with a proper Time instance that's still correct for the event.

Thoughts?