欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 八卦 > 使用钉群发送告警通知

使用钉群发送告警通知

2024/10/24 7:22:34 来源:https://blog.csdn.net/qq_42910468/article/details/141390789  浏览:    关键词:使用钉群发送告警通知

创建钉群,添加机器人

创建群

c115ce4541f97ff061dc8b197bdc3c06

添加机器人并设置信息

需要注意的是设置“安全设置”时如果使用自定义关键词方式,那设置的内容必须要包含告警消息的内容

ddd594aef078160ba4adcd349ab4ef5b

代码

模拟http请求发送通知

    /*** @param content 消息内容* @param webhook 设置告警通知的群中机器人的webhook地址* @author Czw* @date 2024/08/21*/ 
private static void sendWechatMsg(String content, String webhook) {HttpHeaders headers = new HttpHeaders();// jsonheaders.setContentType(MediaType.APPLICATION_JSON_UTF8);WeChatMsg weChatMsg = new WeChatMsg();// 设置消息类型weChatMsg.setMsgtype("text");// 设置消息内容weChatMsg.setText(new WeChatMsg.Markdown(content, Arrays.asList(// 设置艾特对应人的手机号,可以做成配置添加"1980790****","@all")));String jsonString = JSONObject.toJSONString(weChatMsg);HttpEntity<String> requestEntity = new HttpEntity<>(jsonString, headers);String url = webhook;ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, requestEntity, String.class);String responseBody = responseEntity.getBody();log.info("发送消息: Req:{} Resp:{}", jsonString, responseBody);}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com