Skip to content

Commit

Permalink
merge influxdata#10463, add newline in execd for prometheus parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
arstercz committed Jan 20, 2022
1 parent 0daaa59 commit d54ef06
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/inputs/execd/execd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers"
"github.com/influxdata/telegraf/plugins/parsers/influx"
"github.com/influxdata/telegraf/plugins/parsers/prometheus"
)

const sampleConfig = `
Expand Down Expand Up @@ -100,9 +101,16 @@ func (e *Execd) cmdReadOut(out io.Reader) {
return
}

_, isPrometheus := e.parser.(*prometheus.Parser)

scanner := bufio.NewScanner(out)

for scanner.Scan() {
data := scanner.Bytes()
if isPrometheus {
data = append(data, []byte("\n")...)
}

metrics, err := e.parser.Parse(scanner.Bytes())
if err != nil {
e.acc.AddError(fmt.Errorf("parse error: %w", err))
Expand Down

0 comments on commit d54ef06

Please sign in to comment.