Sending alerts

Disclaimer: Prometheus automatically takes care of sending alertsgenerated by its configured alertingrules. It is highlyrecommended to configure alerting rules in Prometheus based on time series datarather than implementing a direct client.

The Alertmanager has two APIs, v1 and v2, both listening for alerts. The schemefor v1 is described in the code snipped below. The scheme for v2 is specified asan OpenAPI specification that can be found in the Alertmanagerrepository.Clients are expected to continuously re-send alerts as long as they are stillactive (usually on the order of 30 seconds to 3 minutes). Clients can push alist of alerts to Alertmanager via a POST request.

The labels of each alert are used to identify identical instances of an alertand to perform deduplication. The annotations are always set to those receivedmost recently and are not identifying an alert.

Both startsAt and endsAt timestamp are optional. If startsAt is omitted,the current time is assigned by the Alertmanager. endsAt is only set if theend time of an alert is known. Otherwise it will be set to a configurabletimeout period from the time since the alert was last received.

The generatorURL field is a unique back-link which identifies the causingentity of this alert in the client.

  1. [
  2. {
  3. "labels": {
  4. "alertname": "<requiredAlertName>",
  5. "<labelname>": "<labelvalue>",
  6. ...
  7. },
  8. "annotations": {
  9. "<labelname>": "<labelvalue>",
  10. },
  11. "startsAt": "<rfc3339>",
  12. "endsAt": "<rfc3339>",
  13. "generatorURL": "<generator_url>"
  14. },
  15. ...
  16. ]