Skip to content

Deploying a 3-node Alertmanager HA cluster with gossip mesh on AlmaLinux 9

Stand up an HA Alertmanager cluster on AlmaLinux 9 — three nodes joined via gossip mesh, each Prometheus pushing to all three, with a deduplication proof so you can show the cluster works before relying on it.

You run a single Alertmanager. It’s been up for eight months. Then it’s not — kernel panic, EBS detach, machine moved to a different host — and during the twelve minutes it’s down you miss two alerts that would have caught a production regression before customers did. The post-mortem says “make Alertmanager HA.” A week later someone has installed three Alertmanagers, none of them are talking to each other, all three are sending the same notification, and your on-call rotation is now getting paged in triplicate. HA Alertmanager isn’t “run three of them” — it’s “run three of them with the gossip mesh wired so they coordinate notifications.”

What’s happening

Alertmanager has a built-in clustering mode that uses gossip over a --cluster.listen-address port to share state: silences, notification log (which alert has already been sent), and group state. When you run three Alertmanagers in a cluster and every Prometheus pushes the same alert to all three, the cluster gossip ensures that only one of them actually delivers the notification — the others see the entry in the notification log and suppress.

What breaks without the gossip mesh:

  • Three Alertmanagers, each independently receives the alert from every Prometheus, each independently fires the webhook. PagerDuty gets three tickets.
  • A silence created on one Alertmanager is unknown to the others. The alert keeps firing on two of three.
  • Group timing differs between instances, so the “first” notification on each node is sent at a slightly different time.

What breaks with the gossip mesh if misconfigured:

  • The cluster ports aren’t reachable across nodes (firewall, private network not bridged). Each node logs failed to join cluster and the cluster is “three nodes” only in your head.
  • Clocks are not synced. Notification log timestamps are inconsistent and dedup decisions become unreliable.
  • Only one Prometheus pushes to one Alertmanager, expecting the cluster to “share” the alert. The cluster shares notification state, not the alerts themselves. Every Prometheus must push to every Alertmanager.

How to verify

After deployment, on any node:

# Cluster members visible to this Alertmanager
curl -fs http://127.0.0.1:9093/api/v2/status | jq '.cluster'

Expected: status: "ready", peers lists all three with their addresses. If status: "settling" for more than 30 seconds, gossip isn’t reaching peers.

# Cluster port reachability
for h in am01 am02 am03; do
  nc -zv $h 9094 || echo "  -> $h:9094 NOT REACHABLE"
done
# Notification log (dedup state)
curl -fs http://127.0.0.1:9093/api/v2/alerts/groups | jq '.[].alerts | length'

After firing a test alert to all three nodes simultaneously, only one node should record a “fired” notification entry; the other two should record the alert but show the notification as already dispatched by a peer.

Deduplication proof — fire the same alert at all three from a different host:

ALERT='[{"labels":{"alertname":"DedupTest","severity":"info","instance":"test"},"annotations":{"summary":"dedup test"},"startsAt":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"}]'

for h in am01 am02 am03; do
  curl -fs -XPOST "http://$h:9093/api/v2/alerts" -H "Content-Type: application/json" -d "$ALERT"
done

# Wait for the group timer to elapse, then check the receiver (slack/pagerduty/webhook).
# Expected: ONE notification, not three.

If you receive three notifications, the cluster isn’t actually clustering — usually a firewall blocks 9094.

The fix

Save the script as /root/setup-alertmanager-node.sh and run on each of the three nodes after editing NODE_NAME, NODE_IP, and PEER_IPS. It installs Alertmanager, configures gossip on TCP+UDP 9094, writes a sample alertmanager.yml with a webhook receiver and a route tree, and brings up the systemd unit.

#!/usr/bin/env bash
set -euo pipefail

### Alertmanager 0.27 HA installer on AlmaLinux 9
### Run on each of 3 nodes — am01, am02, am03

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT PER NODE ===
NODE_NAME="am01"
NODE_IP="10.20.0.11"
PEER_IPS=("10.20.0.11" "10.20.0.12" "10.20.0.13")
ALERTMANAGER_VERSION="0.27.0"
WEBHOOK_URL="https://hooks.example.com/services/REPLACE_ME"
# =====================

echo "==> Base packages"
dnf -y update
dnf -y install epel-release
dnf -y install curl wget tar gzip chrony fail2ban dnf-automatic \
  policycoreutils-python-utils firewalld jq nc

systemctl enable --now chronyd
systemctl enable --now firewalld

echo "==> Creating alertmanager user"
id -u alertmanager &>/dev/null || \
  useradd --system --no-create-home --shell /sbin/nologin alertmanager

echo "==> Downloading Alertmanager ${ALERTMANAGER_VERSION}"
cd /tmp
TARBALL="alertmanager-${ALERTMANAGER_VERSION}.linux-amd64.tar.gz"
wget -q "https://github.com/prometheus/alertmanager/releases/download/v${ALERTMANAGER_VERSION}/${TARBALL}"
tar xzf "${TARBALL}"
install -m 0755 "alertmanager-${ALERTMANAGER_VERSION}.linux-amd64/alertmanager" /usr/local/bin/alertmanager
install -m 0755 "alertmanager-${ALERTMANAGER_VERSION}.linux-amd64/amtool" /usr/local/bin/amtool
rm -rf "alertmanager-${ALERTMANAGER_VERSION}.linux-amd64" "${TARBALL}"

