Grafana: Monitoring Alerts and State History
|
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 stores state history in Loki, and the LogQL query below returned the transitions of the 5xx rule.
To do this by hand, follow Silence, Schedule and Review Alerts.
Building alert rules is half of the job. The other half is being able to answer, after the fact and at three in the morning, four questions: which rules are firing right now, what did a rule do over the last hours, which notifications were really sent (and did they arrive), and is the alerting system itself healthy. Grafana answers them with a set of pages under Alerting and with metrics and logs that Grafana writes about itself. Most of these pages depend on a backend that a self-managed installation must configure first, which is the reason many installations show an empty History page and conclude that "nothing happened".
This page walks through the monitoring pages, shows how to switch on the storage behind them for the lab, and ends with meta-monitoring: alerting on the alerting system. The rule model behind the states is in Rule Evaluation, States and Missing Data, the architecture in Alerting Architecture, and the routing that produces notifications in Notification Policies. The running example is the Bookshelf service (see Metrics and Observability) with the five lab alerts defined in Provisioning Alerting Resources.
The monitoring pages at a glance
The Monitor alerts section of the documentation groups the tools that help to investigate alert issues and improve the reliability of the alerting setup. The pages below are all under Alerts & IRM > Alerting in the Grafana menu.
| Page | What it shows | What it needs |
|---|---|---|
Alerts (Alert activity) |
Counts of firing and pending alert rules and instances, grouped and filtered by labels over a time range. |
Grafana-managed rules only. Reads the |
Alert rules |
All alert and recording rules as folder, rule group and rule, with state and health. |
Folder read permission and |
Rule details (Query and conditions, Instances, History, Details) |
The query and expressions with intermediate values, every instance with its labels, the rule history and metadata. |
The History tab needs alert state history in Loki. |
Active notifications |
Alert groups that are currently being notified, per contact point. |
None beyond access to the notification resources. |
History (Alert events and Notifications tabs) |
Every state transition of every instance, and every notification sent. |
Alert state history (Loki) and, for the Notifications tab, notification history (Loki). |
Source: Grafana: Monitor alerts and its sub-pages Alerts overview page, View alert rules, View alert state.
The Alerts page
The Alerts page is the first place to look during an incident. It shows how many alert rules and alert instances are
firing or pending, lets you group them with the Group by field (one or more labels, for example severity or
team), narrow them with Filters (a label plus an expression for its value) and change the window with the time
picker. Because Bookshelf rules carry the labels team="bookshelf-sre" and severity, grouping by severity answers
"how bad is it" in one glance.
Two details trip people up. First, only Grafana-managed rules appear: rules that live in Prometheus, Mimir or Loki
rulers are not listed here. Second, the page does not read Grafana’s database. It queries the GRAFANA_ALERTS metric,
which on Grafana Cloud is written to the provisioned Mimir data source and which self-managed installations must set up
themselves (see the Prometheus backend below). Two permissions are required: alert.rules:read to read the rules in
their folders and datasources:query on the data source that stores the history. Without the second one the page
shows no alerts even for a user who can see every rule on the Alert rules page.
Source: Grafana: Alerts overview page. The page does not state a release status.
The alert rules list and rule details
The Alert rules page lists every recording and alert rule as folder, rule group and rule. The default Grouped view
keeps that hierarchy; the List view is a flat, unpaginated list. The search bar and the filter popup stay in sync and
accept key:value terms: datasource, namespace, label, group, rule, state, type and health, for example
label:severity=critical or health:error. The label filter supports =, !=, =~ and !~ with RE2 syntax,
anchored and case-sensitive unless the pattern starts with (?i), and it matches both rule labels and instance labels.
A search can be saved, renamed and set as the default.
Opening a rule shows four tabs: Query and conditions (the queries, the expressions and a graph of intermediate values
for range queries), Instances (one row per series with status, labels and metadata, searchable by label for
multi-dimensional rules), History and Details (metadata and annotations). The rule state is the worst state among
its instances, while health flags Error and NoData conditions of the rule itself. Time series panels linked to a
rule show a heart icon (red for Alerting, green for Normal) and coloured annotations at state changes, which is the
dashboard side of the same information (see
Annotations and Links).
Some maintenance actions live here as well. An administrator can pause or resume all evaluations of a folder, or delete
all of its rules. Each rule keeps a version history (View > Versions) where versions can be compared and restored,
with the number of versions kept set by rule_version_record_limit for OSS and Enterprise. Deleted rules are kept in
the Recently deleted tab for 30 days ([unified_alerting] deleted_rule_retention); only administrators can restore a
Grafana-managed rule and a restored rule gets a new UID.
Source: Grafana: View alert rules and Grafana: View alert state.
Active notifications
Active notifications shows the alert groups that Grafana is notifying about right now, each with its label set, its contact point and the number of alerts. It is mainly a debugging tool for notification policies: groups follow the default policy grouping, Custom group by lets you test another label combination, and alerts that miss the grouping labels land in a catch-all group headed "No grouping". Inside a group each instance has a notification state: Unprocessed (received, not yet handled), Suppressed (silenced) or Active (handled and still firing). The Alertmanager dropdown switches to an external Alertmanager, with the Grafana Alertmanager as the default.
The page shows what was grouped, not whether delivery worked. A failing contact point is flagged under Notification configuration > Contact points (a red error, with details on hover) for the Grafana Alertmanager, and past delivery attempts are in the notification history described below.
Source: Grafana: View active notifications.
Alert state history
State history is a record of every state change of every instance of a Grafana-managed rule. An event is written whether or not a silence or mute timing applies, so the history is complete even when nobody was notified. That completeness is exactly why it is the best evidence for questions such as "did the rule flap overnight", "how long was it pending" and "when did it go to No Data".
There are two places to read it. The History page (Alerts & IRM > Alerting > History) shows an Alert Events chart and an event list for all rules, filtered by label, by current or previous state and by time (zoom by dragging on the chart). Expanding a row shows the transition count, a state graph and the value at the transition. The per-rule view (Alert rules > a rule > Show state history) shows a timeline of the last hour and, per instance, the previous and current state, the value of each expression part and the unique labels, with the common labels at the top. If the chart covers more than 5,000 alerts data may be missing, so narrow the time range first. Users see history only for rules they are allowed to read.
Source: Grafana: View alert state history.
Configure the storage (OSS and Enterprise)
On Grafana Cloud the history is stored for you. On a self-managed Grafana the History page and the state history view work only after state history is configured, and the supported backend for them is Loki. The state history view can query up to 30 days of data, so the Loki query limits may need to be raised, and the documentation recommends a separate Loki instance for alert state history so that these settings do not affect the logs of the applications.
# Loki limits_config used by the state history view
limits_config:
split_queries_by_interval: '24h'
max_query_parallelism: 32
# grafana.ini
[unified_alerting.state_history]
enabled = true
backend = loki
loki_remote_url = http://localhost:3100
The same settings as environment variables of the Grafana container in the lab Compose file (the GF_<SECTION>_<KEY>
form, with dots in the section name written as underscores):
services:
grafana:
image: grafana/grafana-enterprise:13.3.0
environment:
GF_UNIFIED_ALERTING_STATE_HISTORY_ENABLED: "true"
GF_UNIFIED_ALERTING_STATE_HISTORY_BACKEND: loki
GF_UNIFIED_ALERTING_STATE_HISTORY_LOKI_REMOTE_URL: http://loki:3100
Add the Loki data source as well (the lab uses the uid loki, see
Data Sources). Reference:
Grafana: Configure alert state history
and Grafana: Configure a Grafana Docker image.
The Prometheus backend and several backends
State history can also be written to a Prometheus-compatible data source as the metric GRAFANA_ALERTS, modelled on the
Prometheus ALERTS metric. That is what the Alerts page and the Prometheus-style queries below read. The Prometheus
backend does not enable the History views, which need Loki. To get both, configure two backends: a primary and a list
of secondaries.
# Prometheus backend only: Prometheus needs --web.enable-remote-write-receiver
[unified_alerting.state_history]
enabled = true
backend = prometheus
prometheus_target_datasource_uid = prometheus
# prometheus_metric_name = GRAFANA_ALERTS
# prometheus_write_timeout = 10s
# Loki and Prometheus together
[unified_alerting.state_history]
enabled = true
backend = multiple
primary = loki
loki_remote_url = http://loki:3100
secondaries = prometheus
prometheus_target_datasource_uid = prometheus
The Prometheus data source must have its Prometheus type set correctly because Grafana uses it to find the remote
write endpoint. GRAFANA_ALERTS carries alertname, alertstate, grafana_alertstate, grafana_rule_uid and the
alert labels, and maps the Grafana states onto the Prometheus ones: Alerting, Recovering, Error and NoData all appear as
alertstate="firing" (with grafana_alertstate set to alerting, recovering, error or nodata), Pending as
pending, and Normal is not emitted.
Reference: Grafana: Configure alert state history and Grafana: Meta monitoring (the state table).
Query the history in Explore
With Loki as the backend, every state change is a log line in the stream {from="state-history"}, so it can be
queried in Explore like any log (see
Queries, Explore and Drilldown):
{from="state-history"} | json
{from="state-history"} | json | previous=~"Normal.*" | current=~"Alerting.*"
{from="state-history"} | json | current=~"Error.*"
Useful fields are previous, current, ruleTitle, ruleUID, ruleID, labels_alertname and
labels_grafana_folder. With the Prometheus backend the equivalent query is
GRAFANA_ALERTS{alertstate="firing"} against the Prometheus data source.
Source: Grafana: Meta monitoring (section "Logs: state history in Loki").
Notification history
State history says what the rules did; notification history says what Grafana sent. Each row is one notification to a contact point for a group of alerts, with the time, the status (Firing or Resolved), the group labels, the contact point and integration, and a Failed badge with the error on hover when delivery failed. Expanding a row lists the firing and resolved alerts it contained, and View opens the delivery outcome. Filters cover labels, status, delivery outcome, contact point and time range, and a rule’s own Notifications tab shows the notifications for that rule. Silenced alerts produce no notification, so they do not appear here (they do appear in state history).
On a self-managed Grafana it must be enabled, again with Loki:
[unified_alerting.notification_history]
enabled = true
loki_remote_url = http://loki:3100
# optional: loki_tenant_id, loki_basic_auth_username, loki_basic_auth_password
An optional [unified_alerting.notification_history.external_labels] section adds extra labels to every record. The
page states neither a release status nor a retention period; as with any Loki data, retention is whatever the Loki
instance is configured to keep.
Source: Grafana: View notification history.
Declaring an incident from an alert
For teams that run incident management in Grafana, a firing alert can become an incident without leaving Grafana: in Alert rules, filter by Firing, open More > Declare Incident (or do the same from the alert details page), confirm the title, which is prefilled with the rule name, pick a severity and optionally labels, and declare. The rule is linked to the incident automatically. The feature needs Grafana Incident and a firing alert; the page states no release status or version. How incidents, on-call and escalation fit around this is covered in SLOs and IRM and, tool-neutrally, in Notifications and Incident Response.
Meta-monitoring: alerting on the alerting system
An alert that never fires because the evaluator is stuck looks exactly like a healthy system. Meta-monitoring means
watching the alerting system with something that does not depend on it for its own signal. Grafana exposes predefined
metrics on its /metrics endpoint, state history and notification history in Loki, and Alertmanager metrics for
external Alertmanagers; they are not collected automatically, so a Prometheus-compatible server has to scrape them.
# prometheus.yml: scrape Grafana (and an external Alertmanager if one is used)
scrape_configs:
- job_name: grafana
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
follow_redirects: true
static_configs:
- targets:
- grafana:3000
- job_name: alertmanager
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- alertmanager:9093
Source: Grafana: Meta monitoring (running Prometheus in production is covered in Prometheus production operations).
The metrics the documentation lists for Grafana-managed alerting, and what to do with them:
| Metric | Use |
|---|---|
|
Alerts per state (normal, pending, alerting, nodata, error). Alert when the |
|
Number of scheduled rules; it should equal the number of non-paused rules. |
|
Time per scheduler tick. Ticks longer than 10 seconds make evaluations lag. |
|
How far the scheduler is behind; alert on sustained growth. |
|
Time to fetch the rules from the database. |
|
Time to send notifications; reveals slow integrations. |
|
Failed state history writes; alert when it increases for |
|
Evaluation count; |
For an external Alertmanager the documentation lists alertmanager_alerts, alertmanager_alerts_invalid_total (it
should stay at 0), alertmanager_notifications_total, alertmanager_notifications_failed_total and
alertmanager_notification_latency_seconds_bucket (each by integration), and the cluster metrics
alertmanager_cluster_members, alertmanager_cluster_failed_peers, alertmanager_cluster_health_score and
alertmanager_cluster_reconnections_failed_total. For rules managed by a Mimir ruler,
rule_evaluation_failures_total counts evaluation failures.
A practical minimum for Bookshelf is three rules in a folder that only meta-monitoring uses: errors
(grafana_alerting_alerts{state="error"} > 0), failing history writes
(grafana_alerting_state_history_writes_failed_total > 0) and a lagging scheduler. Because the evaluator that would
fire them is the thing being watched, route them to a different contact point than the application alerts and, where
possible, evaluate them from a second Grafana or from the Prometheus ruler (see
Recording and Alerting Rules).
Source: Grafana: Meta monitoring.
What can go wrong
| Symptom | Cause and fix |
|---|---|
The History page and the Show state history view are empty or show an error |
State history is not configured, or the backend is Prometheus. Set |
The Alerts page lists nothing although rules are firing |
|
The history chart looks incomplete |
More than 5,000 alerts in the window; narrow the time range. |
The Notifications tab is empty |
Notification history is not enabled ( |
History queries are slow or time out in Loki |
The state history view queries up to 30 days; raise |
A user sees fewer events than a colleague |
History and notification history are filtered by the rules the user may read (folder permissions). |
A notification looks missing |
Check Active notifications (is the group still waiting?), the contact point error badge, the notification history outcome and finally the silences and mute timings (see Silences, Mute Timings and Inhibition). |
Verify in the lab
With the lab profile grafana running (see Hands-on Lab) and the
Bookshelf alert rules provisioned:
-
Add the three
GF_UNIFIED_ALERTING_STATE_HISTORY_*variables above (and the notification history ones) to thegrafanaservice, recreate the container and check that Alerting > History opens without an error. -
Switch the load generator to its failing-request mode. The 5xx ratio rule goes Normal, Pending, Alerting; follow it in Alert rules > Bookshelf high 5xx ratio > Instances.
-
Open History and filter by
severity=critical: the transition rows show the value that crossed the threshold. In Explore, run{from="state-history"} | json | current=~"Alerting.*"against thelokidata source and compare the timestamps. -
Open Active notifications while the alert is firing: the group is listed under the
bookshelf-webhookcontact point. After the group wait elapses, the Notifications tab shows the webhook delivery, and the lab webhook receiver logs the same payload. -
Stop the load generator. The alert goes to Recovering or Normal and the History page shows the Resolved notification.
-
Add the Grafana scrape job to Prometheus and chart
grafana_alerting_alertsbystate; it should follow the counts on the Alerts page.
In the books
The alerting chapter of Learn Grafana 10.x (Salituro, Packt) covers rules, labels, notification policies, contact points and mute timings; Salituro was written for Grafana 10, before the Recovering state existed. None of the book extracts describe the History page, Loki-backed state history, notification history or the meta-monitoring metrics, which makes this page’s content new relative to those books.