docs/sources/alerting/fundamentals/alert-rule-evaluation/_index.md
The criteria determining when an alert rule fires are based on three settings:
Evaluation group: how frequently the alert rule is evaluated.
Pending period: how long the condition must be met to start firing.
Keep firing for: how long the alert continues to fire after the condition is no longer met.
{{< figure src="/media/docs/alerting/alert-rule-evaluation-2.png" max-width="750px" alt="Set the evaluation behavior of the alert rule in Grafana." caption="Set alert rule evaluation" >}}
These settings affect how alert instances progress through their lifecycle.
Each alert rule can generate one or more alert instances.
An alert instance can be in any of the following states, depending on the outcome of the alert rule evaluation:
| State | Description |
|---|---|
| Normal | The state of an alert when no alerting conditions (threshold breach, no data, or error) are met. |
| Pending | The state of an alert when a condition (threshold breach, no data, or error) has been met, but the pending period has not yet elapsed. |
| Alerting | The state of an alert when the threshold has been breached after the pending period has elapsed. |
| Recovering | The state of a firing alert when the threshold is no longer breached, but the keep firing for period has not yet elapsed. |
| No Data<sup>*</sup> | The state of an alert when the query returns no data or all values are null after the pending period has elapsed. You can customize the behavior of the No Data state, which by default triggers a different alert. |
| Error<sup>*</sup> | The state of an alert when an error or timeout occurs while evaluating the alert rule after the pending period has elapsed. You can customize the behavior of the Error state, which by default triggers a different alert. |
{{< figure src="/media/docs/alerting/alert-rule-evaluation-full-statediagram_v3.svg" caption="The lifecycle diagram of alert instances" alt="A diagram of the distinct alert instance states and transitions." max-width="750px" >}}
If an alert rule changes (except for updates to annotations, the evaluation interval, or other internal fields), its alert instances reset to the Normal state, and update accordingly during the next evaluation.
{{< admonition type="note" >}}
The No Data and Error states are supported only for Grafana-managed alert rules. Refer to No Data and Error states to customize their default behavior for triggering a dedicated alert.
{{< /admonition >}}
Alert instances are routed for notifications in two scenarios:
Resolved, either from the Alerting or Recovering state.{{< shared id="evaluation-group-basics" >}}
Every alert rule and recording rule is assigned to an evaluation group. Each evaluation group contains an evaluation interval that determines how frequently the rule is checked. For instance, the evaluation may occur every 10s, 30s, 1m, 10m, etc.
{{< /shared >}}
Rules can be evaluated concurrently or sequentially. For details, see How rules are evaluated within a group.
{{< shared id="pending-period-basics" >}}
You can set a Pending period to prevent unnecessary notifications caused by temporary issues.
When an alerting condition is met, the alert instance enters the Pending state. It remains in this state while any alerting condition is met during the configured pending period. After the pending period has elapsed, the alert transitions to the state corresponding to the last evaluation.
This ensures the condition breach is stable before the alert transitions to the Alerting state and routed for notification.
{{< /shared >}}
You can also set the Pending period to zero to skip the Pending state entirely and transition immediately to the Alerting, No Data, or Error state.
{{< shared id="keep-firing-for" >}}
You can set a Keep firing for period to avoid repeated firing-resolving-firing notifications caused by flapping conditions.
When the alert condition is no longer met during the Alerting state, the alert instance enters the Recovering state.
{{< /shared >}}
You can also set the Keep firing for period to zero to skip the Recovering state entirely.
Keep in mind:
Consider an alert rule with an evaluation interval set at every 30 seconds and a pending period of 90 seconds. The evaluation occurs as follows:
| Time | Condition | Alert instance state | Pending counter |
|---|---|---|---|
| 00:30 (first evaluation) | Not met | Normal | - |
| 01:00 (second evaluation) | Breached | Pending | 0s |
| 01:30 (third evaluation) | Breached | Pending | 30s |
| 02:00 (fourth evaluation) | Breached | Pending | 60s |
| 02:30 (fifth evaluation) | Breached | Alerting 📩 | 90s |
With a keep firing for period of 0 seconds, the alert instance transitions immediately from Alerting to Normal, and marked as Resolved:
| Time | Condition | Alert instance state | Pending counter |
|---|---|---|---|
| 03:00 (sixth evaluation) | Not met | Normal <sup>Resolved</sup> 📩 | 120s |
| 03:30 (seventh evaluation) | Not met | Normal | 150s |
{{< figure src="/media/docs/alerting/alert-evaluation2.svg" alt="A diagram of alert state transitions of an alert example." max-width="750px" >}}