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

When running in Chrome, it shows only text/plain, while with CURL it shows application/openmetrics-text #22

Open
ahus1 opened this issue Oct 13, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ahus1
Copy link

ahus1 commented Oct 13, 2024

I'm running a Quarkus application with a Prometheus endpoint which will shows the "old" Prometheus format without exemplars when accessing the metrics endpoint in the Chrome browser, and it will show the OpenMetrics output when running it via CURL.

I assume that the content negotiation where Chrome sends among other accepted format "text/html" somehow let's the application go down the path of the old format, while when CURL doesn't send any headers, it chooses the new format.

So I wonder: Can I (or this extension) have Chrome send "application/openmetrics-text" as a supported mime type, so that I will see exemplars in the Chrome window?

@fhemberger fhemberger added the enhancement New feature or request label Oct 14, 2024
@fhemberger
Copy link
Owner

The extension gets the current document request from Chrome and checks if its content type is either "application/openmetrics-text" (or "text/plain" and matching the path names defined). So basically you'd have to take every request matching the "text/plain" content type and try to request the same document as "application/openmetrics-text" again and work from there, which would be quite an overhead.

Also, the content type information you get in the extension itself isn't really great. Prometheus sends content-type: text/plain; version=0.0.4; charset=utf-8; escaping=values which would make it easier to detect Prometheus endpoints in the first place, but all the extension sees is content-type: text/plain.

So at the moment, I'm not really sure how to implement this check in a sensible way, but I'm open to suggestions.

As a short term solution, there seem to be Chrome extensions which can override headers. I just did a quick Google search on "chrome force content type", but haven't looked at any extension in particular.

Also, I haven't worked with exemplars yet, could you please provide some sort of example output so I can check if the highlighting still works correctly?

@ahus1
Copy link
Author

ahus1 commented Oct 17, 2024

Here's an example of a metrics with the exemplar. You'll see it after the hash:

http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="204",uri="/realms/{realm}/protocol/{protocol}/login-status-iframe.html/init"} 2.0 # {span_id="cc258ebf850c7ec8",trace_id="39750627ed1138e074b6256816bfa845"} 1.0 1728839669.614

About the content type: When writing this, I didn't have the response content type in mind, but the accepted types. My browser currently sends something like the following. I wonder if this extension could add application/openmetrics-text to it.

accept:
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.7

@fhemberger
Copy link
Owner

Thanks for the example!

I'm lookin into modifying the request headers, might take a little while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants