INFO-钉钉webhook报警配置示例

适用模块

报警组件 easyalert

具体说明

钉钉机器人告警信息发至群组

使用示例

一、获取群机器人信息
1、群管理添加机器人
2、查看机器人webhook 地址

INFO-钉钉webhook报警配置示例 - 图1
INFO-钉钉webhook报警配置示例 - 图2
INFO-钉钉webhook报警配置示例 - 图3

二、验证是可否用

参照:https://open.dingtalk.com/document/robots/custom-robot-access

easyalert节点执行(替换实际url)

curl 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx' \
 -H 'Content-Type: application/json' \
 -d '{"msgtype": "text","text": {"content":"我就是我, 是不一样的烟火"}}'

三、easyops advanced配置

1、template.channel.conf:

4 = {
  id = 4
  name = popo
  clz = "dd-webhook"
  text = "钉钉-webhook"
  enable = true
  channelIdentification = 'dingding-webhook'
  contentType = 'text'
}

2、添加template.plugin_dd-webhook.conf string类型

下属配置url换成webhook 地址

name = "dd-webhook"
post = true
url = "https://oapi.dingtalk.com/robot/send?access_token=xxx"
//
setting = {
  wrap = "\n"
}
//
command = """
  function replace(String a){
    if(a == null){
      return a;
    } else {
      return org.apache.commons.lang3.StringUtils.replace(a, wrap, "\\n");
    }
  }
  content = replace(content);
"""
header = {
}

param = {
}

body = {
  "msgtype": "text",
  "text": {
    "content": "#{content}"
  }
}

3、更新当前配置组-批量应用该版本-同步配置并重启服务

INFO-钉钉webhook报警配置示例 - 图4


作者:林帅