【转帖】Prometheus AlertManager 微信报警配置

Prometheus AlertManager 微信报警配置

https://segmentfault.com/a/1190000015400227

改天尝试一下

prometheus

阅读约 5 分钟

Prometheus AlertManager 微信报警配置

alertmanager支持email,webhook等报警源支持,看到可以支持微信报警信息推送觉得有意思把玩一下,alertmanager0.15版本微信报警推送有问题,后来我把版本降到0.14后微信就能正常收到报警信息

微信企业号申请

  • 微信企业号申请地址(https://work.weixin.qq.com/)
  • 进入企业号注册页面,一些信息可以随便填写,但是管理员信息必须真实有效
  • 创建应用("企业应用"-->"创建应用")

Prometheus中AlertManager配置

  • Prometheus AlertManager配置如下,alerting 与 global同级
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - localhost:9093
  • rules配置文件加入到Prometheus配置文件中
rule_files:
   - "/usr/local/prometheus/rules.yml"

Prometheus rules配置

  • 创建rule.yml文件
  • 根据需求添加报警规则
groups:
- name: prometheus_go_goroutines
  rules:
  - alert: go_goroutines_numbers
    expr: go_goroutines > 45
    for: 15s
    annotations:
      summary: "prometheus的gorotine数据超过40!"

Prometheus AlertManager配置

  • alertmanager 配置文件,加入微信配置信息
global:
  resolve_timeout: 2m
  wechat_api_url: ‘https://qyapi.weixin.qq.com/cgi-bin/‘
  wechat_api_secret: ‘xxx‘
  wechat_api_corp_id: ‘xxx‘

route:
  group_by: [‘alertname‘]
  group_wait: 10s
  group_interval: 10s
  repeat_interval: 1h
  receiver: ‘wechat‘
receivers:
- name: ‘wechat‘
  wechat_configs:
  - send_resolved: true
    to_party: ‘1‘
    agent_id: ‘1000002‘

wechat_api_urlwechat对外接口https://qyapi.weixin.qq.com/cgi-bin/
wechat_api_secret: 企业微信("企业应用"-->"自定应用"[Prometheus]--> "Secret") Prometheus是本人自创建应用名称
wechat_api_corp_id: 企业信息("我的企业"--->"CorpID"[在底部])
to_party1值是组的ID 你可通过链接去定制报警信息接收人或者组(https://work.weixin.qq.com/ap...
agent_id: 企业微信("企业应用"-->"自定应用"[Prometheus]--> "AgentId") Prometheus是本人自创建应用名称

异常列表

报警信息推企业微信异常 invalid APISecret for CorpID

异常信息如下:

level=error ts=2019-06-20T08:33:42.779286895Z caller=dispatch.go:264 component=dispatchermsg="Notify for alerts failed" num_alerts=1 err="cancelling notify retry for \"wechat\"due to unrecoverable error: invalid APISecret for CorpID: xxxxxxxxxxx"
  • 根据官方文档和上述文档内容配置alertmanager报警器推送源,在推送报invalid apisecret,查看源码和官方文档发现wechat_config会继续global wechat配置,但是经过测试 wechat_config没有继承global wechat的配置所以才会出现上述异常
  • 解决方案: 将global wechat信息在wechat_config中重新配置即可正常推送信息
  • 以上异常情况应该与alertmanager版本相关,本人测试时没有碰到,如有碰到可根据以上提供信息修改配置测试
  • 感谢上善若水提供异常信息和解决方案

本人微信: 375419830

原文地址:https://www.cnblogs.com/jinanxiaolaohu/p/12216491.html

时间: 2024-08-29 19:18:01

【转帖】Prometheus AlertManager 微信报警配置的相关文章

Prometheus + AlertManager 邮件报警

安装 wget https://github.com/prometheus/alertmanager/releases/download/v0.13.0/alertmanager-0.13.0.linux-amd64.tar.gz tar -axvf alertmanager-0.13.0.linux-amd64.tar.gz 配置AlertManager AlertManager安装目录下有默认的simple.yml文件,可以创建新的配置文件,在启动时指定即可. 配置文件如下: global:

k8s node alertmanager监控报警配置方法

概述 节点本身的监控主要监控CPU.内存.磁盘IO.文件系统可用空间即可.比如,对于使用来prometheus的alertmanager来做node报警,rules配置可以参考如下点进行配置即可. 说明 不同的node-exporter版本,对应的metrics也不一样,需要自己对照更改一下. CPU监控 (1 - avg(irate(node_cpu{mode="idle"}[10m])) by (instance)) * 100 < 90 内存监控 ((node_memory

prometheus-operator 配置企业微信报警

prometheus-operator 配置企业微信报警1.安装prometheus-operator,具体安装步骤链接:https://www.qikqiak.com/k8s-book/docs/58.Prometheus%20Operator.html2.修改配置文件/root/prometheus-operator/kube-prometheus/manifestsvim alertmanager.yamlglobal:resolve_timeout: 60msmtp_smarthost:

配置zabbix通过微信报警企业微信报警

如今势态: 报警的方式可谓是八仙过海各显神通,如电话报警,短信报警,邮件报警,QQ报警,微信报警等等. 电话报警:一般都是使用别的平台的工具,平台给你提供一个接口供你使用,大多数为限量收费款 短信报警:一般是服务器安装串口GSM短信猫(也有其他平台提供这种接口),zabbix可以使用他来发送短信通知给管理员 邮件报警:一般是在server端安装邮件的客户端如sendEmail等,写脚本给zabbix进行调用,触发后发邮件给管理员 Q Q 报警:一般使用Mojo-Webqq的perl模板和cpan

zabbix详解:(五)添加微信告警配置

新时代,新事物,前两年大伙还在想着怎么用短信告警比较合理的时候,这回微信告警已经悄悄进入人们视线,邮件报警就变得落后了,甚至有些大牛公司,微信告警还能做成图形告警,把监控图形也发上去,想当NB的架构. 添加微信告警配置: 微信告警的原理其实是利用微信企业号接口,把告警信息发送到微信企业号发布内容,然后关注这个企业号的微信用户就能收到微信信息了,达到了微信告警的结果. 所以我们要做的事情是: 第一,创建一个微信公众号 第二,写一个调用微信公众号接口的脚本 第三,在zabbix_web配置相关信息

zabbix-3.0.1 添加微信报警

现实生产环境中,我们已经使用过邮件和短信接收zabbix报警信息,但是邮件的延迟是比较高的,外包公司的短信接口又太贵,复杂环境中使用短息报警会使运维成本增加很多.微信提供了很好的第三方接口,我们可以利用微信报警以求降低运维成本. 企业微信参考文档:https://work.weixin.qq.com/api/doc 一.微信公众号用户权限设置 1. 申请微信公众号(企业号) https://mp.weixin.qq.com/ 2. 审核完成后,需要在手动添加部门.管理员和被发送成员的信息. 3.

zabbix微信报警设置

# Zabbix-Alert-WeChat # zabbix微信报警 ### 需要具备一下条件 * 注册微信企业号(团队类型) [点击注册](https://qy.weixin.qq.com/) #### 安装simplejson 3.8.2 ```bash wget https://pypi.python.org/packages/f0/07/26b519e6ebb03c2a74989f7571e6ae6b82e9d7d81b8de6fcdbfc643c7b58/simplejson-3.8.

ZABBIX 微信报警 插件(python无图)

ZABBIX可以实现短信.邮件.微信等各种报警,这三种基本大家都很熟悉, 现在基于微信写py,感觉钉钉的团队是从微信出来的,变量都不改,太懒了,说可以实现微信报警苍老师说过:Life is short,you need python! 1 微信配置 2 程序配置 3 ZABBIX配置 4 效果展现 5 docker环境修改 1.1.1 部门设置 1.1.2 应用设置 1.1.3 权限管理 1.1 注册安装 3.1 报警媒介类型 3.2 配置用户 3.3 动作设置 1 微信配置 微信公众号官网:h

实战Nagios网络监控(3)——Nagios 微信报警

1. 下载微信公众平台私有接口 # yum install -y git # git clone https://github.com/lealife/WeiXin-Private-API 2. 修改微信公众平台私有接口代码,以配合 nagios 报警 # cp -r WeiXin-Private-API /usr/local/nagios/libexec/weixin # chown -R nagios.nagios /usr/local/nagios/libexec/weixin # cd