INFO-飞书webhook插件配置

适用模块

报警组件 easyalert

具体说明

配置飞书webhook告警-发至群组

使用示例

1、添加机器人入群并复制地址
https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxx

INFO-飞书webhook插件配置 - 图1

2、在插件配置(template.plugin=9.conf)中需要提供此变量,即url = 上述参数

####**1. 查询当前插件配置**
--查询SQL
use easyalert;
select * from channel;

INFO-飞书webhook插件配置 - 图2

若当前存在8910渠道需特别注意:
- 默认情况下8910渠道分别为企业微信,钉钉,飞书的渠道配置,由于报警系统设计缺陷,只有10个渠道。
- 此文档,飞书webhook选择可渠道5,因为一般渠道10会被飞书插件(自建应用)占用
2. EasyOps配置参数

#####**2.1 接口说明**
**Content-Type:**application/json

- 明确调用频次限制
- 明确消息长度限制
- 明确测试环境配置,生产环境参数配置

**请求样例**
curl -X POST -H "Content-Type: application/json" \
   -d '{"msg_type":"text","content":{"text":"request example"}}' \
  https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxx
配置项组:advanced
增加 template.channel.conf 类型string

1 = {
  id = 5
  name = stone
  clz = "feishu-webhook"
  text = "飞书-webhook"
  enable = true
}

增加 template.plugin_feishu_webhook.conf  类型string

name = "feishu-webhook"
post = true
url = "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx(替换)"
//
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 = {
  "msg_type": "text",
  "content": {
    "text": "#{content}"
  }
}

EasyAlert同步配置重启,并重启
3、若遇到以下报错(easyalert2.4.0.1以下版本)复制plugin_feishu_webhook.confplugins重启alert组件
easybdms@bigdata-demo9:/usr/easyops/easy_alert/default_easy_alert_server/current/conf$ pwd
/usr/easyops/easy_alert/default_easy_alert_server/current/conf
easybdms@bigdata-demo9:/usr/easyops/easy_alert/default_easy_alert_server/current/conf$ cp plugin_feishu_webhook.conf ../package/easy_alert-server-2.4.0/plugins/

INFO-飞书webhook插件配置 - 图3


作者:林帅