mkdir -pv /apps/alertmanager/{conf,template}
vim /apps/alertmanager/docker-compose.yml
version: "3"
services:
alertmanager:
image: prom/alertmanager:v0.24.0
container_name: prometheus-alertmanager
hostname: alertmanager
restart: always
volumes:
- /apps/alertmanager/template:/etc/alertmanager/template
- /apps/alertmanager/conf/alertmanager.yml:/etc/alertmanager/alertmanager.yml
ports:
- 9093:9093
networks:
default:
external:
name: prometheus
vim /apps/alertmanager/conf/alertmanager.yml
global:
resolve_timeout: 5m
route:
group_by: ['instance']
group_wait: 30s
group_interval: 30s
repeat_interval: 1h
receiver: 'dingtalk'
routes:
- receiver: 'message'
continue: true
match:
severity: emergency
- receiver: 'dingtalk'
continue: true
match_re:
severity: critical|warning
receivers:
- name: 'dingtalk'
webhook_configs:
- url: 'http://127.0.0.1:9080/prometheusalert?type=dd&tpl=prometheus-dd-my&ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxx'
- name: 'message'
webhook_configs:
- url: 'http://127.0.0.1:9080/prometheusalert?type=txdx&tpl=prometheus-dx-my&phone=xxx'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['instance']
说明:
receivers
配置实际的告警发送方式,此处使用了开源组件 Prometheus Alert
具体配置请参考官方文档Alertmanager
官方文档:https://prometheus.io/docs/alerting/latest/alertmanagerPrometheus Alert
官方文档:https://feiyu563.gitbook.io/prometheusalertAlertmanager
配置文件官方说明:https://prometheus.io/docs/alerting/latest/configurationAlertmanager
配置文件详解:https://www.cnblogs.com/kebibuluan/p/14928490.htmldocker network list
若不存在,则创建:
docker network create prometheus --subnet 10.21.22.0/24
cd /apps/alertmanager
docker-compose up -d
cd /apps/alertmanager
docker-compose ps
docker-compose logs -f
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']