Added ability to specify scrape protocols to accept during HTTP content type negotiation.#12738
Conversation
a127463 to
c2e1ecf
Compare
ArthurSens
left a comment
There was a problem hiding this comment.
LGTM, just one question :)
29b64ce to
0e99aa6
Compare
|
Friendly ping @roidelapluie @beorn7 (: |
|
Wait.. |
|
This is an open door to all sort of bad things. I would not have free text.
Le jeu. 31 août 2023, 00:20, Bartlomiej Plotka ***@***.***> a
écrit :
… ***@***.**** commented on this pull request.
------------------------------
In scrape/scrape.go
<#12738 (comment)>
:
> @@ -807,10 +809,20 @@ type targetScraper struct {
var errBodySizeLimit = errors.New("body size limit exceeded")
-const (
- scrapeAcceptHeader = `application/openmetrics-text;version=1.0.0,application/openmetrics-text;version=0.0.1;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
- scrapeAcceptHeaderWithProtobuf = `application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited,application/openmetrics-text;version=1.0.0;q=0.8,application/openmetrics-text;version=0.0.1;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1`
-)
+func acceptHeader(sps []config.ScrapeProtocol) string {
+ var vals []string
+ for _, sp := range sps {
+ switch {
+ case sp.Equals(config.PrometheusText):
+ vals = append(vals, "text/plain;version=0.0.4;q=0.5")
+ case sp.Equals(config.PrometheusProto):
+ vals = append(vals, "application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited")
+ case sp.Equals(config.OpenMetricsText):
+ vals = append(vals, "application/openmetrics-text;version=1.0.0,application/openmetrics-text;version=0.0.1;q=0.75,*/*;q=0.1")
I consider changing to header values for more flexibility and simplicity:
[image: image]
<https://user-images.githubusercontent.com/6950331/264486651-67519d7c-2f82-4d31-a5ff-c16134997d08.png>
WDYT?
—
Reply to this email directly, view it on GitHub
<#12738 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHHJRCF6CDZNVUYIQF463XX64C7ANCNFSM6AAAAAA32OPQII>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Hm, what bad things? |
|
The alternatives to my proposal are: B) Multiple enum values like "OpenMetrics1.0.0", "OpenMetrics0.0.1", "PrometheusText0.0.4" "PrometheusProto" (proto is not versioned) and if new version of something comes in users are blocked (until code is changed). Also more work for us to maintain and update those. C) Enums for types of format and free form semver version. This gives us ability to experiment with new versions of formats. More complex code, more flexibility for users. I guess the benefit of B is that those are formats Prometheus supports and this is clearly guarded by those options. |
|
I haven't studied this in detail yet, but I like pragmatic fallbacks, something like:
|
|
@beorn7 I think you are speaking about something else. We don't change parsing here, we only change Accept header that will be passed to clients. It's up to clients to give us something based on our priority as well as what they implement (support). |
|
Yeah, sorry. I'll have a closer look ASAP (which might not be very soon in absolute terms, but let's see if somebody else beats me to it). |
|
I want promethe to only send accept headers that are clearly defined. I do not really care about the enums we are using but let's not allow free text. |
|
Ack, this is what we discussed in person too - moving to enums with version then - will do soon (: |
|
PTAL, updated to enums. 🤗 cc @roidelapluie @beorn7 |
…nt type negotiation. This is done via new option in GlobalConfig and ScrapeConfig: "scrape_protocol" Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: bwplotka <bwplotka@gmail.com>
Broken by #12738. We have to update both global variables (as GlobalConfig is not a pointer here). DefaultConfig is used when no global: section is provided, whereas DefaultGlobalConfig is used when it's provided and for individual scrape configsReported on #prometheus-dev (thanks to @beorn7): https://cloud-native.slack.com/archives/C01AUBA4PFE/p1697733267205649 Tested manually, it would be nice to add test at some point (quick fix for now). Signed-off-by: bwplotka <bwplotka@gmail.com>
Broken by #12738. We have to update both global variables (as GlobalConfig is not a pointer here). DefaultConfig is used when no global: section is provided, whereas DefaultGlobalConfig is used when it's provided and for individual scrape configs. Reported on #prometheus-dev (thanks to @beorn7): https://cloud-native.slack.com/archives/C01AUBA4PFE/p1697733267205649 Tested manually, it would be nice to add test at some point (quick fix for now). Signed-off-by: bwplotka <bwplotka@gmail.com>
…13010) Broken by #12738. We have to update both global variables (as GlobalConfig is not a pointer here). DefaultConfig is used when no global: section is provided, whereas DefaultGlobalConfig is used when it's provided and for individual scrape configs. Reported on #prometheus-dev (thanks to @beorn7): https://cloud-native.slack.com/archives/C01AUBA4PFE/p1697733267205649 Tested manually, it would be nice to add test at some point (quick fix for now). Signed-off-by: bwplotka <bwplotka@gmail.com>
…30934) Fixes #30883 Prometheus PR we need to adapt to: prometheus/prometheus#12738 The configuration option we were using to enable protobuf has been removed, so this PR removes the `enable_protobuf_negotiation` configuration on the prometheus receiver. In its place, the prometheus server now has a config option, `scrape_protocols`, which specifies which protocols it uses, including protobuf. Use `config.global.scrape_protocols = [ PrometheusProto, OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText0.0.4 ]` to enable protobuf scraping instead of using our option. Prometheus PR we need to adapt to: prometheus/prometheus#12958 We now need to pass a prometheus.Registerer to the scrape manager to collect metrics about scrapes. This PR disables the collection of these scrape metrics from the prometheus server. We did not use the default registry, so we were previously collecting these metrics and never exposing them. This PR passes a no-op registerer to prevent using memory to store those metrics. In the future, we can consider using the prometheus -> OTel bridge to export these with the self-observability pipeline.
…nt type negotiation. (prometheus#12738) * Added ability to specify scrape protocols to accept during HTTP content type negotiation. This is done via new option in GlobalConfig and ScrapeConfig: "scrape_protocol" Signed-off-by: bwplotka <bwplotka@gmail.com> * Fixed readability and log message. Signed-off-by: bwplotka <bwplotka@gmail.com> --------- Signed-off-by: bwplotka <bwplotka@gmail.com>
This is done via new option in GlobalConfig and ScrapeConfig: "scrape_protocols"