Alerting API for Prometheus and AlertManager
The Prometheus API allows you to manage the alerts functionality.
Alerts involve several steps conceptually:
- alert rule
s are configured within Prometheus
- Prometheus evaluates the alert rules and sends any triggered alert
s to AlertManager
- AlertManager processes any received alerts based on the defined route
s, receiver
s, silence
s, and inihibition rule
s.
Contents
Authentication
API requests are authenticated using basic auth. Please refer to your dashboard for the credentials.
Native APIs Provided by AlertManager
AlertManager has its own API built in. The documentation can be accessed at http://petstore.swagger.io/?url=https://raw.githubusercontent.com/prometheus/alertmanager/master/api/v2/openapi.yaml.
The root url path for this API is:
https://hostedmetrics.com/s/{identifier}/prometheus/alertmanager/api/v2/
It provides the following endpoints:
/status GET
/receivers GET
/silences GET
/ POST
/silence/{silenceID} GET
/ DELETE
/alerts GET
/ POST
/alerts/groups GET
Additional APIs Provided by HostedMetrics:
Alert Rules
Get
The current alert rules can be retrieved using a GET
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-rules/
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/promsrvr/rules
Put
Alert rules can be defined using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-rules/
Set the Content-Type
header to either application/json
or application/yaml
.
The request body must contain the JSON or YAML that defines the new configuration for the alert rules.
Alerts
Get
The status of any alerts defined by the alert rules can be retrieved in two ways:
GET
https://hostedmetrics.com/s/{identifier}/prometheus/promsrvr/api/v1/alerts
or
GET
https://hostedmetrics.com/s/{identifier}/prometheus/promsrvr/api/v1/rules
(nested data)
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/promsrvr/alerts
AlertManager Config
This API combines the APIs for global settings, routes, receivers, and inhibitions. It reflects the entire contents of what appears in the alertmanager.yml
file.
Get
The current AlertManager configuration can be retrieved with the following request:
GET
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-manager-configuration/
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/alertmanager/#/status
Put
The AlertManager configuration can be defined using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-manager-configuration/
Set the Content-Type
header to either application/json
or application/yaml
.
The request body must contain the JSON or YAML that defines the new AlertManager configuration.
HostedMetrics provides a default SMTP configuration if you do not specify your own. In order to specify your own, at a minimum, you must specify the smtp_smarthost
, smtp_auth_username
, smtp_auth_password
, and smtp_from
settings in the global
section.
Global Settings
Get
The current global settings can be retrieved with the following request:
GET
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-global-settings/
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/alertmanager/#/status
Put
The global settings can be defined using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-global-settings/
Set the Content-Type
header to either application/json
or application/yaml
.
The request body must contain the JSON or YAML that defines the new configuration for the global settings.
HostedMetrics provides a default SMTP configuration if you do not specify your own. In order to specify your own, at a minimum, you must specify the smtp_smarthost
, smtp_auth_username
, smtp_auth_password
, and smtp_from
settings.
Alert Routes
Get
The current alert routes can be retrieved with the following request:
GET
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-routes/
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/alertmanager/#/status
Put
Alert routes can be defined using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-routes/
Set the Content-Type
header to either application/json
or application/yaml
.
The request body must contain the JSON or YAML that defines the new configuration for the alert routes.
Alert Receivers
Get
The current alert receivers can be retrieved with the following request:
GET
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-receivers/
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/alertmanager/#/status
Put
Alert receivers can be defined using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-receivers/
Set the Content-Type
header to either application/json
or application/yaml
.
The request body must contain the JSON or YAML that defines the new configuration for the alert receivers.
Alert Inhibitions
Get
The current alert inhibitions can be retrieved with the following request:
GET
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-inhibitions/
The retrieved data is equivalent to the content on this webpage:
https://hostedmetrics.com/s/{identifier}/prometheus/alertmanager/#/status
Put
Alert inhibitions can be defined using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-inhibitions/
Set the Content-Type
header to either application/json
or application/yaml
.
The request body must contain the JSON or YAML that defines the new configuration for the alert inhibitions.
Alert Notification Templates
List
The list of alert notification templates can be retrieved using a GET
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-notification-templates/
Add
A new alert notification template file can be defined using a POST
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-notification-templates/
The request body must contain the contents of the alert notification template file that will be created.
The response will contain the id and path of the created file.
Alert Notification Template
Get
Alert notification templates can be retrieved using a GET
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-notification-templates/{file-id}/
Put
An alert notification template file can be created/replaced using a PUT
request to
https://hostedmetrics.com/s/{identifier}/prometheus/api/v1/alert-notification-template/{file-id}/
The request body must contain the contents of the alert notification template file that will be created.
The response will contain the id and path of the created/replaced file.