官网网站
https://prometheus.io/download/
wget https://github.com/prometheus/alertmanager/releases/download/v0.17.0/alertmanager-0.17.0.linux-amd64.tar.gz
tar xvf alertmanager-0.17.0.linux-amd64.tar.gz
mv alertmanager-0.17.0.linux-amd64 /usr/local/alertmanager
创建用户
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/alertmanager
创建Systemd服务
cat > /etc/systemd/system/alertmanager << EOF
[Unit]
Description=Prometheus Alertmanager.
Documentation=https://github.com/prometheus/alertmanager
After=network.target
[Service]
EnvironmentFile=-/etc/default/alertmanager.service
User=prometheus
ExecStart=/usr/local/alertmanager/alertmanager \
--config.file=/usr/local/alertmanager/alertmanager.yml \
--storage.path=/var/lib/prometheus/alertmanager/data \
$ALERTMANAGER_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
EOF
查看运行状态
Alertmanager启动后可以通过9093端口访问,http://ip:9093
关联Prometheus与Alertmanager
vim /usr/local/prometheus.yml
alerting:
alertmanagers:
- static_configs:
- targets: ["localhost:9093"]
重启Prometheus服务
systemctl restart prometheus
成功后,可以从http://ip:9090/config查看alerting配置是否生效。