Skip to content

Commit

Permalink
allow measurement to be defined for logparser_grok plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc authored and sparrc committed Jul 18, 2016
1 parent 1d9745e commit 8c7edeb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/inputs/logparser/grok/grok.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Parser struct {
Patterns []string
CustomPatterns string
CustomPatternFiles []string
Measurement string

// typeMap is a map of patterns -> capture name -> modifier,
// ie, {
Expand Down Expand Up @@ -114,6 +115,10 @@ func (p *Parser) Compile() error {
p.addCustomPatterns(scanner)
}

if p.Measurement == "" {
p.Measurement = "logparser_grok"
}

return p.compileCustomPatterns()
}

Expand Down Expand Up @@ -215,7 +220,7 @@ func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
}
}

return telegraf.NewMetric("logparser_grok", tags, fields, p.tsModder.tsMod(timestamp))
return telegraf.NewMetric(p.Measurement, tags, fields, p.tsModder.tsMod(timestamp))
}

func (p *Parser) addCustomPatterns(scanner *bufio.Scanner) {
Expand Down

0 comments on commit 8c7edeb

Please sign in to comment.