This is the companion page to my Grafana alerting video. We start from an empty Grafana 13 and end with a real email: [FIRING:1] High CPU usage, about a minute after a server's CPU goes over 80%. Then a RESOLVED email when it calms down. Every value below is the one I used on camera.
You will build a contact point, an alert rule and a real test. At the end you will set the timings that decide how often Grafana emails you, so alerts don't turn into spam.
Grafana alerting has three parts:
Every alert moves through these states:
| State | What it means |
|---|---|
| Normal | The condition is false. Nothing to do. |
| Pending | The condition is true, but not for long enough yet. |
| Firing | The condition stayed true for the whole pending period. Notifications go out. |
| Resolved | Things are fine again. You get a second email saying so. |
My setup: Grafana 13.3 (OSS) in Docker, Prometheus 3.7, and a Linux server called web-01 (Ubuntu 24.04) running node_exporter. Email goes to Mailpit, a test inbox, so you can see every message without touching a real mailbox. Any data source that supports alerting works the same way.
If you want the same lab, here is the compose.yaml:
services:
grafana:
image: grafana/grafana:13.3.2
ports: ["3000:3000"]
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
GF_SMTP_ENABLED: "true"
GF_SMTP_HOST: mailpit:1025
GF_SMTP_FROM_ADDRESS: [email protected]
GF_SMTP_FROM_NAME: Grafana
GF_SERVER_ROOT_URL: http://localhost:3000
volumes:
- ./provisioning:/etc/grafana/provisioning
prometheus:
image: prom/prometheus:v3.7.3
command: ["--config.file=/etc/prometheus/prometheus.yml", "--web.enable-lifecycle"]
ports: ["9090:9090"]
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
mailpit:
image: axllent/mailpit:v1.34
ports: ["8025:8025"]
prometheus.yml scrapes node_exporter on the server. Replace
SERVER with your server's IP address. The instance: web-01
label gives the server a readable name in alerts.
global:
scrape_interval: 15s
scrape_configs:
- job_name: node
static_configs:
- targets: ["SERVER:9100"]
labels: { instance: web-01 }
And provisioning/datasources/prometheus.yaml adds Prometheus to Grafana
as the default data source:
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
jsonData: { timeInterval: 15s }On the server itself, install node_exporter and stress-ng (we use it later to load the CPU):
sudo apt install -y prometheus-node-exporter stress-ng
Start the stack with docker compose up -d. Grafana is on
http://localhost:3000 and the Mailpit inbox is on
http://localhost:8025. In Grafana, open Explore and
you should see web-01's CPU.
Lab password. admin / admin is fine on a
laptop. Change it for anything that faces a network you don't control.
Grafana can only send email when it knows an SMTP server. Without it, an email
contact point saves fine and then never delivers. On a normal install, that is the
[smtp] section in grafana.ini:
[smtp]
enabled = true
host = smtp.example.com:587
user = ...
password = ...
from_address = [email protected]
In Docker, use the same settings as environment variables. Every
grafana.ini option becomes GF_<SECTION>_<KEY>:
GF_SMTP_ENABLED=true
GF_SMTP_HOST=smtp.example.com:587
GF_SMTP_USER=...
GF_SMTP_PASSWORD=...
[email protected]
In my lab, Grafana sends to Mailpit (axllent/mailpit) instead, with
GF_SMTP_HOST=mailpit:1025. Mailpit accepts everything on port 1025 and
shows it in its web inbox. It needs no user or password. Restart Grafana after you
change SMTP settings.
Tip: set the root URL. Grafana's emails contain links to open the
rule or silence it. They are built from GF_SERVER_ROOT_URL
(root_url in grafana.ini). Set it to the address your team
actually uses, or the links point to the wrong host.
[email protected]. You can add several, separated by commas.
Edit the contact point and click Test, then
Send test notification. A message with the subject
[FIRING:1] TestAlert should land in the inbox.
If it arrives, email works. Anything that goes wrong later is in the rule, not in the delivery. If it doesn't, fix SMTP first (see If no email arrives).
Open Alerting → Alert rules and click New alert rule. The form has six steps.
High CPU usage.
Pick the Prometheus data source, switch the query editor from Builder to Code and type:
100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[1m])) * 100node_cpu_seconds_total counts how long each core spent in every mode.rate(...[1m]) turns that into a speed.idle mode is the time the CPU did nothing.Click Run queries to see the current value. Below it is the alert condition: When query is above. Type 80. Click Preview alert rule condition and you see every server with its state. Normal, for now.
Turn on Advanced options to see what Grafana builds underneath:
The folder also decides who can see and edit the rule. Click New folder and create Linux.
Labels are optional, but they are what notification policies use to route alerts.
Click Add labels and add severity =
critical. We use it in step 8.
Rules are checked in groups. Click New evaluation group, name it linux, interval 1m. Grafana checks the rule every minute.
| Setting | Value | Why |
|---|---|---|
| Pending period | 1m | CPU has to stay above 80 for a full minute before the alert fires. A short spike won't wake anyone up. |
| Keep firing for | optional | The opposite: it keeps the alert firing for a while after CPU drops. A value that flaps around 80 doesn't send you ten emails. |
| Alert state if no data | Alerting | Under Configure no data and error handling. If the server stops sending data at all, a dead server alerts you too. |
Pick the Ops email contact point.
The summary can use templates. This is the one from the video:
CPU on {{ $labels.instance }} is {{ printf "%.0f" $values.A.Value }}%
$labels.instance is the server's name. $values.A is the
value of query A, the CPU usage. printf "%.0f" rounds it to a whole
number.
The description and a runbook URL are optional. The person who gets this email at three in the morning will thank you for them.
Tip: example values. These were not typed in the video. Adapt them.
Description: CPU on {{ $labels.instance }} has been above 80% for over a minute. Check the top processes with top or htop.
Runbook URL: https://wiki.example.com/runbooks/high-cpu
Click Save.
On the server, load every CPU core for ten minutes:
stress-ng --cpu 0 --timeout 600s
--cpu 0 starts one worker per CPU core. Ctrl+C
stops it early.
severity=critical and
instance=web-01.[FIRING:1] and the rule
name, High CPU usage. Inside is the summary with web-01 and the value, the labels,
and links to open the rule or to silence it.[RESOLVED] email, so you know it is over.This is the setting that decides how often you get emails. Open Alerting → Notification configuration, then the Notification policies tab. The Default policy handles every alert, and its three timings are the defaults:
| Timing | Default | Shown as | What it does |
|---|---|---|---|
| Group wait | 30s | Wait 30s to group | Grafana waits a moment, so alerts that fire together arrive in one email. |
| Group interval | 5m | Wait 5m before sending updates | New alerts in the same group wait at least that long. |
| Repeat interval | 4h | Repeated every 4h | While an alert keeps firing, you get it again only every four hours. |
Don't set the repeat interval too low. An email every few minutes for the same problem teaches your team to ignore Grafana.
Tip: give the default policy a contact point. In my lab the default policy sends to Ops email. Check yours with Edit on the default policy, so alerts that reach the tree always go somewhere.
This is where labels pay off.
[email protected], the same way as in step 2.severity = critical.Now critical alerts go to the on-call team. Everything else stays on the default policy.
Rules that pick a contact point directly skip this tree. Our High CPU rule chose Ops email in step 5 of the rule form, so it still goes to Ops email, whatever its labels say. The child policy only applies to rules that use notification policies.
Tip: to route the High CPU rule through the tree, edit the rule and in step 5 choose Use notification policy instead of a contact point.
Planned maintenance? Use a silence instead of disabling the rule.
instance = web-01.The rule still runs, but no emails go out for web-01 until the silence ends. Every firing email also has a link to silence that alert.
Start with the Test button on the contact point. If the test fails too, it is the SMTP settings, and Grafana's log shows the exact error.
| What you see | Where to look |
|---|---|
| The test notification fails or never arrives | SMTP: host, port, user, password, or enabled = true missing.
Read Grafana's log. In Docker: docker compose logs grafana (tip). |
| The test arrives, the alert email doesn't | The rule. Is it Firing, or still Pending? Does it use the right contact point, or a policy that sends somewhere else? |
| The rule never leaves Normal | Run the query and check the value really goes above 80. Check that the condition is set on expression C. |
| Too many emails for one problem | Repeat interval on the policy, and Keep firing for on the rule. |
The whole walkthrough on Grafana 13, from an empty Grafana to the FIRING and RESOLVED emails, notification timings and silences:
One rule and one inbox is a start. A real setup needs rules that catch the problems that matter, routing by team and severity, and timings nobody learns to ignore. I'm a Grafana Champion, and I set up monitoring and observability through KorFlux. Tell me what you run and I'll tell you how I'd set up the alerting.