-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
area/prometheusbugunexpected problem or unintended behaviorunexpected problem or unintended behaviorhelp wantedRequest for community participation, code, contributionRequest for community participation, code, contribution
Description
Relevent telegraf.conf
[[inputs.prometheus]]
urls = ["http://localhost:8080/metrics"]System info
Telegraf 1.20.4 MacOS 11.6.1
Docker
No response
Steps to reproduce
The issue is related to the Accept header of the Prometheus input plugin:
- Let's say we have a service that prefers the OpenMetrics format or exclusively supports it
- Since Telegraf accepts any media types (see: Accept any media type in the prometheus input #6745) it should be able to parse the OpenMetrics format in the response (because of
*/*) - But Telegraf is not able to parse the OpenMetrics format (see: Support for OpenMetrics standard #9547) so it fails with:
2021-12-09T02:43:40Z E! [inputs.prometheus] Error in plugin: error reading metrics for http://localhost:8080/metrics: reading text format failed: text format parsing error in line 118: invalid escape sequence '\"'
Expected behavior
Telegraf should only accept the formats it supports (no */*):
application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3
Actual behavior
Telegraf should not accept everything (see */*):
application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3,*/*;q=0.1
In this case, if the service only support OpenMetrics, Telegraf should get 406 Not Acceptable instead of a response in the OpenMetrics format that it tries and fails to parse.
Additional info
Prometheus itself also defines */* as a fallback but it supports both formats (and it prefers OpenMetrics) so it does not get into any trouble if the client prefers or only supports OpenMetrics:
application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1
Metadata
Metadata
Assignees
Labels
area/prometheusbugunexpected problem or unintended behaviorunexpected problem or unintended behaviorhelp wantedRequest for community participation, code, contributionRequest for community participation, code, contribution