部署altermanager组件
[root@zabbix ~]# tar -xf alertmanager-0.21.0.linux-amd64.tar.gz -C /opt/monitor/
[root@zabbix ~]# cd /opt/monitor/
[root@zabbix monitor]# mv alertmanager-0.21.0.linux-amd64/ alertmanager/
[root@zabbix system]# cd /usr/lib/systemd/system/
[root@zabbix system]# cat alertmanager.service
[Unit]
Description=alertmanager
[Service]
ExecStart=/opt/monitor/alertmanager/alertmanager --config.file=/opt/monitor/alertmanager/alertmanager.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@zabbix system]# systemctl daemon-reload
[root@zabbix system]# systemctl restart alertmanager
[root@zabbix system]# systemctl enable alertmanager
[root@zabbix system]# ps -ef | grep alertmanager
root 24241 1 0 10:48 ? 00:00:00 /opt/monitor/alertmanager/alertmanager --config.file=/opt/monitor/alertmanager/alertmanager.yml
root 24761 66919 0 10:48 pts/2 00:00:00 grep --color=auto alertmanager
配置规则
[root@zabbix ~] cat /opt/monitor/alertmanager/alertmanager.yml
global:
resolve_timeout: 5m
smtp_smarthost: 'smtp.163.com:25'
smtp_from: 'm18126055174@163.com'
smtp_auth_username: 'm18126055174@163.com'
smtp_auth_password: 'YNHXISKEIIKAGZEA'
smtp_require_tls: false
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'mail'
receivers:
- name: 'mail'
email_configs:
- to: 'm19940312qazwsx@163.com'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
prometheus配置如下
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- 127.0.0.1:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "rules/*.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['192.168.0.61:9100']