mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
msgpack does support ruby time ::sigh:: hack around it.
This commit is contained in:
parent
1f58ac5b9e
commit
279711497a
1 changed files with 6 additions and 5 deletions
|
@ -12,17 +12,17 @@ class LogStash::Codecs::Msgpack < LogStash::Codecs::Base
|
|||
def decode(data)
|
||||
begin
|
||||
# Msgpack does not care about UTF-8
|
||||
event = LogStash::Event.new(MessagePack.unpack(raw))
|
||||
event = LogStash::Event.new(MessagePack.unpack(data))
|
||||
event["@timestamp"] = Time.at(event["@timestamp"]).utc if event["@timestamp"].is_a? Float
|
||||
event["tags"] ||= []
|
||||
if @format
|
||||
event.message ||= event.sprintf(@format)
|
||||
end
|
||||
rescue => e
|
||||
## TODO(sissel): Instead of dropping the event, should we treat it as
|
||||
## plain text and try to do the best we can with it?
|
||||
# Treat as plain text and try to do the best we can with it?
|
||||
@logger.warn("Trouble parsing msgpack input, falling back to plain text",
|
||||
:input => raw, :exception => e)
|
||||
event.message = raw
|
||||
:input => data, :exception => e)
|
||||
event.message = data
|
||||
event["tags"] ||= []
|
||||
event["tags"] << "_msgpackparsefailure"
|
||||
end
|
||||
|
@ -31,6 +31,7 @@ class LogStash::Codecs::Msgpack < LogStash::Codecs::Base
|
|||
|
||||
public
|
||||
def encode(event)
|
||||
event["@timestamp"] = event["@timestamp"].to_f
|
||||
@on_event.call event.to_hash.to_msgpack
|
||||
end # def encode
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue