kubernetes-Prometheus基于邮件告警
1、告警逻辑框架Prometheus的告警逻辑框架:
1)指标获取:Prometheus从监控目标中获取指标数据;
2)设置规则:运维人员根据运维管理需要 , 设置告警规则(rule_files);
3)推送告警:在Pometheus中指定指定告警规则 , 并设置告警服务器(prometheus.yml) , 当发生符合告警的规则时 , Prometheus就会将告警信息发送给设置的告警服务器;
4)发送告警:在告警服务器中 , 设置告警路由和告警接收 , 告警服务器将会根据告警管理配置将告警信息发送给告警接收器(email等);
5)处理告警:运维人员接收到告警信息后 , 对告警信息进行处理 , 保证被监控对象的正常运行 。
2、指定告警服务和规则文件告诉Promentheus , 将告警信息发送给那个告警管理服务 , 以及使用那个告警规则文件 。 这里的告警服务在Kubernetes中部署 , 对外提供的服务名称为alertmanager , 端口为9093 。 告警规则文件为“/etc/prometheus/rules/”目录下的所有规则文件 。
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).# 指定告警服务器alerting: alertmanagers: - static_configs: - targets: - alertmanager:9093# 指定告警规则文件rule_files: - "/etc/prometheus/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=
3、设置告警规则设置告警的规则 , Prometheus基于此告警规则 , 将告警信息发送给告警服务 。 这将未启动的实例信息发送给告警服务 , 告知哪些实例没有正常启动 。
#rulesgroups: - name: node-rules rules: - alert: InstanceDown # 告警名称expr: up == 0 # 告警判定条件for: 3s # 持续多久后 , 才发送labels: # 标签team: k8sannotations: # 警报信息summary: "{{$labels.instance}}: has been down"description: "{{$labels.instance}}: job {{$labels.job}} has been down "
4、设置告警信息路由和接受器这里设置通过邮件接收告警信息 , 当告警服务接收到告警信息后 , 会通过邮件将告警信息发送给被告知者 。
global: resolve_timeout: 5m smtp_smarthost: 'smtp.163.com:25' # 发送信息邮箱的smtp服务器代理 smtp_from: 'xxx@163.com' # 发送信息的邮箱名称 smtp_auth_username: 'xxx' # 邮箱的用户名 smtp_auth_password: 'SYNUNQBZMIWUQXGZ' # 邮箱的密码或授权码route: group_by: ['alertname'] group_wait: 10s group_interval: 10s repeat_interval: 1h receiver: 'email'receivers: - name: 'email' email_configs: - to: 'xxxxxx@aliyun.com' # 接收告警的邮箱 headers: { Subject: "[WARN] 报警邮件"} # 接收邮件的标题inhibit_rules: - source_match: severity: 'critical' target_match: severity: 'warning' equal: ['alertname', 'dev', 'instance']
推荐阅读
- 华硕基于WRX80的主板现身 为AMD Ryzen Threadripper Pro打造
- Facebook向客户发邮件:对苹果隐私新规“别无选择”
- 分析师预测苹果新服务可能包括播客+股票+和 邮件+
- 微软新版电子邮件客户端截图曝光:基于网页端Outlook
- 微软计划用Monarch项目取代Windows 10电子邮件客户端
- 曝光 | 小鹏或春节前推送NGP更新,基于高精地图可自动变道
- 微软测试Outlook智能文本预测功能 帮助用户更快地撰写电子邮件
- 基于Spring+Angular9+MySQL开发平台
- 14款华为手机/平板公测EMUI 11:全部基于麒麟980
- 今年美国大选未出现政客电子邮件泄漏 很大程度归功于物理安全密钥