Grafana 9 부터 통합 알림(Unified Alerting)이 기본이다. 데이터 소스와 무관하게 Grafana 가 규칙을 직접 평가한다.
| 요소 | 역할 |
|---|---|
| Alert rule | 조건과 평가 주기 |
| Contact point | 알림을 보낼 곳 (메일 · Slack · Webhook) |
| Notification policy | 어떤 알림을 어느 contact point 로 보낼지 |
| Silence | 일정 기간 알림 중단 |
Alerting → Alert rules → New alert rule 에서 만든다. 구성은 세 단계다.
node_filesystem_avail_bytes / node_filesystem_size_bytes * 100Last) → Threshold(IS BELOW 10)Pending periodPending period 는 조건이 계속 참일 때 알림을 보내기까지 기다리는 시간이다. 짧으면 순간 튀는 값에 알림이 온다. 보통 5분 이상 준다.
파일로 관리하려면 /etc/grafana/provisioning/alerting/ 에 둔다.
apiVersion: 1
contactPoints:
- orgId: 1
name: ops-slack
receivers:
- uid: ops-slack-01
type: slack
settings:
url: '<Slack_Webhook_URL>'
policies:
- orgId: 1
receiver: ops-slack
group_by: ['alertname', 'instance']
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
메시지 템플릿에서 쓸 수 있는 값이다.
{{ .CommonLabels.alertname }}
{{ .CommonLabels.instance }}
{{ range .Alerts }}{{ .Annotations.summary }}{{ end }}
Prometheus 의 Alertmanager 를 이미 쓰고 있다면 Grafana 에서 규칙을 따로 만들지 않고 외부 Alertmanager 를 데이터 소스로 붙여 조회만 한다. 규칙이 두 곳에 흩어지면 어디서 울린 알림인지 찾기 어려워진다.
자세한 것은 Alertmanager 를 볼 것.