Skip to content

Accept pushes in the OpenMetrics text format - #888

Open
cvas22 wants to merge 1 commit into
prometheus:masterfrom
cvas22:feat/400-openmetrics-push
Open

cvas22 wants to merge 1 commit into
prometheus:masterfrom
cvas22:feat/400-openmetrics-push

Conversation

@cvas22

@cvas22 cvas22 commented Nov 10, 2026

Copy link
Copy Markdown

Fixes #400

prometheus/common v0.73 has an OpenMetrics 1.0 parser now (prometheus/common#1015), which was the blocker beorn7 pointed out on the issue. So this bumps common to v0.73.1 and sends pushes with Content-Type: application/openmetrics-text through expfmt.NewDecoder. Versions 0.0.1 and 1.0.0 work, anything else gets a 400. Names are validated with the same scheme as the other formats, so --push.enable-utf8-names behaves the same way.

The main thing people wanted was exemplars. They're kept on the pushed metrics and show up on protobuf scrapes. I also added --web.enable-openmetrics so they can show up on OpenMetrics scrapes. It's off by default because Prometheus prefers OpenMetrics when a target offers it, and I didn't want existing setups to quietly switch scrape formats.

Notes

Tests cover the three content type variants, a body without # EOF and an unknown version. I haven't run them locally, CI will. The common bump also pulls a few x/ deps, same as what dependabot has queued in #886.

prometheus/common v0.73 can parse OpenMetrics 0.0.1 and 1.0.0, so a push
with Content-Type application/openmetrics-text now goes through that
parser instead of the classic text parser. Names are validated with the
same scheme as the other formats, and unknown versions are rejected.

Exemplars from these pushes are kept. They're exposed on protobuf scrapes,
and on OpenMetrics scrapes when the new --web.enable-openmetrics flag is
set. It's off by default because Prometheus prefers OpenMetrics when it's
offered, which would change the scrape format for existing setups.

Fixes prometheus#400

Signed-off-by: Srinivas Chippagiri <cvas22@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.

Support for the OpenMetrics format

1 participant