Advanced
Searching inInstall guides
How to search
  • Paste an error message in quotes, e.g. "permission denied", to find the fix table that explains it.
  • Choose an area and a part of the guide (install, first settings, daily use, security, fixes) to go straight to the right step.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

Guide 34Alertmanager · Monitoring

Install and set up Alertmanager

Prometheus decides when something is wrong; Alertmanager decides who hears about it and how: email, Slack, Microsoft Teams, PagerDuty or a webhook. It groups many alerts into one message, sends critical ones to on-call and warnings to a channel, stops duplicates, and lets you silence alerts during maintenance. This guide installs Alertmanager on RHEL and Ubuntu, writes routes and receivers, connects Prometheus, tests the routing and covers the fixes.

  • 10 Lessons
  • 9 Commands

$ run as a normal user# run as root (or with sudo)

34.1

Know it before you install

Prometheus sends firing alerts to Alertmanager. The route tree matches alerts by labels (severity, team, env) and sends them to a receiver. Grouping puts related alerts in one message; inhibition hides warnings when a related critical alert is firing; silences mute alerts for a time.

ItemValue
Files/usr/local/bin/alertmanager, amtool (from the release file)
Config/etc/alertmanager/alertmanager.yml
Data (silences, notification log)/var/lib/alertmanager/
Ports9093/tcp (UI and API), 9094 tcp+udp (cluster, only for HA)
Servicealertmanager.service (you write it)
Ubuntu package (older)prometheus-alertmanager

34.2

Install on RHEL and Ubuntu

Use the release file (choose the version from github.com/prometheus/alertmanager/releases):

useradd --system --no-create-home --shell /sbin/nologin alertmanager
mkdir -p /etc/alertmanager /var/lib/alertmanager
AVER=0.28.1
curl -fsSLO https://github.com/prometheus/alertmanager/releases/download/v$AVER/alertmanager-$AVER.linux-amd64.tar.gz
tar -xzf alertmanager-$AVER.linux-amd64.tar.gz
install -m 0755 alertmanager-$AVER.linux-amd64/alertmanager alertmanager-$AVER.linux-amd64/amtool /usr/local/bin/
chown -R alertmanager: /etc/alertmanager /var/lib/alertmanager
/etc/systemd/system/alertmanager.service
[Unit]
Description=Prometheus Alertmanager
After=network-online.target
 
[Service]
User=alertmanager
ExecStart=/usr/local/bin/alertmanager \
  --config.file=/etc/alertmanager/alertmanager.yml \
  --storage.path=/var/lib/alertmanager \
  --web.listen-address=127.0.0.1:9093 \
  --web.external-url=https://alerts.example.com/ \
  --cluster.listen-address=
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

(--cluster.listen-address= empty = no cluster for a single server.)

34.3

First configuration: routes and receivers

Keep secrets (SMTP password, webhook URLs) in separate files, not in the main config:

install -m 600 -o alertmanager /dev/null /etc/alertmanager/smtp_password
install -m 600 -o alertmanager /dev/null /etc/alertmanager/slack_url
/etc/alertmanager/alertmanager.yml
global:
  smtp_smarthost: "smtp.example.com:587"
  smtp_from: "alerts@example.com"
  smtp_auth_username: "alerts@example.com"
  smtp_auth_password_file: /etc/alertmanager/smtp_password
  smtp_require_tls: true
  resolve_timeout: 5m
 
route:
  receiver: ops-email
  group_by: ["alertname", "instance"]
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  routes:
    - matchers: ['severity="critical"']
      receiver: oncall-slack
      repeat_interval: 1h
    - matchers: ['team="db"']
      receiver: db-email
 
receivers:
  - name: ops-email
    email_configs:
      - to: "ops@example.com"
        send_resolved: true
  - name: db-email
    email_configs:
      - to: "dba@example.com"
  - name: oncall-slack
    slack_configs:
      - api_url_file: /etc/alertmanager/slack_url
        channel: "#oncall"
        send_resolved: true
        title: '{{ .CommonLabels.alertname }} ({{ .Status }})'
        text: '{{ range .Alerts }}{{ .Annotations.summary }}{{ "\n" }}{{ end }}'
 
inhibit_rules:
  - source_matchers: ['severity="critical"']
    target_matchers: ['severity="warning"']
    equal: ["alertname", "instance"]
