Skip to content

Commit

Permalink
Added filename tag to tail input plugin and set tag name as 'path' fo…
Browse files Browse the repository at this point in the history
…r consistency with logparser input plugin.
  • Loading branch information
wingsof committed Jun 18, 2018
1 parent 7781507 commit daff426
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/inputs/tail/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ func (t *Tail) receiver(tailer *tail.Tail) {

m, err = t.parser.ParseLine(text)
if err == nil {
t.acc.AddFields(m.Name(), m.Fields(), m.Tags(), m.Time())
if m != nil {
tags := m.Tags()
tags["path"] = tailer.Filename
t.acc.AddFields(m.Name(), m.Fields(), tags, m.Time())
}
} else {
t.acc.AddError(fmt.Errorf("E! Malformed log line in %s: [%s], Error: %s\n",
tailer.Filename, line.Text, err))
Expand Down

0 comments on commit daff426

Please sign in to comment.