Skip to content

Added ability to specify scrape protocols to accept during HTTP content type negotiation.#12738

Merged
bwplotka merged 2 commits intomainfrom
formats
Oct 10, 2023
Merged

Added ability to specify scrape protocols to accept during HTTP content type negotiation.#12738
bwplotka merged 2 commits intomainfrom
formats

Conversation

@bwplotka
Copy link
Copy Markdown
Member

@bwplotka bwplotka commented Aug 22, 2023

This is done via new option in GlobalConfig and ScrapeConfig: "scrape_protocols"

@bwplotka bwplotka force-pushed the formats branch 2 times, most recently from a127463 to c2e1ecf Compare August 22, 2023 20:44
Copy link
Copy Markdown
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one question :)

@bwplotka bwplotka force-pushed the formats branch 2 times, most recently from 29b64ce to 0e99aa6 Compare August 24, 2023 11:30
@bwplotka
Copy link
Copy Markdown
Member Author

Friendly ping @roidelapluie @beorn7 (:

@roidelapluie
Copy link
Copy Markdown
Member

Wait..

@roidelapluie
Copy link
Copy Markdown
Member

roidelapluie commented Aug 31, 2023 via email

@bwplotka
Copy link
Copy Markdown
Member Author

bwplotka commented Sep 3, 2023

Hm, what bad things?

@bwplotka
Copy link
Copy Markdown
Member Author

bwplotka commented Sep 3, 2023

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.

🤔 @roidelapluie @beorn7

@beorn7
Copy link
Copy Markdown
Member

beorn7 commented Sep 5, 2023

I haven't studied this in detail yet, but I like pragmatic fallbacks, something like:

  • if the version number exposed by the target doesn't fit exactly, but Prometheus recognizes the protocol, try something "smart" (something like trying the most recent parser for that protocol, but stay within the same major versions if one could be parsed).
  • if nothing fits, try classic Prometheus text format as the universal fallback (that's what we do right now, don't we?)

@bwplotka
Copy link
Copy Markdown
Member Author

bwplotka commented Sep 20, 2023

@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).

@beorn7
Copy link
Copy Markdown
Member

beorn7 commented Sep 20, 2023

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).

@roidelapluie
Copy link
Copy Markdown
Member

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.

@bwplotka
Copy link
Copy Markdown
Member Author

bwplotka commented Oct 2, 2023

Ack, this is what we discussed in person too - moving to enums with version then - will do soon (:

@bwplotka bwplotka marked this pull request as draft October 2, 2023 14:29
@bwplotka bwplotka marked this pull request as ready for review October 9, 2023 09:21
@bwplotka
Copy link
Copy Markdown
Member Author

bwplotka commented Oct 9, 2023

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>
@bwplotka bwplotka merged commit 624b973 into main Oct 10, 2023
@bwplotka bwplotka deleted the formats branch October 10, 2023 10:16
bwplotka added a commit that referenced this pull request Oct 19, 2023
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>
bwplotka added a commit that referenced this pull request Oct 19, 2023
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>
bwplotka added a commit that referenced this pull request Oct 19, 2023
…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>
dmitryax pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Mar 25, 2024
…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.
jerrywang2352 pushed a commit to jerrywang2352/prometheus that referenced this pull request Jun 6, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants