From 6e8b7e3cc677ae12beb0e7b8d103d37cd07c8edd Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 17 Oct 2018 12:43:58 -0600 Subject: [PATCH] Fix panic in logparser input (#4849) --- plugins/inputs/logparser/logparser.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/logparser/logparser.go b/plugins/inputs/logparser/logparser.go index 089c22d94..20ebeaa9e 100644 --- a/plugins/inputs/logparser/logparser.go +++ b/plugins/inputs/logparser/logparser.go @@ -131,8 +131,14 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error { l.done = make(chan struct{}) l.tailers = make(map[string]*tail.Tail) + mName := "logparser" + if l.GrokConfig.MeasurementName != "" { + mName = l.GrokConfig.MeasurementName + } + // Looks for fields which implement LogParser interface config := &parsers.Config{ + MetricName: mName, GrokPatterns: l.GrokConfig.Patterns, GrokNamedPatterns: l.GrokConfig.NamedPatterns, GrokCustomPatterns: l.GrokConfig.CustomPatterns, @@ -260,7 +266,7 @@ func (l *LogParserPlugin) parser() { if m != nil { tags := m.Tags() tags["path"] = entry.path - l.acc.AddFields(l.GrokConfig.MeasurementName, m.Fields(), tags, m.Time()) + l.acc.AddFields(m.Name(), m.Fields(), tags, m.Time()) } } else { log.Println("E! Error parsing log line: " + err.Error())