Ravindra BagaleCourses & study guides मराठी

Chapter 87: Prometheus and Grafana Monitoring

DevOps

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.

Prometheus fires alerts. Alertmanager groups and silences. Then email or Slack receives one clear message.
Prometheus fires alerts. Alertmanager groups and silences. Then email or Slack receives one clear message.

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

  1. Configure Alertmanager receivers (Helm values or Secret).
  2. Put webhook URLs and SMTP passwords only in Secrets or your vault — never in Git.
  3. Group by alertname and namespace so one incident is one thread.
  4. 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.

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.