chore(parsers.prometheus): Do not warn about unknown format without headers (#16166)
This commit is contained in:
parent
e5e52f0a4a
commit
54dcd2d8cb
|
|
@ -33,7 +33,9 @@ func (p *Parser) SetDefaultTags(tags map[string]string) {
|
||||||
func (p *Parser) Parse(data []byte) ([]telegraf.Metric, error) {
|
func (p *Parser) Parse(data []byte) ([]telegraf.Metric, error) {
|
||||||
// Determine the metric transport-type derived from the response header and
|
// Determine the metric transport-type derived from the response header and
|
||||||
// create a matching decoder.
|
// create a matching decoder.
|
||||||
format := expfmt.ResponseFormat(p.Header)
|
format := expfmt.NewFormat(expfmt.TypeProtoCompact)
|
||||||
|
if len(p.Header) > 0 {
|
||||||
|
format = expfmt.ResponseFormat(p.Header)
|
||||||
switch format.FormatType() {
|
switch format.FormatType() {
|
||||||
case expfmt.TypeProtoText:
|
case expfmt.TypeProtoText:
|
||||||
// Make sure we have a finishing newline but no trailing one
|
// Make sure we have a finishing newline but no trailing one
|
||||||
|
|
@ -44,6 +46,7 @@ func (p *Parser) Parse(data []byte) ([]telegraf.Metric, error) {
|
||||||
case expfmt.TypeUnknown:
|
case expfmt.TypeUnknown:
|
||||||
p.Log.Debugf("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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue