Skip to content

Commit

Permalink
Fix panic in logparser input (influxdata#4849)
Browse files Browse the repository at this point in the history
  • Loading branch information
glinton authored and Jean-Louis Dupond committed Apr 22, 2019
1 parent 420e88e commit 2b1db03
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/inputs/logparser/logparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 2b1db03

Please sign in to comment.