Skip to content

Commit

Permalink
avoiding overwriting of tags with key named as 'tags'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hariprasad Selvaraj (hselvara) committed Apr 13, 2017
1 parent 6734f1c commit f98ae45
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/logstash/codecs/fluent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def decode(data, &block)
end # def decode

def encode(event)
tag = event.get("tags") || "log"
tag = event.get("tags") || "log"

epochtime = event.timestamp.to_i

# use normalize to make sure returned Hash is pure Ruby for
Expand Down Expand Up @@ -70,31 +71,34 @@ def decode_event(data, &block)
entries_decoder.feed_each(entries) do |entry|
epochtime = entry[0]
map = entry[1]
event = LogStash::Event.new(map.merge(
arr= []
event = LogStash::Event.new(map.merge!(
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
"tags" => [ tag ]
))
"tags" => tag
){ |key, v1, v2| arr.insert(0,v2,v1) })
yield event
end
when Array
# Forward
entries.each do |entry|
epochtime = entry[0]
map = entry[1]
event = LogStash::Event.new(map.merge(
arr= []
event = LogStash::Event.new(map.merge!(
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
"tags" => [ tag ]
))
"tags" => tag
){ |key, v1, v2| arr.insert(0,v2,v1) })
yield event
end
when Fixnum
# Message
epochtime = entries
map = data[2]
event = LogStash::Event.new(map.merge(
arr = []
event = LogStash::Event.new(map.merge!(
LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
"tags" => [ tag ]
))
"tags" => tag
){ |key, v1, v2| arr.insert(0,v2,v1) })
yield event
else
raise(LogStash::Error, "Unknown event type")
Expand Down

0 comments on commit f98ae45

Please sign in to comment.