码迷,mamicode.com
首页 > 其他好文 > 详细

部署altermanager 并使用邮件进行报警

时间:2021-04-13 11:58:34      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:manage   defaults   --   files   end   dde   bin   cond   emc   

部署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‘]

部署altermanager 并使用邮件进行报警

标签:manage   defaults   --   files   end   dde   bin   cond   emc   

原文地址:https://www.cnblogs.com/heping0312/p/14647152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!