Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Handle HTTP API error responses #25

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

Merged
merged 1 commit into from
Jun 15, 2024

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
1 check passed
@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