Skip to content

Conversation

@tgwizard
Copy link
Contributor

Currently if we query the Prometheus HTTP API with an invalid query, or there are other errors, the run_command or query_range methods just return nil. E.g. for the response

{"status": "error", "error": "1:6: parse error: unexpected identifier \"a\""}

This PR ensures we check the status field in the response body, which should be success on successful responses, and raises RequestError otherwise. Based on https://prometheus.io/docs/prometheus/latest/querying/api/.

I think some way of distinguishing good requests/responses from bad is nice, and given that there's already an exception here, perhaps we can reuse it?

@yaacov

Signed-off-by: Adam Renberg Tamm <[email protected]>
@tgwizard tgwizard force-pushed the handle-http-api-error-responses branch from 0d5805f to 0dafc9a Compare June 14, 2024 14:18
@yaacov yaacov merged commit a0bee50 into prometheus:master Jun 15, 2024
@yaacov
Copy link
Member

yaacov commented Jun 15, 2024

Thanks 💚

@tgwizard tgwizard deleted the handle-http-api-error-responses branch November 15, 2024 10:38
@tgwizard
Copy link
Contributor Author

@yaacov would you mind releasing this as v0.6.4?

@yaacov yaacov mentioned this pull request Nov 21, 2024
@yaacov
Copy link
Member

yaacov commented Nov 21, 2024

@yaacov would you mind releasing this as v0.6.4?

v0.6.4 released 🎉 🍰

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.

2 participants