Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow measurement to be defined for logparser_grok plugin #1434

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
allow measurement to be defined for logparser_grok plugin
  • Loading branch information
nathanielc committed Jul 1, 2016
commit 83feb8551394bf45c2f4bec2cfaf8c8a867c4118
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