Chapter 87: Prometheus and Grafana Monitoring
87.7 Alertmanager — email and Slack without secrets in Git
Story. Neha's team got 200 Slack messages for one disk full event because every replica fired. They turned on Alertmanager grouping and a five-minute repeat interval. Webhook URL lived in a Kubernetes Secret; the Helm values only referenced the Secret name. Git stayed clean — no real tokens committed.
Why
Raw alerts spam people. Alertmanager batches, deduplicates, silences and routes.
What
- Alertmanager — Receives alerts from Prometheus, groups them, and sends notifications.
- Route tree — Matches labels (for example
severity: page) to receivers. - Receiver — email, Slack webhook, PagerDuty, and others.
- Silence — Temporary mute matching alerts (maintenance windows).
- Inhibition — Suppress a low alert when a related high alert is already firing.
How
- Configure Alertmanager receivers (Helm values or Secret).
- Put webhook URLs and SMTP passwords only in Secrets or your vault — never in Git.
- Group by
alertnameandnamespaceso one incident is one thread. - Test with a deliberate firing alert in non-prod.
Example 1: Route sketch (no real secrets)
route:
receiver: team-slack
group_by: ["alertname", "namespace"]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receivers:
- name: team-slack
slack_configs:
- api_url_file: /etc/alertmanager/secrets/slack_webhook
channel: "#ops-alerts"
What it shows: Grouping reduces noise. The webhook is read from a file mounted from a Secret, not pasted into the Git repo.
Example 2: Check Alertmanager status
kubectl -n monitoring port-forward svc/kube-prometheus-stack-alertmanager 9093:9093
# then open http://127.0.0.1:9093 in your browser
Output
Forwarding from 127.0.0.1:9093 -> 9093
What it shows: You can view firing alerts, silences and the status page locally without publishing Alertmanager to the internet.
Ravindra Bagale's Tip
If Slack gets a storm, fix grouping and repeat_interval before you add more alerts.
Slack वर storm आला तर आधी grouping आणि repeat_interval ठीक करा — नवे alerts नंतर.
Slack पर storm आए तो पहले grouping और repeat_interval ठीक करें — नए alerts बाद में.
Quick quiz
Q1. What problem does Alertmanager solve?
It groups, routes, silences and notifies so humans are not spammed.
Q2. Where should Slack webhook URLs live?
In a Secret or vault — never committed to Git.
Q3. What is a silence?
A temporary mute for matching alerts, often used in maintenance.
Did you understand? Let us try it once more.