fix(inputs.prometheus): Initialize logger of parser (#15021)

This commit is contained in:
Sven Rebhan 2024-03-19 17:42:51 +01:00 committed by GitHub
parent 71f999fd83
commit fcb713a0a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -492,6 +492,7 @@ func (p *Prometheus) gatherURL(u URLAndAddress, acc telegraf.Accumulator) (map[s
Header: resp.Header, Header: resp.Header,
MetricVersion: p.MetricVersion, MetricVersion: p.MetricVersion,
IgnoreTimestamp: p.IgnoreTimestamp, IgnoreTimestamp: p.IgnoreTimestamp,
Log: p.Log,
} }
metrics, err := metricParser.Parse(body) metrics, err := metricParser.Parse(body)
if err != nil { if err != nil {

View File

@ -38,7 +38,7 @@ func (p *Parser) Parse(data []byte) ([]telegraf.Metric, error) {
data = append(data, []byte("\n")...) data = append(data, []byte("\n")...)
} }
case expfmt.FmtUnknown: case expfmt.FmtUnknown:
p.Log.Warnf("Unknown format %q... Trying to continue...", p.Header.Get("Content-Type")) p.Log.Debugf("Unknown format %q... Trying to continue...", p.Header.Get("Content-Type"))
} }
buf := bytes.NewBuffer(data) buf := bytes.NewBuffer(data)
decoder := expfmt.NewDecoder(buf, format) decoder := expfmt.NewDecoder(buf, format)