-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
add api for /api/v1/alerts #2600
Conversation
Having a quick look at this, it seems you've exposed alert rules, not alerts, so perhaps this should be exposes under Also, each alert rule can have multiple active alerts (differentiated by the labels), which currently is partially exposed by this PR by the Also, you're exposing the parsed alert rule here, which is more than the UI exposes. I wonder whether it would be preferable to just expose the alert rule as some text (as suggested by @brancz in #2467), so we don't lock ourselves into another format. @fabxc WDYT? This issues seem relevant: #1570 |
In terms of exposing alerting rules, I think we should actually have both, parsed and not parsed, whereas what we expose in the UI currently is an odd mix of both (not that it doesn't serve it's purpose well). I think we should 1) expose the loaded rule files, which are completely unmodified as they came from disk and 2) a parsed representation, so that UIs that can be built on top of the API don't have to implement a parser for alerting rules themselves. |
@fabxc : could you please provide guidance /direction? |
I agree with @brancz that we ultimately want both. Probably one Additionally, we should also have and endpoint exposing configuration and rule files (as mentioned in the past, everything in our UI should be available via API too). Maybe along the lines of:
That's not a definitive spec. Just my opinion at this point. |
The status endpoint sounds good to me. Regarding the config I think we should return JSON and YAML (maybe even the pure unparsed yaml additionally). I don't recall how we hold rules in memory (1 pool of rules, by file they came from, etc.) and with rule groups coming up, we may need to change that, so I'm hesitant to expose anything at this point in a stable API that's not the plaintext filename and content that were loaded. Wdyt @fabxc ? |
We'll want raw so comments and the like can be inspected for those using configuration management. |
@brian-brazil agreed! |
@fabxc @brian-brazil : thank you sirs for yall feedback .... ill work on it |
hi @mg03, are you still actively working on this PR? |
And for us too 👍 |
Hi @mg03 , |
Hey there, Is someone still working on this proposition (aka exposing prometheus rules as a json)? I need to extract rules in order to pre-configure an external monitoring system before I send alerts to it via an alertmanager wehook. I was thinking to do a temporary html parser for /rules on the main prometheus UI for now but that's far from ideal :) Thanks |
maybe it should add another column called |
Hi
this merge contains code to expose /api/v1/alerts . The output is json. Example is
{ "status": "success", "data": { "alerts": [ { "name": "promup", "query": "up{job=\"prometheus\"} != 1", "duration": "1m0s", "labels": { "severity": "critical" }, "annotations": { "dashboard": "http://grafana.com/dashboard/somedashbaord", "description": "lol hahahahha", "summary": "Prom Up" }, "status": "inactive" }, { "name": "promx", "query": "up{job=\"prom\"} < 1", "duration": "1m5s", "labels": { "severity": "critical" }, "annotations": { "dashboard": "http://grafana.com/dashboard/somedashbaord", "description": "sad sad", "summary": "Promxxxxx Up" }, "status": "pending", "activesince": "2017-03-31T19:09:07.808-07:00" }, { "name": "promnoann", "query": "up{job=\"prom\"} < 1", "duration": "10s", "labels": { "severity": "critical" }, "status": "firing", "activesince": "2017-03-31T19:09:07.808-07:00" } ] } }