songquanpeng / message-pusher

搭建专属于你的消息推送服务,支持多种消息推送方式,支持 Markdown,基于 Golang 仅单可执行文件,开箱即用
https://msgpusher.com
MIT License
2.64k stars 395 forks source link

请问接口的webhook提取,构建规则是所有平台通用的吗? #124

Open rebron1900 opened 10 months ago

rebron1900 commented 10 months ago

例行检查

问题描述 经过我的测试,目前在构建规则中只有 contentdescription 两个字段可以识别,其他的都不行,即便能成功提交也接收不到数据,请问这个有具体规范吗?

artalk样本数据:

{
  "notify_subject": "",
  "notify_body": "@测试用户:\n\n测试内容\n\nhttps://127.0.0.1/index.html?atk_comment=1057",
  "comment": {
    "id": 1057,
    "content": "测试内容",
    "user_id": 226,
    "nick": "测试用户",
    "email_encrypted": "654236c1e78i4c09a17c4869c9d43910",
    "link": "https://qwqaq.com",
    "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
    "date": "2022-05-23 17:00:23",
    "is_collapsed": false,
    "is_pending": false,
    "is_pinned": false,
    "is_allow_reply": false,
    "rid": 0,
    "badge_name": "",
    "badge_color": "",
    "visible": true,
    "vote_up": 0,
    "vote_down": 0,
    "page_key": "/index.html",
    "page_url": "https://127.0.0.1/index.html",
    "site_name": "ArtalkDocs"
  },
  "parent_comment": null
}

我的提取规则

{
  "site_name":"comment.site_name",
  "content": "comment.content",
  "nick": "comment.nick",
  "url": "comment.page_url",
  "notify_body": "notify_subject"
}

构建规则

{
  "content": "### 【$site_name】\n\n评论人:$nick\n\n评论:$content\n\n原文链接:[$url]($url)"
}

复现步骤

预期结果

相关截图 如果没有的话,请删除此节。

songquanpeng commented 10 months ago

得看一下实现了,时间太久我有点忘记了

rebron1900 commented 10 months ago

得看一下实现了,时间太久我有点忘记了

期待答复😁

AiTian1211 commented 3 months ago

样本数据: { "receiver": "webhook", "status": "firing", "alerts": [ { "status": "firing", "labels": { "alertname": "ServicePortUnavailable", "group": "elasticsearch", "instance": "192.168.10.55:9200", "job": "blackbox_exporter_tcp", "severity": "warning", "team": "elk" }, "annotations": { "description": "elasticsearch 192.168.10.55:9200 service port is unavailable", "summary": "service port unavailable", "value": "192.168.10.55:9200" }, "startsAt": "2023-07-08T09:16:01.979669601Z", "endsAt": "0001-01-01T00:00:00Z", "generatorURL": "/graph?g0.expr=probe_success%7Binstance%3D~%22%28%5C%5Cd%2B.%29%7B4%7D%5C%5Cd%2B%22%7D+%3D%3D+0&g0.tab=1", "fingerprint": "1e43318d4e7834f1" } ], "groupLabels": { "alertname": "ServicePortUnavailable" }, "commonLabels": { "alertname": "ServicePortUnavailable", "group": "elasticsearch", "instance": "192.168.10.55:9200", "job": "blackbox_exporter_tcp", "severity": "warning", "team": "elk" }, "commonAnnotations": { "description": "elasticsearch 192.168.10.55:9200 service port is unavailable", "summary": "service port unavailable", "value": "192.168.10.55:9200" }, "truncatedAlerts": 0 }

提取规则: {
"title": "${alerts[0].labels.alertname}",
"description": "${alerts[0].annotations.summary}",
"content": {
"告警等级": "${alerts[0].labels.severity}",
"告警类型": "${alerts[0].labels.alertname}",
"告警主机": "${alerts[0].labels.instance}",
"告警详情": "${alerts[0].annotations.description}",
"告警时间": "${alerts[0].startsAt}",
"恢复时间": "${alerts[0].endsAt}"
},
"url": "${alerts[0].generatorURL}"
} 构建规则 {
"title": "${title}",
"description": "告警简述:${description}",
"content": "详情:\n告警等级:${content.告警等级}\n告警类型:${content.告警类型}\n告警主机:${content.告警主机}\n告警详情:${content.告警详情}\n告警时间:${content.告警时间}\n恢复时间:${content.恢复时间}",
"url": "告警链接:${url}"
}

使用的是飞书群机器人通道: https://xxxxx/webhook/043ecff64e724wec9b1d4f4d56862c7f

报错: { "message": "Webhook 提取规则解析失败", "success": false } 能帮看看哪个地方不对吗?