Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPEC: clarify what output format we require for /metrics #678

Closed
donbourne opened this issue Jul 7, 2022 · 3 comments · Fixed by #690
Closed

SPEC: clarify what output format we require for /metrics #678

donbourne opened this issue Jul 7, 2022 · 3 comments · Fixed by #690
Assignees
Milestone

Comments

@donbourne
Copy link
Member

We need to decide whether we expect compliant implementations to export metrics in Prometheus format or OpenMetrics format.

The MP metrics spec, as currently written, says that it supports OpenMetrics text format, but in reality it supports Prometheus format (the Prometheus and OpenMetrics formats have diverged somewhat since the previous MP Metrics spec was written)

Micrometer's PrometheusMeterRegistry supports collecting scrapes in either Prometheus or OpenMetrics format (though at the moment the Units line and _created line found in OpenMetrics format are not supported), so it would be relatively easy for Micrometer-based implementations to accomodate exporting metrics in either format.

OpenTelemetry is discussing accepting and producing metrics in the OpenMetrics format (see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/openmetrics-guidelines.md), but also mentions it needs to interoperate with the Prometheus format.

I suggest we adopt the same approach here as is described in the OpenTelemetry spec (https://opentelemetry.io/docs/reference/specification/metrics/sdk_exporters/prometheus/) which says...

@donbourne donbourne added this to the 5.0 milestone Jul 7, 2022
@donbourne donbourne changed the title clarify what output format we require for /metrics SPEC: clarify what output format we require for /metrics Jul 7, 2022
@donbourne donbourne self-assigned this Jul 26, 2022
@donbourne
Copy link
Member Author

original thought on this was that we would require implementations to support Prometheus format text output from /metrics, but that they may also support OpenMetrics format...
but that raises the question -- how would an implementation be expected to allow the choice between the two formats when making a call to /metrics?

@tjquinno
Copy link
Contributor

tjquinno commented Jul 27, 2022

Transcribed from gitter...

I see at least two use cases:

  • an administrator wants to set up which format the service uses by default (sounds like a config setting), and
  • a client wants to request a specific format.

There seems to be no official IANA media type for either Prometheus or OpenMetrics. That said,
this issue OpenObservability/OpenMetrics#79 shows that OpenMetrics folks pondered this question and there's a related PR that adopted a particular name but I don't see the name in the IANA mime types catalog so it's hard to know what to make of that.

Yet, there is evidence (code) that application/openmetrics-text; version=1.0.0; charset=utf-8 is in use, at least in some places. (e.g., spring-projects/spring-boot#28130). This uses the media type proposed in the OpenMetrics issue linked above.

So, even though that is not an official cataloged media type according to IANA there does seem to be some use of it in the wild. We could consider Accept as a way for clients to request what they want when accessing /metrics. Off the cuff, I would guess that Accept: text/plain would request Prometheus format, whereas Accept: application/openmetrics-text would request Prometheus format.

Failing that, there's always a query parameter such as ?format=openmetrics or ?format=prometheus.

@donbourne
Copy link
Member Author

I see also at https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#iana-considerations-iana the following:

EDITOR’S NOTE: application/openmetrics-text is in active use since 2018, application/openmetrics-proto is not yet in active use.

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 a pull request may close this issue.

2 participants