Skip to main content
Alert rules define the conditions that trigger alerts in Grafana. They combine data queries with expressions to evaluate alert conditions.

Rule Structure

An alert rule consists of several key components:

Query and Expression Model

Alert rules use a query + expression model:
  1. Data Source Queries: Fetch data from data sources (Prometheus, Loki, etc.)
  2. Expressions: Transform and evaluate query results
  3. Condition: The expression that determines alert state

State Handling

Pending Duration (for)

The for duration specifies how long a condition must be true before the alert fires:

Keep Firing For (keepFiringFor)

Keeps the alert in a firing state even after the condition resolves:

NoData State

Controls behavior when queries return no data:

Execution Error State

Controls behavior when query execution fails:

Labels and Annotations

Labels

Labels are used for:
  • Routing alerts to contact points
  • Grouping related alerts
  • Filtering and searching
Reserved Labels - These labels are automatically managed:
  • grafana_folder: Folder title
  • __grafana_receiver__: Auto-routing receiver
  • __grafana_route_settings_hash__: Notification settings identifier

Annotations

Annotations provide additional context:

Rule Groups

Rules are organized into groups that share an evaluation interval:

Recording Rules

Recording rules pre-compute expensive queries and store results:
Recording rules ignore alerting-specific fields:
  • noDataState
  • execErrState
  • condition
  • for
  • keepFiringFor
  • notificationSettings

Notification Settings

Rules can define inline notification routing:

Rule Validation

Rules must pass validation before being saved:
1

UID Validation

Rule UID must be valid (alphanumeric, hyphens, underscores)
2

Query Validation

At least one query or expression must be defined
3

Interval Validation

Interval must be divisible by base interval (default 10s)
4

State Validation

NoData and ExecErr states must be valid enum values
5

Namespace Validation

Folder must exist and not be managed by Git Sync
6

Label Validation

Reserved labels cannot be manually set

Backend API Endpoints

Common Patterns

Dashboard Panel Alerts

Link an alert to a dashboard panel:

Multi-Condition Alerts

Combine multiple conditions:

Overview

Understand the alerting architecture

Contact Points

Configure notification destinations

Notification Policies

Route alerts to contact points

Silences

Temporarily mute notifications