From 7df14d16800f99a854568147a1bfe227f16adc30 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 089c22d943b1d..20ebeaa9e1546 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())