alertmanager configuration file

Installation and deployment, self-starting and writing independent log files

alertmanager.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
global:
resolve_timeout: 5m
smtp_from: 'xxx@xxxx.com'
smtp_smarthost: 'smtp.ym.163.com:465'
smtp_auth_username: 'xxxx'
smtp_auth_password: 'xxxx'
smtp_require_tls: false
route:
group_by: ['instance']
group_wait: 10s
group_interval: 1m
repeat_interval: 10m
receiver: 'webhook_legacy'
routes:
- receiver: 'webhook1'
group_wait: 30s
group_interval: 2m
repeat_interval: 3m
continue: true
match:
env: Alitest
- receiver: 'webhook2'
group_by: ['resource']
continue: true
match:
type: host
- receiver: 'webhook_legacy'
match:
resource:memory
receivers:
- name: 'webhook2'
webhook_configs:
- url: 'http://127.0.0.1:8060/dingtalk/webhook2/send'
- name: 'webhook1'
webhook_configs:
- url: 'http://127.0.0.1:8060/dingtalk/webhook1/send'
- name: 'webhook_legacy'
webhook_configs:
- url: 'http://127.0.0.1:8060/dingtalk/webhook_legacy/send'
- name: 'email'
email_configs:
- to: 'xxxx@xxx.com'
send_resolved: true
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']

/etc/systemd/system/alertmanager.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target

[Service]
User=prometheus
Group=prometheus
ExecStart=/opt/soft/monitor/alertmanager-0.25.0.linux-amd64/alertmanager --config.file /opt/soft/monitor/alertmanager-0.25.0.linux-amd64/alertmanager.yml --storage.path /opt/soft/monitor/alertmanager-0.25.0.linux-amd64/data
StandardOutput=syslog
StardardError=syslog
SyslogIdentifier=alertmanager
Restart=always

[Install]
WantedBy=multi-user.target

/etc/rsyslog.d/alertmanager.conf

1
2
3
4
5
#!/bin/bash
if ($programname == "alertmanager")then{
action(type="omfile" file="/var/log/alertmanager.log")
stop
}

alertmanager configuration file
http://www.7-24.tech/en/2025/06/25/alertmanager配置文件/