Grafana Unified Alerting — reguły, contact points i on-call
Opublikowano: 10 kwietnia 2026 · Kategoria: VPS
Grafana 9+ zastąpiło stary system alertowania (panel-by-panel) nowym Unified Alerting — jednym centralnym miejscem do zarządzania regułami, kanałami powiadomień i harmonogramem dyżurów. To nie tylko ewolucja UI — to zupełnie nowa architektura z wbudowanym Alertmanagerem, wielodataźródłowymi regułami i integracją z Grafana OnCall.
Legacy vs Unified Alerting — porównanie
| Cecha | Legacy (<Grafana 9) | Unified (Grafana 9+) |
|---|---|---|
| Zasięg | Per panel | Centralne zarządzanie |
| Datasources | 1 per alert | Wiele w jednej regule |
| Routing | Notification channels | Notification policies (drzewo) |
| Silencing | Brak | Silences z matchers |
| Stan alertów | OK/Alerting | Normal/Pending/Firing/No data/Error |
| Zewn. Alertmanager | Brak | Wbudowany + external |
Tworzenie alert rule — krok po kroku
Przejdź do Alerting → Alert rules → New alert rule. Proces tworzenia reguły ma 5 kroków:
- Query & conditions — zapytanie (PromQL/LogQL/SQL) + reducer (Last, Mean, Max) + condition (threshold: B > 85)
- Alert evaluation behavior — evaluate every 1m, for 5m (PENDING zanim FIRING)
- Add details — nazwa, folder, group, labels, annotations
- Notifications — contact point, notification policy
- Confirm and save
Przykładowa reguła dla wysokiego CPU — query A jako PromQL, expression B jako Reduce:
# Query A (Prometheus datasource):
100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
# Expression B: Reduce
Operation: Last
Input: A
Output: B
# Condition: WHEN B IS ABOVE 85
# Evaluate every: 1m / For: 5m Contact Points — kanały powiadomień
Grafana Unified Alerting obsługuje dziesiątki integracji. Najpopularniejsze:
| Integracja | Wymagane dane | Kiedy używać |
|---|---|---|
| Slack | Webhook URL lub Bot Token + Channel | Alerty dev/ops teamów, informacyjne |
| Telegram | Bot API Token + Chat ID | Małe zespoły, mobilne alerty |
| OpsGenie | API Key, Region | On-call management, eskalacje |
| PagerDuty | Integration Key (Events API v2) | 24/7 on-call, krytyczna infrastruktura |
| SMTP config w grafana.ini | Raporty, alerty mniej pilne | |
| Webhook | URL endpointu | Własne integracje, Teams, Discord |
Konfiguracja Telegramu przez UI: Alerting → Contact points → Add → Telegram → wpisz Bot API Token i Chat ID. Możesz dostosować treść wiadomości szablonem Go:
# Przykładowy template dla Telegrama (w polu Message):
{{ define "telegram.default.message" -}}
{{ if eq .Status "firing" }}🚨 ALERT{{ else }}✅ RESOLVED{{ end }}
*{{ .CommonAnnotations.summary }}*
{{ .CommonAnnotations.description }}
Severity: {{ .CommonLabels.severity }}
{{- end }} Notification Policies — drzewo routingu
Notification policies (dawniej "routes") decydują który contact point dostanie dany alert. Root policy obsługuje wszystkie alerty, nested policies — podzbiory według matchers:
# Schemat drzewa routingu:
Root policy:
contact_point: default-email
group_by: [grafana_folder, alertname]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
Nested policy 1:
matchers: severity=critical
contact_point: pagerduty-team
repeat_interval: 1h
Nested policy 2:
matchers: team=database
contact_point: slack-db-channel
group_by: [alertname, instance] Silences — tymczasowe wyciszanie
Alerting → Silences → New silence. Definiujesz matchers (label=value lub label=~regex), czas trwania i opcjonalnie komentarz. Silence jest aktywne natychmiast — alerty pasujące do matchers nie generują powiadomień przez ten czas. Silences możesz też tworzyć bezpośrednio z listy aktywnych alertów (przycisk "Silence").
Grafana OnCall — harmonogram dyżurów
Grafana OnCall (open-source, instalacja na własnym serwerze lub Grafana Cloud) rozszerza Unified Alerting o zarządzanie on-call:
- Schedules — harmonogram dyżurów (tygodniowy, rotacyjny, warstwy primary+secondary)
- Escalation chains — jeśli osoba dyżurująca nie odpowie w X minut → powiadamiasz kolejną
- Integracje — Grafana Alerting, Prometheus Alertmanager, PagerDuty, Zabbix
- Mobile App — natywna apka iOS/Android z push alertami i acknowledge
Tip: Grafana OnCall możesz zainstalować przez Docker lub jako Helm chart dla Kubernetes. Połącz z Unified Alerting przez webhook contact point — OnCall dostaje alerty i zarządza kto je dostaje i kiedy.