SettingWhy
group_byOne message per alert name and server, not one per alert.
group_waitWait 30 s to collect alerts that start together (one message, not ten).
group_intervalHow often a group with new alerts is sent again.
repeat_intervalRemind about alerts that are still firing (4 h; critical 1 h).
routes + matchersCritical to on-call Slack, database alerts to the DBAs, all the rest to ops email.
inhibit_rulesNo warning messages when the same problem is already critical.
*_file settingsPasswords and webhook URLs are not in the main file (safe to keep it in Git).

Microsoft Teams: use msteams_configs with a webhook URL file (Alertmanager 0.26+); other tools: webhook_configs.

Check and start:

amtool check-config /etc/alertmanager/alertmanager.yml
Checking '/etc/alertmanager/alertmanager.yml'  SUCCESS
systemctl daemon-reload
systemctl enable --now alertmanager

34.4

Connect Prometheus

In prometheus.yml (see the Prometheus guide):

/etc/prometheus/prometheus.yml
alerting:
  alertmanagers:
    - static_configs:
        - targets: ["127.0.0.1:9093"]

Every alert rule needs a severity label (and maybe team) so the routes can match. Reload Prometheus, then check Status → Runtime & Build Information → Alertmanagers.

34.5

Test the routing

Ask "where would this alert go?" and send a test alert:

amtool config routes show --config.file=/etc/alertmanager/alertmanager.yml
amtool config routes test --config.file=/etc/alertmanager/alertmanager.yml severity=critical alertname=InstanceDown
oncall-slack
amtool --alertmanager.url=http://127.0.0.1:9093 alert add TestAlert severity=warning instance=web1 --annotation=summary="Test from amtool"
amtool --alertmanager.url=http://127.0.0.1:9093 alert query

34.6

Daily use: silences and the real uses

Silence a server during maintenance (always with a comment and an end time):

export ALERTMANAGER_URL=http://127.0.0.1:9093
amtool silence add instance=db1 --duration=2h --comment="Patch window, ticket OPS-311" --author=alice
amtool silence query
amtool silence expire 8c6f2c1e-…
amtool alert query --active
systemctl reload alertmanager

Real uses at work:

  • Route by severity and team: critical → on-call (Slack/PagerDuty), warning → team channel, info → email.
  • Silences for maintenance windows; inhibition to stop alert storms.
  • Grafana and Loki alerts can use the same Alertmanager.

34.7

Make it safe

Security checklist:

  • Listen on 127.0.0.1 or a private network; the UI has no login — put Nginx with TLS and SSO/basic auth in front, or use --web.config.file.
  • Secrets in *_file files with mode 600.
  • send_resolved: true, so people know when a problem is over.
  • Test routes after every change (amtool config routes test) and send a test alert.
  • For high availability run 2–3 Alertmanagers in a cluster (port 9094), all listed in Prometheus.
  • Watch Alertmanager itself: alert when notifications fail (alertmanager_notifications_failed_total).

34.8

Update and remove

amtool check-config /etc/alertmanager/alertmanager.yml
systemctl stop alertmanager
install -m 0755 alertmanager-0.28.2.linux-amd64/alertmanager alertmanager-0.28.2.linux-amd64/amtool /usr/local/bin/
systemctl start alertmanager

34.9

Fix common problems

ProblemCauseFix
Alerts fire in Prometheus but nobody gets a messagePrometheus does not reach Alertmanager, or the route sends to a receiver with errors.Check Prometheus → Alertmanagers; journalctl -u alertmanager; amtool config routes test.
Email: x509 / 535 authentication failedTLS or SMTP login problem.Check smtp_smarthost port (587 + smtp_require_tls), user and password file.
Too many messagesGrouping too fine, intervals too short.group_by fewer labels; longer group_interval / repeat_interval.
The same alert twiceTwo Alertmanagers not in one cluster.Cluster them (--cluster.peer) or list only one in Prometheus.
Alert goes to the wrong teamRoute order: the first matching route wins (without continue: true).amtool config routes show; order the routes; use continue when needed.
Config does not loadYAML or template error.amtool check-config; the log shows the line.
Silence does not matchWrong label value (for example instance=db1:9100).Copy the labels from amtool alert query.

34.10

Next steps

1What does group_wait: 30s do?

Alertmanager waits 30 seconds to collect alerts that start together, then sends them in one message.

2How do you check where an alert with severity=critical will go, without sending one?

All commands in this chapter