Added path tag to tail input plugin (#4292)

This commit is contained in:
JongHyok Lee 2018-06-22 09:55:54 +09:00 committed by Daniel Nelson
parent ee6e4b0afd
commit 3f28add025
1 changed files with 5 additions and 1 deletions

View File

@ -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))