Backend: Set content-type on metrics endpoints - #5042
Conversation
|
@brandon1024 Thank you very much! I apologize for the wait. It would be great to use the Is it required to add a "version" like |
|
No worries at all @lastzero :-)
Can do! I'll make this change tonight and ping you when it's done.
According to the prometheus docs, the The official
|
|
I see. So, the version doesn't refer to the client library or our application version, which we could read dynamically? If so, you can add a suitable content type constant for this to the file linked above. π |
|
Genau, it's the version of the text format itself and not the client :) Can do! Thanks! |
The prometheus text format requires metrics endpoints respond with the content-type 'text/plain; version=0.0.4'. Without this, newer versions of prometheus fail to scrape the metrics endpoint and report an error. It's possible to work around this by setting the 'fallback_scrape_protocol' setting in the prometheus scrape target configuration, but this revision sets the content type appropriately to avoid this in the first place. Add test for the content type in the response.
|
@lastzero This should be ready to go now :-) |
|
Thank you very much! β¨ |
Signed-off-by: Michael Mayer <michael@photoprism.app>
Overview
The prometheus text format requires metrics endpoints respond with the content-type
text/plain; version=0.0.4. Without this, newer versions of prometheus fail to scrape the metrics endpoint and report an error. It's possible to work around this by setting thefallback_scrape_protocolsetting in the prometheus scrape target configuration, but this revision sets the content type appropriately to avoid this in the first place.Add test for the content type in the response.
Fix Details
With the latest version of Prometheus, after configuring photoprism as a scrape target with standard configuration, prometheus scrapes fail with the error below:
I've been using the docker compose configuration below for my testing, and you can use this to test if you'd like. I believe the standard compose configuration in the project should suffice too.
After this revision, the scrape succeeds.
The prometheus exposition format documentation can be found here.
Acceptance Criteria