Replies: 1 comment
-
看了源码,没办法替换content的内容,所以如果需要使用企业微信的webhook,只能改代码,具体的代码逻辑: /**
* set body params
*/
private void setMsgInRequestBody(String msg) {
try {
ObjectNode objectNode = JSONUtils.createObjectNode();
if (StringUtils.isNotBlank(bodyParams)) {
objectNode = JSONUtils.parseObject(bodyParams);
}
// set msg content field
objectNode.put(contentField, msg); // 这里只是把内容拼到body里面,如果要解决的话,这里应该使用变量替换的方式更合理(个人感觉)
StringEntity entity = new StringEntity(JSONUtils.toJsonString(objectNode), DEFAULT_CHARSET);
((HttpPost) httpRequest).setEntity(entity);
} catch (Exception e) {
log.error("send http alert msg exception : {}", e.getMessage());
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
官方文档中,关于http 告警的说明不太清楚,不知道怎么将告警消息传递进去。
企业微信机器人webhook的通知内容类似这样:
我想把content替换成系统的告警内容,该如何配置?
Beta Was this translation helpful? Give feedback.
All reactions