Grafana Rule Evaluation, States and Missing Data
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Checked on 2026-11-09 against Grafana 13.3.x. Tested with Grafana Enterprise 13.3.0 in the hands-on lab: the lab’s no-data rule went from pending to firing three minutes after the Bookshelf container was stopped and resolved after it was started again, and a rule with a keep-firing period showed the Recovering state; the HCL passes terraform validate with provider 4.54.0.
To do this by hand, follow Create an Alert Rule.
A rule that never fires and a rule that fires at the wrong moment look the same from outside: nothing arrives. The difference is in evaluation: how often the rule runs, how long a breach has to last before it counts, which state each series is in, and what Grafana decides when the query returns nothing or fails. Those choices turn a correct query into a useful alert or into one that is silent during the outage it exists for.
This page covers the evaluation half of Grafana Alerting. The generic lifecycle (what a pending period is, why recovery needs hysteresis) is in Alerting Fundamentals, and the advice on missing data (what a silent query should mean) is in Designing Actionable Alerts; both are summarised only where the Grafana behaviour needs it. The rule itself (queries, expressions, condition) is in Alert Rules: Queries and Conditions, the surrounding architecture in Alerting Architecture, and how to watch states over time in Monitoring Alerts and State History. The Prometheus-centred comparison of rule evaluation is in Grafana alerting (Prometheus section). The running example is the Bookshelf service (see Metrics and Observability).
Evaluation groups and the interval
Three settings decide when a rule fires: the evaluation group (how often the rule is checked), the pending period (how long the condition must hold) and keep firing for (how long the alert keeps firing after the condition clears). Every alert rule and every recording rule belongs to an evaluation group, and the group’s interval sets how often all of its rules are evaluated; the documentation gives 10 seconds, 30 seconds, 1 minute and 10 minutes as examples. In the rule form you select an existing group or create one and set its interval.
Source: Grafana: Alert rule evaluation.
The interval is a cost and a latency budget at once. Each evaluation runs the rule’s queries against the data source, so a
1-second interval on an expensive query multiplies load; and the earliest notification after a breach starts is the pending
period plus up to one interval. The lab uses a 1 minute group interval for the Bookshelf rules, which matches the scrape
and rate windows of five minutes and keeps the load on the prometheus and loki data sources small.
The instance-wide floor is the [unified_alerting] setting min_interval (default 10s, equal to the scheduler interval):
a rule interval shorter than it, or not a multiple of it, is adjusted, and the setting takes precedence over lower rule
frequencies.
Source: Grafana: Configure Grafana ([unified_alerting]).
Concurrent and sequential evaluation
Rules in different groups run at the same time. Inside one group the order depends on the kind of rule:
-
Grafana-managed rules in a group run concurrently: they start at different moments in the interval but share the same evaluation timestamp.
-
Data source-managed rules in a group run sequentially, one after another, which guarantees that a recording rule has finished before the alert rule that depends on it.
-
Grafana-managed rules imported from data source-managed rules run as an evaluation sequence in their original group order; each starts after the previous one finishes.
The consequence for Grafana-managed rules: do not rely on group order for dependencies. A rule that queries the metric written by a recording rule in the same group may read the previous value. For that case Grafana has rule sequences.
Rule sequences
A rule sequence lets a Grafana-managed recording rule or alert rule depend on the result of a recording rule. It references existing rules and defines the evaluation order and a shared interval; the page says it "defines evaluation order, not a general-purpose organizational group". The facts that matter:
-
Requires Grafana Cloud, or Open Source or Enterprise 13.1 or later. The page does not label it preview or generally available, and the API version is
v0alpha1, which the page says is subject to change: treat it as an unstable API. -
All rules and the sequence must be in the same folder, there must be at least one recording rule (alert rules are optional), a rule can be in only one sequence, and the interval must be an integer multiple of the base evaluation interval (with a base of
10s,10s,30sand1mare valid and15sis not). -
Each interval runs in two stages: the recording rules in the order of
spec.recordingRules, then the alert rules in the order ofspec.alertingRules. The sequence interval overrides the member rules' own intervals. -
Order, not consistency: Grafana waits for the recording rule’s write request to finish but does not confirm the samples can be queried before the next rule runs. If a recording rule fails or returns nothing, Grafana still moves on, and the dependent rule may read older data or none, so give it explicit No Data and Error handling.
-
It is created through the API (
POSTto/apis/rules.alerting.grafana.app/v0alpha1/namespaces/{namespace}/rulesequences) or with the Terraform resourcegrafana_apps_rules_rulesequence_v0alpha1. In Open Source and Enterprise the feature togglejitterAlertRulesWithinGroupsmust stay disabled, because it turns off sequential evaluation.
Source: Grafana: Rule sequences. The recording rules themselves are in Recording Rules.
Pending period and keep firing for
The pending period is how long a breach has to hold before the alert fires. While it runs, the instance is Pending; if the condition clears first, the instance goes back to Normal. When it elapses, the instance moves to the state matching the last evaluation. A pending period of 0 skips Pending. It exists to keep a brief spike from notifying anyone.
Keep firing for is the mirror image: the minimum time an alert stays firing after the breach has stopped. During that time the instance is Recovering, and if the breach returns the instance goes back to Alerting without a new notification. A keep firing for of 0 skips Recovering. It exists to stop a firing, resolved, firing sequence from a series that hovers around the threshold. The value-based alternative, a recovery threshold, is in Alert Rules: Queries and Conditions.
Grafana’s worked example uses a 30 second interval, a 90 second pending period and a keep firing for of 0:
| Time | Condition | State | Pending counter |
|---|---|---|---|
00:30 |
Not met |
Normal |
none |
01:00 |
Breached |
Pending |
0 s |
01:30 |
Breached |
Pending |
30 s |
02:00 |
Breached |
Pending |
60 s |
02:30 |
Breached |
Alerting, notification sent |
90 s |
03:00 |
Not met |
Normal, Resolved, notification sent |
120 s |
03:30 |
Not met |
Normal |
150 s |
Source: Grafana: Alert rule evaluation ("Pending period", "Keep firing for").
The practical lesson of the table is that pending is counted in evaluations, not in wall-clock promises: with a 1 minute interval and a 2 minute pending period (the lab’s 5xx rule) the first notification arrives between two and three minutes after the breach begins, plus the notification policy’s group wait. Budget accordingly against the response time you promised.
The six states
Every instance of a rule has a state. Grafana documents six:
| State | Meaning |
|---|---|
Normal |
No alerting condition (threshold breach, no data or error) is met. It is also the state after a No Data or Error option set to Normal, after a rule is deleted, paused or updated, and after a stale instance whose series disappeared. |
Pending |
A condition is met, but the pending period has not elapsed. |
Alerting |
The threshold is breached and the pending period has elapsed. |
Recovering |
A firing alert no longer breaches the threshold, but keep firing for has not elapsed. |
No Data |
The query returns no data (or only nulls) after the pending period. Behaviour is customisable. |
Error |
An error or a timeout occurs after the pending period. Behaviour is customisable. |
No Data and Error apply only to Grafana-managed rules. Notifications are sent when an instance enters Alerting and when it returns to Normal and is marked Resolved (from Alerting or Recovering); an instance that is merely Pending or Recovering does not notify. If a rule is edited (other than its annotations, evaluation interval or other internal fields), its instances reset to Normal and update on the next evaluation. The diagram shows the transitions:
The arrows into and out of No Data and Error are a simplification: with the default options the state is reached through Pending when the pending period is longer than 0, and the handling options below decide whether the instance goes to No Data, Error, Alerting or Normal at all. The diagram is a reading aid assembled from the state tables of the evaluation and No Data and Error pages.
Source: Grafana: Alert rule evaluation ("Alert instance states", "Transitions") and Grafana: State and health of alerting rules.
The rule list also shows the health of a rule and can filter on it (for example health:error shows the rules whose
evaluation is failing).
Source: Grafana: View alert rules.
No Data and Error handling
The query can fail in two different ways, and they are different problems.
-
Error: the rule cannot evaluate its queries. It happens when the evaluation exceeds the timeout (
evaluation_timeout, default30s) or the data source fails repeatedly (max_attempts, default3). -
No Data: the query runs successfully and returns no data points at all.
Both are configured under Configure no data and error handling in the rule. For each there are four options, and the behaviour depends on whether the pending period is 0:
| Option | Pending period 0 | Pending period above 0 |
|---|---|---|
Set No Data state / Set Error state (default) |
Immediately No Data or Error |
Pending, then No Data or Error if the last evaluation still has the problem |
Set Alerting state |
Immediately Alerting |
Pending, then Alerting |
Set Normal state |
Immediately Normal |
Immediately Normal |
Keep last state |
Keeps the current state |
Keeps the current state |
With the defaults, Grafana creates a separate alert instance with alertname set to DatasourceNoData or DatasourceError
and the labels datasource_uid (the data source that caused it) and rulename (the rule). Those instances are independent of
the original one: silences, mute timings and notification policies that matched the original may not match them, so they need
their own routing. If the rule sends directly to a contact point, they go there too. When the option is Alerting or Normal,
Grafana reuses the latest known Values and puts -1 in place of the measured value.
Keep last state prevents firing, resolving and re-firing during a short data source problem, and is not suitable for critical
monitoring; there, add a rule that catches a prolonged outage. To reduce the noise of these alerts, the page suggests Keep last
state, widening the time range for No Data (and narrowing it when timeouts cause Error), a longer pending period, and a
notification policy that matches alertname=DatasourceError and groups by datasource_uid. Changing evaluation_timeout or
max_attempts is a last resort because it affects every rule.
The grafana_state_reason annotation explains states that are not obvious: No Data or Error when the handling moved the
instance to Normal, Paused, RuleDeleted, Updated, and MissingSeries for stale instances.
Source: Grafana: No Data and Error states.
Missing series and stale instances
A third case sits between a healthy result and No Data: the query still returns data, but a series that used to be there is
gone, for example a pod that was replaced or a route that stopped receiving traffic. Grafana calls the instance stale. It keeps
the last state for a number of evaluation intervals (the Missing series evaluations to resolve setting in the no data and
error options; two intervals when unset), and if the series is still missing it moves the instance to Normal with the reason
MissingSeries, marks it Resolved (sending a resolved notification if it was Alerting, No Data or Error) and removes it from the UI.
The state history shows it as "Normal (Missing Series)" before it disappears. This applies only to Grafana-managed rules.
Eviction prevents flapping when instances come and go, but a resolved notification with MissingSeries is a disappearance, not a
recovery. Show the annotation in the notification so responders can tell the difference, route those notifications
separately, and silence them during planned rollouts.
Detecting disappearance in the query
The guide’s PromQL idioms complement the options above. They run in a Prometheus-compatible data source and keep the labels that Grafana’s No Data state does not:
# All series disappeared (the result has no labels)
absent_over_time(http_server_requests_seconds_count{application="bookshelf"}[5m]) == 1
# Series seen in the last 24 hours but not in the last 10 minutes, per instance
group(present_over_time(http_server_requests_seconds_count{application="bookshelf"}[24h])) by (instance)
unless
group(present_over_time(http_server_requests_seconds_count{application="bookshelf"}[10m])) by (instance)
# Return 0 instead of no data when an empty result is a normal value
sum(rate(http_server_requests_seconds_count{application="bookshelf",status=~"5.."}[5m])) or on() vector(0)
# Tolerate a late sample: take the latest value in the window
last_over_time(http_server_requests_seconds_count{application="bookshelf"}[10m])
Reference: Grafana: Handle missing data (PromQL idioms; the guide uses a
generic http_request_latency_seconds metric, replaced here by the Bookshelf metric). For scrape delay the guide also suggests
shifting the rule’s To time to now-1m.
Connectivity errors
The Error state is only half of "can’t reach the target". The connectivity guide separates two situations. Availability problems
(the target is down or unreachable) are detected with metrics such as Prometheus up or the Blackbox Exporter’s probe_success.
Execution errors (the rule’s query fails because the data source timed out, the network dropped or the query is invalid) are
handled by the Error options of the rule, including for Prometheus-backed rules.
The guide warns against up == 0 with a pending period as the only check: a single successful scrape resets the pending timer, and
an outage that comes and goes may never fire. Its fix is to smooth the signal, for example avg_over_time(up[10m]) < 0.8, which
fires when the target is unreachable for more than 20% of the window and allows a short pending period. For the data source
itself it recommends one dedicated rule, with a small cheap query that returns data when the source is healthy, with the error
option set to Alerting and a pending period such as 5m; the application rules use Normal or Keep last state so that one
failure does not produce many DatasourceError alerts, and DatasourceError alerts are grouped by datasource_uid.
Source: Grafana: Handle connectivity errors.
Settings that bound evaluation
Evaluation is bounded by a few [unified_alerting] settings. They are instance-wide, so a change affects every rule.
| Setting | Default | Effect |
|---|---|---|
|
|
The minimum rule interval, equal to the scheduler interval. Shorter or non-multiple intervals are adjusted. |
|
|
Timeout for an evaluation when fetching data from the data source. A timeout produces the Error state. |
|
|
How many times a rule evaluation is retried before giving up. Retries use jitter and stop at the attempt limit or at the rule’s evaluation interval. |
|
|
Retry timing (the factor must be between 0 and 1). |
|
|
When |
[unified_alerting]
min_interval = 10s
evaluation_timeout = 30s
max_attempts = 3
Reference: Grafana: Configure Grafana ([unified_alerting]). In
the lab, set the same keys as environment variables such as GF_UNIFIED_ALERTING_EVALUATION_TIMEOUT, as described in
Installation and Configuration. On Grafana Cloud
the evaluation settings are changed by a support ticket.
As code
The evaluation settings of a rule are plain fields of the rule in every provisioning format. In file provisioning a rule has
for, noDataState (NoData, Alerting, OK; default NoData) and execErrState (Error, Alerting, OK; default
Alerting), and the group has interval; the complete Bookshelf file is in
Provisioning Alerting Resources. The
Terraform rule block of grafana_rule_group adds keep_firing_for, missing_series_evals_to_resolve and is_paused, and
its no_data_state and exec_err_state accept KeepLast as well:
variable "folder_uid" {
type = string
description = "uid of the folder bookshelf (generated when the lab's rule file creates it)"
}
resource "grafana_rule_group" "bookshelf_no_data" {
name = "bookshelf-availability"
folder_uid = var.folder_uid
interval_seconds = 60
rule {
name = "Bookshelf metrics missing"
condition = "B"
for = "5m"
keep_firing_for = "2m"
no_data_state = "Alerting"
exec_err_state = "KeepLast"
missing_series_evals_to_resolve = 2
labels = {
application = "bookshelf"
team = "bookshelf-sre"
severity = "critical"
}
data {
ref_id = "A"
datasource_uid = "prometheus"
relative_time_range {
from = 600
to = 0
}
model = jsonencode({
refId = "A"
expr = "sum(rate(http_server_requests_seconds_count{application=\"bookshelf\"}[5m]))"
instant = false
range = true
intervalMs = 1000
maxDataPoints = 43200
})
}
data {
ref_id = "B"
datasource_uid = "__expr__"
relative_time_range {
from = 0
to = 0
}
model = jsonencode({
refId = "B"
type = "threshold"
expression = "A"
conditions = [{ evaluator = { type = "lt", params = [0.0001] } }]
})
}
}
}
Reference: Terraform: grafana_rule_group.
This is the "no data" idea of the lab in its simplest form: the rule alerts when the request rate is below a tiny number, with
no_data_state = "Alerting" so that a query that returns nothing counts as an outage too, and exec_err_state = "KeepLast"
so that a short Prometheus hiccup does not page anybody while a separate data source health rule watches the data source.
Pair it with a rule on up, as described in
Designing Actionable Alerts.
What can go wrong
-
Silence during the outage. A rule left on the default No Data state creates
DatasourceNoDataalerts that no policy of yours matches; they land in the default policy or are lost. Routealertname=DatasourceNoDataandDatasourceError. -
Set Normal state hides outages. It moves instances to Normal immediately, pending period or not.
-
Keep last state masks a long failure. It is for brief hiccups.
-
MissingSeries read as recovery. A resolved notification caused by eviction looks like a fix; check
grafana_state_reason. -
Pending period longer than the data lives. If a series disappears before the pending period ends it never fires.
-
Dependencies assumed from group order. Grafana-managed rules in a group run concurrently; use a rule sequence.
-
Editing resets states. Changing a rule’s query or condition resets its instances to Normal on the next evaluation, so an active alert can resolve and fire again.
-
Interval below the floor. A rule interval shorter than
min_intervalis adjusted, which is a surprise only if nobody read the setting.
Verify it in the lab
In the lab (Hands-on Lab, profile grafana), with the rules from
Alert Rules: Queries and Conditions:
-
Start the load generator in failing-request mode and watch the 5xx rule in Alerting > Alert rules: Normal, Pending (with the countdown), then Alerting after the 2 minute pending period. Note the time of the notification at the webhook receiver against the time of the breach.
-
Add Keep firing for of 5 minutes, stop the failures and confirm the instance shows Recovering, and that no resolved notification is sent until it elapses.
-
Run the p95 rule with traffic on two routes, then stop traffic to one of them. After the window empties and two evaluation intervals pass, the instance of the quiet route becomes Normal with
grafana_state_reasonset toMissingSeries, and a resolved notification is sent if it was firing. -
Stop Bookshelf entirely and wait for the five minute window to empty: the rule with the default option creates a
DatasourceNoDataalert, which the webhook receiver shows withalertname,datasource_uidandrulename. Switch the rule to Set Alerting state and compare. -
Stop the
prometheuscontainer: the rules report Error and aDatasourceErroralert appears. Restart it. -
Set
GF_UNIFIED_ALERTING_EVALUATION_TIMEOUTto a very low value in the lab compose file, restart Grafana and observe the Error state on a heavy query; restore the default.
In the books
Salituro (Learn Grafana 10.x) sets the evaluation group, the interval and the pending period and shows the No Data options on an
NGINX rule; McCollam (Getting Started with Grafana) explains pending as "about to fire" in the Grafana 8 alerting and warns not to
evaluate every second; Hernandez (Building IoT Visualizations using Grafana) lists the No Data and Error options and notes that
mute timings and silences do not stop evaluation. The ideas hold. What is newer than the books: the Recovering state and keep
firing for, the Keep last state option, DatasourceNoData and DatasourceError labelled with datasource_uid and rulename,
stale instance handling with MissingSeries, concurrent evaluation of Grafana-managed rules in a group (the book describes
sequential evaluation) and rule sequences.