Skip to content

Commit

Permalink
avoid overriding path if already present in json + decorate last
Browse files Browse the repository at this point in the history
  • Loading branch information
wiibaa committed Jan 21, 2015
1 parent 0159a2f commit d0a1781
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/logstash/inputs/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def register
require "filewatch/tail"
require "digest/md5"
@logger.info("Registering file input", :path => @path)
@host = Socket.gethostname.force_encoding(Encoding::UTF_8)

@tail_config = {
:exclude => @exclude,
Expand Down Expand Up @@ -127,14 +128,14 @@ def run(queue)
@tail = FileWatch::Tail.new(@tail_config)
@tail.logger = @logger
@path.each { |path| @tail.tail(path) }
hostname = Socket.gethostname

@tail.subscribe do |path, line|
@logger.debug? && @logger.debug("Received line", :path => path, :text => line)
@codec.decode(line) do |event|
event["[@metadata][path]"] = path
event["host"] = @host if !event.include?("host")
event["path"] = path if !event.include?("path")
decorate(event)
event["host"] = hostname if !event.include?("host")
event["path"] = path
queue << event
end
end
Expand Down

0 comments on commit d0a1781

Please sign in to comment.