$ run as a normal user# run as root (or with sudo)
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.
| Item | Value |
|---|---|
| Files | /usr/local/bin/alertmanager, amtool (from the release file) |
| Config | /etc/alertmanager/alertmanager.yml |
| Data (silences, notification log) | /var/lib/alertmanager/ |
| Ports | 9093/tcp (UI and API), 9094 tcp+udp (cluster, only for HA) |
| Service | alertmanager.service (you write it) |
| Ubuntu package (older) | prometheus-alertmanager |
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[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.)
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_urlglobal:
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"]| Setting | Why |
|---|---|
group_by | One message per alert name and server, not one per alert. |
group_wait | Wait 30 s to collect alerts that start together (one message, not ten). |
group_interval | How often a group with new alerts is sent again. |
repeat_interval | Remind about alerts that are still firing (4 h; critical 1 h). |
routes + matchers | Critical to on-call Slack, database alerts to the DBAs, all the rest to ops email. |
inhibit_rules | No warning messages when the same problem is already critical. |
*_file settings | Passwords 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:
Connect Prometheus
In prometheus.yml (see the Prometheus guide):
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.
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 queryDaily 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 alertmanagerReal 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.
Make it safe
Security checklist:
- Listen on
127.0.0.1or 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
*_filefiles with mode600. 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).
Update and remove
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
| Alerts fire in Prometheus but nobody gets a message | Prometheus 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 failed | TLS or SMTP login problem. | Check smtp_smarthost port (587 + smtp_require_tls), user and password file. |
| Too many messages | Grouping too fine, intervals too short. | group_by fewer labels; longer group_interval / repeat_interval. |
| The same alert twice | Two Alertmanagers not in one cluster. | Cluster them (--cluster.peer) or list only one in Prometheus. |
| Alert goes to the wrong team | Route order: the first matching route wins (without continue: true). | amtool config routes show; order the routes; use continue when needed. |
| Config does not load | YAML or template error. | amtool check-config; the log shows the line. |
| Silence does not match | Wrong label value (for example instance=db1:9100). | Copy the labels from amtool alert query. |
Next steps
- Quick how-tos: Send alerts to Slack or email, Write a runbook for on-call, Define an SLO.
- Command page: amtool.
- The alert rules: Install and set up Prometheus. Server alerts: Node Exporter.
- Practise the stack: Lab: Prometheus, node exporter, Alertmanager and Grafana.
- At work: Route and silence alerts.
1What does group_wait: 30s do?
Alertmanager waits 30 seconds to collect alerts that start together, then sends them in one message.