-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
What did you do?
Configured Prometheus with metric_name_validation_scheme: legacy
What did you expect to see?
Prometheus scrapes without escaping=allow-utf-8
in the Accept header, that appears to be the intention from this change https://github.com/prometheus/prometheus/pull/14490/files#diff-4535d6172e0a9ab4e0879d71ef67ab69023f6eda9b44100343a6afa04fc8925fR732, i.e.only append that to the accept header if scheme is utf8
What did you see instead? Under which circumstances?
Prometheus scrapes with escaping=allow-utf-8
in the Accept header
I don't have any prometheus logs showing the header being set, but here's a patch that adds a failing test demonstrating the issue:
diff --git a/scrape/scrape_test.go b/scrape/scrape_test.go
index 2bb9c7247..7b3e87dd7 100644
--- a/scrape/scrape_test.go
+++ b/scrape/scrape_test.go
@@ -2826,6 +2826,8 @@ func TestTargetScraperScrapeOK(t *testing.T) {
accept := r.Header.Get("Accept")
if allowUTF8 {
require.Containsf(t, accept, "escaping=allow-utf-8", "Expected Accept header to allow utf8, got %q", accept)
+ } else {
+ require.NotContainsf(t, accept, "escaping=allow-utf-8", "Expected Accept header to not allow utf8, got %q", accept)
}
if protobufParsing {
require.True(t, strings.HasPrefix(accept, "application/vnd.google.protobuf;"),
@@ -2868,7 +2870,7 @@ func TestTargetScraperScrapeOK(t *testing.T) {
model.SchemeLabel, serverURL.Scheme,
model.AddressLabel, serverURL.Host,
),
- scrapeConfig: &config.ScrapeConfig{},
+ scrapeConfig: &config.ScrapeConfig{MetricNameValidationScheme: "legacy"},
},
client: http.DefaultClient,
timeout: configTimeout,
And here's a patch that has that test passing: that extra param is already unconditionally set previously:
diff --git a/config/config.go b/config/config.go
index 73282ac42..465affe08 100644
--- a/config/config.go
+++ b/config/config.go
@@ -523,7 +523,7 @@ func (s ScrapeProtocol) HeaderMediaType() string {
ScrapeProtocolsHeaders = map[ScrapeProtocol]string{
PrometheusProto: "application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited",
PrometheusText0_0_4: "text/plain;version=0.0.4",
- PrometheusText1_0_0: "text/plain;version=1.0.0;escaping=allow-utf-8",
+ PrometheusText1_0_0: "text/plain;version=1.0.0",
OpenMetricsText0_0_1: "application/openmetrics-text;version=0.0.1",
OpenMetricsText1_0_0: "application/openmetrics-text;version=1.0.0",
}
Some context:
- scrape: provide a fallback format #15136 Added the parameter unconditionally
- feat(utf8): utf-8 content negotiation and flags #14490 Added negotiating header values from config
System information
No response
Prometheus version
Prometheus configuration file
Alertmanager version
Alertmanager configuration file
Logs
ffilippopoulos, george-angel, DTLP, OysteinThuen and jmichalek132