Alerting rules

    Alerting rules allow you to define alert conditions based on Prometheus expression language expressions and to send notifications about firing alerts to an external service. Whenever the alert expression results in one or more vector elements at a given point in time, the alert counts as active for these elements’ label sets.

    Alerting rules are configured in Prometheus in the same way as .

    An example rules file with an alert would be:

    The labels clause allows specifying a set of additional labels to be attached to the alert. Any existing conflicting labels will be overwritten. The label values can be templated.

    The clause specifies a set of informational labels that can be used to store longer additional information such as alert descriptions or runbook links. The annotation values can be templated.

    Templating

    Label and annotation values can be templated using console templates. The $labels variable holds the label key/value pairs of an alert instance. The configured external labels can be accessed via the variable. The $value variable holds the evaluated value of an alert instance.

    To manually inspect which alerts are active (pending or firing), navigate to the “Alerts” tab of your Prometheus instance. This will show you the exact label sets for which each defined alert is currently active.

    For pending and firing alerts, Prometheus also stores synthetic time series of the form . The sample value is set to 1 as long as the alert is in the indicated active (pending or firing) state, and the series is marked stale when this is no longer the case.

    Prometheus’s alerting rules are good at figuring what is broken right now, but they are not a fully-fledged notification solution. Another layer is needed to add summarization, notification rate limiting, silencing and alert dependencies on top of the simple alert definitions. In Prometheus’s ecosystem, the takes on this role. Thus, Prometheus may be configured to periodically send information about alert states to an Alertmanager instance, which then takes care of dispatching the right notifications.
    Prometheus can be configured to automatically discover available Alertmanager instances through its service discovery integrations.