Alertmanager 钉钉报警04

IT
IT
IT
285
文章
1
评论
2020年3月23日12:07:26 评论 99 2475字阅读8分15秒

配置文件

  • alertmanager的webhook集成了钉钉报警,所以他不是本来就有的。钉钉对格式要求很严格,一会还需要使用插件进行格式转换。
    此处为隐藏的内容!
    登录后方可查看!
[root@iZ2ze4v2sdd3v6w7w8doecZ alertmanager]# /usr/local/prometheus/alertmanager/amtool check-config /usr/local/prometheus/alertmanager/alertmanager.yml
Checking '/usr/local/prometheus/alertmanager/alertmanager.yml'  SUCCESS
Found:
 - global config
 - route
 - 0 inhibit rules
 - 1 receivers
 - 0 templates

创建机器人见官方文档https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq

先测试机器人能不能正常使用

  • 为避免出错,请将以下命令直接复制到命令行,再将xxxxxxxx替换为真实access_token;若测试出错,请检查复制的命令是否和测试命令一致,多特殊字符会报错
curl 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx' \
   -H 'Content-Type: application/json' \
   -d '{"msgtype": "text",
        "text": {
             "content": "我就是我, 是不一样的烟火"
        }
		}'

Alertmanager 钉钉报警04

将钉钉接入 Prometheus AlertManager WebHook

  • 使用docker镜像
[root@iZ2ze4v2sdd3v6w7w8doecZ ~]# yum install docker-ce -y
[root@iZ2ze4v2sdd3v6w7w8doecZ ~]# systemctl start docker
[root@iZ2ze4v2sdd3v6w7w8doecZ ~]# systemctl enable docker
  • 下载并启动钉钉镜像
[root@iZ2ze4v2sdd3v6w7w8doecZ home]# docker pull timonwong/prometheus-webhook-dingtalk:v0.3.0
v0.3.0: Pulling from timonwong/prometheus-webhook-dingtalk
Image docker.io/timonwong/prometheus-webhook-dingtalk:v0.3.0 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
aab39f0bc16d: Already exists
a3ed95caeb02: Already exists
2cd9e239cea6: Already exists
2e9091ef5cc7: Already exists
7e999a8b25ab: Already exists
Digest: sha256:88d8b9a50c6fb70fd227ef5dc5465786b9c97cdd81c704a78d687ce9efe30e03
Status: Image is up to date for timonwong/prometheus-webhook-dingtalk:v0.3.0
docker.io/timonwong/prometheus-webhook-dingtalk:v0.3.0
[root@10 alertmanager]# docker run -d --restart always -p 8060:8060 timonwong/prometheus-webhook-dingtalk:v0.3.0 --ding.profile="webhook=https://oapi.dingtalk.com/robot/send?access_token=3880d8ee82bcf347ffvfv6d369c565b178e8699c3d5732bb83859babd179d72c639a8"

注意:http://localhost:8060/dingtalk/webhook1/send ,其中webhook1,一定是当时使用docker运行prometheus-webhook-dingtalk容器指定钉钉接口参数的变量:webhook1,如下:webhook1

--ding.profile="webhook1=https://oapi.dingtalk.com/robot/send?access_token=XXXXXX"

  • 重新启动服务
[root@iZ2ze4v2sdd3v6w7w8doecZ ~]#  systemctl restart alertmanager.service
  • 坐等报警

Alertmanager 钉钉报警04

 

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年3月23日12:07:26
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
完全删除zabbix zabbix

完全删除zabbix

停止服务 $ sudo systemctl stop zabbix-agent.service 简单直接暴力 $ sudo find / -name zabbix-agent | xargs rm -...