跳转至

Alertmanager

这里介绍飞书webhook的配置,结合PrometheusALert告警中心

部署

下载启动alertmanager 管理

alertmanager-0.27.0.linux-amd64.tar.gz

Bash
root@pts/0 # ls /opt/alertmanager
alertmanager  alertmanager.yml  amtool  LICENSE  NOTICE

启动程序

Bash
1
2
3
screen -S alert
cd /opt/alertmanager/
./alertmanager --web.listen-address=0.0.0.0:9093 --config.file="alertmanager.yml"

systemd管理服务

vim /usr/lib/systemd/system/alertmanager.service

Bash
[Unit]
Description=Prometheus-Server
After=network.target

[Service]
ExecStart=/opt/alertmanager/alertmanager --cluster.advertise-address=0.0.0.0:9093 --config.file=/opt/alertmanager/alertmanager.yml
User=root

[Install]
WantedBy=multi-user.target

重载服务

Bash
1
2
3
4
/usr/bin/systemctl daemon-reload
systemctl start alertmanager.service
systemctl enable alertmanager.service  
systemctl status alertmanager.service

配置

提前准备

编辑配置文件

vim /opt/alertmanager/alertmanager.yml

Bash
route:
  group_by: ['alertname','instance']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'feishu-webhook'
receivers:
  - name: 'feishu-webhook'
    webhook_configs:
      - url: 'http://172.16.1.26:8080/prometheusalert?type=fs&tpl=prometheus-fs1&fsurl=https://open.feishu.cn/open-apis/bot/v2/hook/c1540edd-c881-404b-baf2-c00b4f2ede8f'
        send_resolved: true
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']

配置完成后重新加载配置

curl -X POST http://172.18.1.18:9093/-/reload

页面访问http://172.16.1.18:9093