mkdir -p /etc/alertmanager /var/lib/alertmanager
chown -R alertmanager:alertmanager /etc/alertmanager /var/lib/alertmanager

echo "==> Writing alertmanager.yml"
cat > /etc/alertmanager/alertmanager.yml <<EOF
global:
  resolve_timeout: 5m

route:
  receiver: 'default-webhook'
  group_by: ['alertname','cluster','service']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  routes:
    - matchers:
        - severity = critical
      receiver: 'critical-webhook'
      group_wait: 10s
      repeat_interval: 1h
    - matchers:
        - severity = info
      receiver: 'info-webhook'
      repeat_interval: 12h

receivers:
  - name: 'default-webhook'
    webhook_configs:
      - url: '${WEBHOOK_URL}'
        send_resolved: true

  - name: 'critical-webhook'
    webhook_configs:
      - url: '${WEBHOOK_URL}'
        send_resolved: true

  - name: 'info-webhook'
    webhook_configs:
      - url: '${WEBHOOK_URL}'
        send_resolved: false

inhibit_rules:
  - source_matchers:
      - severity = critical
    target_matchers:
      - severity = warning
    equal: ['alertname','cluster','service']

templates:
  - '/etc/alertmanager/templates/*.tmpl'
EOF
chown alertmanager:alertmanager /etc/alertmanager/alertmanager.yml

mkdir -p /etc/alertmanager/templates
cat > /etc/alertmanager/templates/default.tmpl <<'EOF'
{{ define "slack.default.title" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.alertname }} {{ if .CommonLabels.service }}({{ .CommonLabels.service }}){{ end }}{{ end }}
EOF
chown -R alertmanager:alertmanager /etc/alertmanager/templates

echo "==> Building cluster peer flags"
CLUSTER_PEERS=""
for ip in "${PEER_IPS[@]}"; do
  if [[ "$ip" != "$NODE_IP" ]]; then
    CLUSTER_PEERS+="--cluster.peer=${ip}:9094 "
  fi
done

echo "==> Systemd unit"
cat > /etc/systemd/system/alertmanager.service <<EOF
[Unit]
Description=Alertmanager
After=network.target chronyd.service
Wants=chronyd.service

[Service]
Type=simple
User=alertmanager
Group=alertmanager
ExecStart=/usr/local/bin/alertmanager \\
  --config.file=/etc/alertmanager/alertmanager.yml \\
  --storage.path=/var/lib/alertmanager \\
  --web.listen-address=:9093 \\
  --web.external-url=http://${NODE_NAME}:9093 \\
  --cluster.listen-address=${NODE_IP}:9094 \\
  --cluster.advertise-address=${NODE_IP}:9094 \\
  ${CLUSTER_PEERS} \\
  --cluster.peer-timeout=15s \\
  --cluster.reconnect-timeout=5m \\
  --cluster.gossip-interval=200ms \\
  --cluster.pushpull-interval=60s \\
  --log.level=info
Restart=on-failure
RestartSec=5s
LimitNOFILE=200000

[Install]
WantedBy=multi-user.target
EOF

echo "==> Firewall — 9093 (HTTP) + 9094 (cluster TCP+UDP)"
firewall-cmd --permanent --add-port=9093/tcp
firewall-cmd --permanent --add-port=9094/tcp
firewall-cmd --permanent --add-port=9094/udp
firewall-cmd --reload

echo "==> fail2ban"
cat > /etc/fail2ban/jail.d/sshd.local <<'EOF'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
EOF
systemctl enable --now fail2ban

echo "==> Start Alertmanager"
systemctl daemon-reload
systemctl enable --now alertmanager

echo "==> Waiting for HTTP endpoint"
for i in {1..30}; do
  if curl -fs "http://127.0.0.1:9093/-/ready" >/dev/null 2>&1; then break; fi
  sleep 2
done

echo
echo "========================================"
echo "DONE — Alertmanager ${NODE_NAME} up on ${NODE_IP}"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(9093|9094)\b' || true
echo
echo "Cluster status:"
curl -fs http://127.0.0.1:9093/api/v2/status | jq '.cluster' || true
echo
echo "Peer reachability:"
for ip in "${PEER_IPS[@]}"; do
  if [[ "$ip" != "$NODE_IP" ]]; then
    nc -zv "$ip" 9094 2>&1 || true
  fi
done
echo
echo "Repeat on the other 2 nodes with their NODE_NAME / NODE_IP."
echo "Once all 3 are up:"
echo "  curl -s http://127.0.0.1:9093/api/v2/status | jq '.cluster.peers'"
echo "  -> should list all 3 peers"

After all three nodes are up, configure every Prometheus to push to all three Alertmanagers — this is the part that’s commonly missed:

# /etc/prometheus/prometheus.yml on EVERY Prometheus
alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - 'am01.internal:9093'
            - 'am02.internal:9093'
            - 'am03.internal:9093'
      scheme: http
      timeout: 10s
      api_version: v2

The dedup proof from the verification section above is the test that the cluster is real. Run it once, see one notification, then run it after stopping one Alertmanager — you should still see exactly one notification, because gossip continues with the remaining two. If notifications double when you stop one node, the cluster wasn’t actually doing the dedup; one node was doing all the delivery and the others were silent.

A working three-node Alertmanager survives any single-node failure invisibly, dedups across all healthy peers, and propagates silences in seconds. Run this under our monitoring + on-call tier with notification routing, runbook URLs, and dedup verified in CI — scope an alerting overhaul if your current setup pages you in triplicate.