From 3f28add0250539f9a01f3d9b38c5478222924efd Mon Sep 17 00:00:00 2001 From: JongHyok Lee Date: Fri, 22 Jun 2018 09:55:54 +0900 Subject: [PATCH] Added path tag to tail input plugin (#4292) --- plugins/inputs/tail/tail.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/tail/tail.go b/plugins/inputs/tail/tail.go index 86534da5f..0de2a344c 100644 --- a/plugins/inputs/tail/tail.go +++ b/plugins/inputs/tail/tail.go @@ -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))