The Wayback Machine - https://web.archive.org/web/20201215093333/https://github.com/prometheus/alertmanager/issues/2228
Skip to content
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

Incomplete AlertManager API Documentation #2228

Open
stevebail opened this issue Apr 7, 2020 · 4 comments
Open

Incomplete AlertManager API Documentation #2228

stevebail opened this issue Apr 7, 2020 · 4 comments

Comments

@stevebail
Copy link

@stevebail stevebail commented Apr 7, 2020

@mxinden
Either I don't know what I am doing or the Alert Manager API is not working as expected.
Your assistance is greatly appreciated.

I am trying to get a list of active alerts using a filter and it does not work as expected.
In all cases, I receive the complete list of active alarms.
Example 1:
curl -X GET http://10.44.0.3:9093/api/v2/alerts
Here I get the full list of active alerts.
So far so good!

Example 2:
curl -X GET http://10.44.0.3:9093/api/v2/alerts?name=my_receiver
Here I still get the full list of active alerts.

Example 2:
curl -X GET http://10.44.0.3:9093/api/v2/alerts?alertname=my_alert.*
Here I still get the full list of active alerts.

Unfortunately the AlertManager API documentation is poor vs Prometheus Server API documentation.
See link below:
https://prometheus.io/docs/alerting/management_api/

Below is the Alert Manager OPEN API spec but I don't know how to use it:
https://github.com/prometheus/alertmanager/blob/master/api/v2/openapi.yaml

/alerts:
get:
tags:
- alert
operationId: getAlerts
description: Get a list of alerts
parameters:
- in: query
name: active
type: boolean
description: Show active alerts
default: true
- in: query
name: silenced
type: boolean
description: Show silenced alerts
default: true
- in: query
name: inhibited
type: boolean
description: Show inhibited alerts
default: true
- in: query
name: unprocessed
type: boolean
description: Show unprocessed alerts
default: true
- name: filter
in: query
description: A list of matchers to filter alerts by
required: false
type: array
collectionFormat: multi
items:
type: string
- name: receiver
in: query
description: A regex matching receivers to filter alerts by
required: false
type: string

Can you provide examples showing how to construct alert queries with filters?

@mxinden
Copy link
Contributor

@mxinden mxinden commented Apr 9, 2020

Unfortunately the AlertManager API documentation is poor vs Prometheus Server API documentation. See link below: https://prometheus.io/docs/alerting/management_api/

This only documents the API documentation. Given that you stumbled over it, it might make sense to add a note in there. (PRs are welcome.)

Can you provide examples showing how to construct alert queries with filters?

On the projects readme there is an API section which should give some more insights.

The easiest way to construct your curl commands is probably the interactive swagger ui.

Let me know if this helps. Again, as this is an open source project it heavily depends on contributions, especially in the form of documentation. Thus if you find anything that would have helped you, please file a pull request.

@simonpasquier
Copy link
Member

@simonpasquier simonpasquier commented Apr 10, 2020

I agree with @mxinden: it would be good to mention the API specification in the official documentation.

@stevebail
Copy link
Author

@stevebail stevebail commented Apr 16, 2020

@mxinden
Thank you very much for the tip.
Both swagger and amtool work for me.
The only question left is to know the syntax for querying alerts based on the receiver name using amtool.
It works with swagger but it does not work with amtool.

This is what I am using so far:
amtool alert query receiver="receiver-name" --alertmanager.url "url"

The response is an empty list.
Help please :)

@mxinden
Copy link
Contributor

@mxinden mxinden commented Apr 17, 2020

I don't have much experience with amtool. In addition as this would be a usage question the mailing list is the best place to ask https://groups.google.com/forum/#!forum/prometheus-users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.