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

Prometheus actuator endpoint should produce a text/plain response unless application/openmetrics-text is explicitly accepted #28446

Closed
ThomasKasene opened this issue Oct 25, 2021 · 1 comment
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@ThomasKasene
Copy link
Contributor

ThomasKasene commented Oct 25, 2021

After upgrading from 2.5.5 to 2.5.6 I noticed my browser started downloading a file rather than displaying the Prometheus metrics in the tab. This makes it a little tedious to work with.

Anyway, the Accept header my browser is sending is:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

... and the responses from 2.5.5 and 2.5.6 are:

2.5.5: Content-Type: text/plain;version=0.0.4;charset=utf-8
2.5.6: Content-Type: application/openmetrics-text;version=1.0.0;charset=utf-8

I made a minimal example on Github - just change the version of the Spring Boot parent in pom.xml to reproduce:
https://github.com/ThomasKasene/example-spring-boot-prometheus

My hunch says this might be related to the discussions over at #28130 or #28137, but I'm not completely sure.

EDIT:
I should point out that I don't actually know whether this is considered a bug, or if it's "working as intended", and that the browser is the one at fault.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 25, 2021
@wilkinsona
Copy link
Member

From the Accept header's perspective, both 2.5.5 and 2.5.6 are behaving correctly as no preference is being expressed between text/plain and application/openmetrics-text. It's */* that matches both of those. From Prometheus's perspective, we've made a mistake in 2.5.6 and you're right that it's related to #28130.

On #28130, I said the following:

We're going to align with TextFormat. It ignores versions and quality. If there's an accept header and it contains application/openmetrics-text it produces application/openmetrics-text; version=1.0.0; charset=utf-8 otherwise it produces text/plain; version=0.0.4; charset=utf-8.

Unfortunately, this isn't what we implemented. We correctly prefer to produce application/openmetrics-text if it's explicitly accepted but we also serve it by default. To align with TextFormat, we should be serving text/plain by default. Happily for you, correcting this will also improve the situation when accessing the endpoint with a browser.

@wilkinsona wilkinsona changed the title Prometheus actuator endpoint returns the wrong content type Prometheus actuator endpoint should produce a text/plain response unless application/openmetrics-text is explicitly accepted Oct 25, 2021
@wilkinsona wilkinsona added this to the 2.5.x milestone Oct 25, 2021
@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 25, 2021
@wilkinsona wilkinsona self-assigned this Oct 28, 2021
@wilkinsona wilkinsona modified the milestones: 2.5.x, 2.5.7 Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants