- set @timestamp field correctly

This commit is contained in:
Jordan Sissel 2013-08-25 00:05:24 -07:00
parent b5a71c9ce6
commit 10e42a6c88

View file

@ -11,13 +11,15 @@ class LogStash::Codecs::OldLogStashJSON < LogStash::Codecs::Base
h = {}
# Convert the old logstash schema to the new one.
basics = %w(@timestamp @message @source_host @source_path @source
basics = %w(@message @source_host @source_path @source
@tags @type)
basics.each do |key|
# Convert '@message' to 'message', etc
h[key[1..-1]] = obj[key] if obj.include?(key)
end
h["@timestamp"] = obj["@timestamp"] if obj.include?("@timestamp")
h.merge!(obj["@fields"]) if obj["@fields"].is_a?(Hash)
yield LogStash::Event.new(h)
end # def decode