admin管理员组文章数量:1582016
系列文章目录
第一章 生产环境部署prometheus+grafana+kafka+redis+nginx+node+postgres
prometheus+alertmanager告警管理
- 系列文章目录
- 前言
- 一、根据qq邮箱帮助文档获取授权码
-
- 1、qq邮箱获取授权码
- 2、企业微信获取授权码
-
- 1、登录web端企业微信--应用管理--创建应用
- 2.应用名称、头像、介绍、成员根据实际要求选。
- 3、创建完成后收集corpid(企业id)、 AgentId、Secret、账号
- 二、部署alertmanager
-
- 1.下载、安装alertmanager
-
- 配置qq邮箱alert
- 微信配置:
- 飞书配置
-
- 飞书修改告警模板
- 2.配置prometheus告警规则alerts-rules。
-
- 3、创建通知模版
- 三、自定义告警规则
-
-
-
- 1、在 Grafana 中打开“Alerting”面板,并单击“New Alert”。
- 2、在弹出的“Create Alert”窗口中,为 Alert 命名并选择适当的数据源。
- 3、在“Alert”选项卡中,选择适当的触发条件,例如当死锁事件数大于某个阈值时触发。
- 4、在“Notification”选项卡中选择适当的通知渠道,例如电子邮件、Slack 等。
- 5、在“Queries”选项卡中,为死锁事件的查询编写 PromQL 查询。
-
-
- 四、prometheus-rules.yml(正式环境)
前言
alert官方配置说明文档:https://prometheus.io/docs/alerting/latest/configuration/
Prometheus官方下载地址(很丰富):https://prometheus.io/download/
rules基本配置:https://awesome-prometheus-alerts.grep.to/rules
qq邮箱获取授权码帮助:https://service.mail.qq/cgi-bin/help?subtype=1&&id=28&&no=1001256
企业微信:https://work.weixin.qq/
一、根据qq邮箱帮助文档获取授权码
1、qq邮箱获取授权码
2、企业微信获取授权码
1、登录web端企业微信–应用管理–创建应用
2.应用名称、头像、介绍、成员根据实际要求选。
3、创建完成后收集corpid(企业id)、 AgentId、Secret、账号
二、部署alertmanager
1.下载、安装alertmanager
mv alertmanager-0.24.0.linux-amd64.tar.gz /u01/
mkdir alertmanager
tar -zxvf alertmanager-0.24.0.linux-amd64.tar.gz -C alertmanager
cd alertmanager/alertmanager-0.24.0.linux-amd64/
配置qq邮箱alert
global: ##全局配置
resolve_timeout: 5m ##当告警的状态由firing变为resolve时,需等待5min,如果报警未更新,则声明该告警已解决。可略微调高阈值避免
smtp_smarthost: 'smtp.qq:465'
smtp_from: '134****626@qq'
smtp_auth_username: '134****626@qq'
smtp_auth_password: 'zzsijsyobcddbaah' # 这个密码需要生成,非QQ密码
smtp_require_tls: false
route:
group_by: ['service','alertname','cluster'] ##根据label进行分组。--cluster可创建集群
group_wait: 30s ##触发告警后,等待30s发送
group_interval: 10s ##两组告警发送的时间间隔
repeat_interval: 1h ##重复告警发送的时间间隔
receiver: 'email' #默认接收者
receivers: ###告警的处理方式email
- name: 'email'
#webhook_configs: ##告警转发到下列url
# - url: 'http://127.0.0.1:5001/'
email_configs: ##告警转发到对应邮箱地址
- to: '134****626@qq'
inhibit_rules: ###添加抑制规则
- source_match: ####根据label匹配源告警
severity: 'critical'
target_match: ####根据label匹配目的告警
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
微信配置:
需要修改route的receiver:
receivers:
- name: 'wechat'
# webhook_configs:
# - url: 'http://127.0.0.1:5001/'
wechat_configs:
- send_resolved: true
corp_id: "ww4489c7c1e62"
#to_party: 部门id
to_user: "WangChao"
agent_id: 1000002
api_secret: "mYYWhtWWF4hZ-eRm_BRlKwNReuCq6m8"
message: '{
{ template "wechat.default.message" . }}'
飞书配置
最大的坑就是飞书传参必须有头部信息,像跳过这个坑就得借助工具了,我用的PrometheusAlert
curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"request example"}}' https://open.feishu/open-apis/bot/v2/hook/f7b50f15-0c78-4378-a74c-185d445f3e92
就是他!!!!!!!!!!!
headers:
Content-Type: 'application/json'
本文标签: 邮箱企业prometheusAlertmanagerqq
版权声明:本文标题:【prometheus+alertmanager+qq邮箱、企业微信、飞书告警管理】 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1727891546a1136384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论