Fix panic in logparser input (#4849)

This commit is contained in:
Greg 2018-10-17 12:43:58 -06:00 committed by Greg Linton
parent 48745c3171
commit 6e8b7e3cc6
1 changed files with 7 additions and 1 deletions

View File

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