What Is Alertmanager?
Alertmanager handles alerts sent by Prometheus server. It takes care of deduplication, grouping, silencing, and routing alerts to the correct receiver -- whether that is email, Slack, PagerDuty, or a webhook. It is essential for a production monitoring setup on your Breeze.
Prerequisites
- A Breeze with Prometheus already installed and running
- Ubuntu 22.04 or later
Install Alertmanager
cd /tmp
wget https://github.com/prometheus/alertmanager/releases/download/v0.27.0/alertmanager-0.27.0.linux-amd64.tar.gz
tar -xzf alertmanager-0.27.0.linux-amd64.tar.gz
sudo mv alertmanager-0.27.0.linux-amd64/alertmanager /usr/local/bin/
sudo mv alertmanager-0.27.0.linux-amd64/amtool /usr/local/bin/
sudo mkdir -p /etc/alertmanager
Configure Alertmanager
Create /etc/alertmanager/alertmanager.yml:
global:
resolve_timeout: 5m
route:
receiver: email-alerts
group_by: [alertname, instance]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receivers:
- name: email-alerts
email_configs:
- to: admin@yourdomain.com
from: alertmanager@yourdomain.com
smarthost: smtp.yourdomain.com:587
auth_username: alertmanager@yourdomain.com
auth_password: YourSMTPPassword
Create a Systemd Service
sudo tee /etc/systemd/system/alertmanager.service <<EOF
[Unit]
Description=Alertmanager
After=network.target
[Service]
ExecStart=/usr/local/bin/alertmanager --config.file=/etc/alertmanager/alertmanager.yml
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now alertmanager
Connect Prometheus to Alertmanager
Add the following to your prometheus.yml:
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']
Restart Prometheus and verify the connection at the Alertmanager web UI on port 9093.