Skip to content

Commit

Permalink
Fix tags applied to wrong metric on parse error (influxdata#5650)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and Mathieu Lecarme committed Apr 17, 2020
1 parent ef914a8 commit 429c1ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/parsers/influx/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ func (h *MetricHandler) SetTimestamp(tm []byte) error {
h.builder.SetTime(time.Unix(0, ns))
return nil
}

func (h *MetricHandler) Reset() {
h.builder.Reset()
}
2 changes: 2 additions & 0 deletions plugins/parsers/influx/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
}

if err != nil {
p.handler.Reset()
return nil, &ParseError{
Offset: p.machine.Position(),
LineOffset: p.machine.LineOffset(),
Expand All @@ -87,6 +88,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {

metric, err := p.handler.Metric()
if err != nil {
p.handler.Reset()
return nil, err
}

Expand Down

0 comments on commit 429c1ae

Please sign in to comment.