kafka报警规则:
一、alertmanager安装
1、下载安装包:https://github.com/prometheus/alertmanager/releases/download/v0.15.2/alertmanager-0.15.2.linux-amd64.tar.gz
2、解压安装
# tar zxf alertmanager-0.15.2.linux-amd64.tar.gz -C /usr/local/ # cd /usr/local/alertmanager-0.15.2.linux-amd64/
修改alertmanager.yml配置文件
# cat alertmanager.yml
global: resolve_timeout: 5m smtp_smarthost: ‘smtp.qq.com:465‘ # 邮箱smtp服务器代理 smtp_from: ‘xxxxx@qq.com‘ # 发送邮箱名称 smtp_auth_username: ‘xxxxxx@qq.com‘ # 邮箱名称 smtp_auth_password: ‘xxxxxx‘ #qq邮箱授权码 smtp_require_tls: false route: group_by: [‘kafka_rules‘] # 报警分组名称 group_wait: 10s # 最初即第一次等待多久时间发送一组警报的通知 group_interval: 10s # 在发送新警报前的等待时间 repeat_interval: 1m # 发送重复警报的周期 receiver: ‘email‘ # 发送警报的接收者的名称,以下receivers name的名称 receivers: - name: ‘email‘ email_configs: # 邮箱配置 - to: ‘xxxxx@qq.com‘ # 接收警报的email配置
配置文件语法检测
# ./amtool check-config alertmanager.yml
Checking ‘alertmanager.yml‘ SUCCESS Found: - global config - route - 0 inhibit rules - 1 receivers - 0 templates
启动alertmanager
# nohup ./alertmanager --config.file=alertmanager.yml 2>&1 1>altermanager.log &
3、修改prometheus.yml配置文件
# cat /usr/local/prometheus-2.6.1.linux-amd64/prometheus.yml
# Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: ["localhost:9093"] # - alertmanager:9093
重启prometheus
# systemctl restart prometheus.service
4、手动触发报警
查看报警邮件
原文:https://www.cnblogs.com/lina-2159/p/13628158.html