-
Notifications
You must be signed in to change notification settings - Fork 9.6k
HTTP API for getting alerts #1570
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
Comments
There is no HTTP API, however you can access the |
Looks like only firing alerts are available there and annotations are missing. |
There was a PR for that a while back. We should reconsider having an API I raised before that we generally want to have an API that allows to build On Thu, Apr 21, 2016, 9:32 PM Roman Belyakovsky notifications@github.com
|
I'm thinking of a telegram bot to get more details on alerts when internet connection is limited and web UI is difficult to access. By the way it's not mobile friendly for some reason, pretty unusual for a bootstrap based one. |
For that sort of thing, a link to a dashboard generally works best. |
That's much more to load than just an annotation string. So looking forward for an API. =) |
Personally I want this to embed Alert status in Grafana. If Prometheus provide API, it's very helpful. |
ALERTS is fine but doesn't seem to show inactive alerts. An API would be great. Looked quickly at the code, looks like simply converting to json the result of h.ruleManager.AlertingRules() would be a good start. |
Such an API would get accepted as part of our effort to make all UI features represented in our HTTP API. Contributions are gladly accepted. |
+1 |
@fabxc : i have some code written to expose endpoint /api/v1/alerts which puts out a json like so
Is there any other info that I can expose via the api? |
I don't understand, there already seems to be an API endpoint exposed from alert manager.
Where does that fit in this discussion? |
@moolitayer In a project name |
So there is an API for alerts in alert manager but not in Prometheus? |
@moolitayer Correct. |
Thanks @juliusv. I'm interested in collecting alerts from Prometheus and integrating them in an external system. Here is another related question; For effective collection I would like like to collect only new alerts using pull every X seconds. (possible solutions: using a time field OR using labels for collected alerts OR a streaming api similar to the kubernetes events endpoint) |
@moolitayer It doesn't make sense. From prometheus point of view it's collecting data every X time and evaluates rules every Y time. If you are scrapping alerts every Z seconds and it's more than Y then you expect that prometheus will keep historical alerts till your next check. Additionally how to handle restarts and your problems (like you lost updates about some resolve) So it's quite good that at one shot you can get a list of active alarms - you have a clear picture of a status |
@jsuchenia It seems alert manager already has that data and I'm wondering if there is a mechanism there to get what I need? If an alert has fired and was immediately resolved for example I would still like to know about it so only resolved alerts are not enough for my use case. |
@moolitayer According to Alert Manager configuration you can specify a webhook that will be triggered whenever an alert state was changed. Is this something that works for you? |
Thanks @jsuchenia. I have to initiate all the connections due to security concerns. Is that possible somehow? (kubernetes watch api is a good example of what I need) |
@brancz Did you implement this already? |
@brian-brazil I implemented the alertmanagers endpoint, not alerts. That's still tbd. However as suggested before I would recommend to implement a system as described above as a webhook that is called by the Alertmanager instead of scraping Prometheus alerts. Nonetheless there are usecases for the alerts API. |
In case this is of useful to someone, to collect alerts we web hooked alerts into another component (running on the same k8s pod as alert manager) and we are collecting from that component: |
I have a use case where I would like to see triggered and non-triggered alerts, the current alertmanager alerts API currently only exposes triggered alerts. Would you guys welcome a PR to add functionality to be able to glean all alerts? I don't need an API, just the information exposed... I would be happy with adding a label to the |
It's not possible to list non-firing alerts, as we don't know their labels. |
That's a good point... I really don't need an alerts api, but a rules api. I don't mind if it is read-only, just something better than html. In Prometheus 2.0 using |
Maybe a good extension for |
In case anyone comes in here looking for an firing alert dashboard in grafana, here's one: https://grafana.com/dashboards/4181 |
Hello, For anyone else looking at the answer, you can call |
See #4318 |
@amaury-d yes, but that only returns firing alerts. People here want inactive and pending alerts as well |
@ealexhaywood #4318 exposes pending alerts via @juliusv as the initial issue is about getting alerts in general, should we close here with #4318 being merged? |
@mxinden Yes, thank you! Closing. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I didn't find anything about API for the /alerts in docs. I can see that /alerts returns html:
But is it possible to get them with json?
The text was updated successfully, but these errors were encountered: