fix: add newline in execd for prometheus parsing (#10463)
This commit is contained in:
parent
5ab466464d
commit
61214bd33b
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
|
"github.com/influxdata/telegraf/plugins/parsers/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const sampleConfig = `
|
const sampleConfig = `
|
||||||
|
|
@ -100,10 +101,17 @@ func (e *Execd) cmdReadOut(out io.Reader) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, isPrometheus := e.parser.(*prometheus.Parser)
|
||||||
|
|
||||||
scanner := bufio.NewScanner(out)
|
scanner := bufio.NewScanner(out)
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
metrics, err := e.parser.Parse(scanner.Bytes())
|
data := scanner.Bytes()
|
||||||
|
if isPrometheus {
|
||||||
|
data = append(data, []byte("\n")...)
|
||||||
|
}
|
||||||
|
|
||||||
|
metrics, err := e.parser.Parse(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.acc.AddError(fmt.Errorf("parse error: %w", err))
|
e.acc.AddError(fmt.Errorf("parse error: %w", err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue