-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update enterprise wechat notify (#854)
update enterprise wechat notify add enterprise wechat app document and test unit for WeChatAppAlertNotifyHandlerImpl --------- Co-authored-by: hudongdong <[email protected]>
- Loading branch information
Showing
10 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: alert_enterprise_wechat_app | ||
title: Alert Enterprise Wechat App notification | ||
sidebar_label: Alert Enterprise Wechat App notification | ||
keywords: [open source monitoring tool, open source alerter, open source Enterprise Wechat App notification] | ||
--- | ||
|
||
> After the threshold is triggered send alarm information and notify the recipient by enterprise WeChat App. | ||
### Operation steps | ||
|
||
1. **【Enterprise Wechat backstage】-> 【App Management】-> 【Create an app】-> 【Set App message】->【Copy AgentId and Secret adding successfully】** | ||
|
||
![email](/img/docs/help/alert-wechat-1.jpg) | ||
|
||
2. **【Alarm notification】->【Add new recipient】 ->【Select Enterprise WeChat App notification method】->【Set Enterprise WeChat ID,Enterprise App ID and Enterprise App Secret 】-> 【Confirm】** | ||
|
||
![email](/img/docs/help/alert-wechat-2.jpg) | ||
|
||
3. **Configure the associated alarm notification strategy⚠️ 【Add new notification strategy】-> 【Associate the recipient just set】-> 【Confirm】** | ||
|
||
> **Note⚠️ Adding a new recipient does not mean that it is effective to receive alarm information. It is also necessary to configure the associated alarm notification strategy, that is, to specify which messages are sent to which recipients.** | ||
![email](/img/docs/help/alert-wechat-3.jpg) | ||
|
||
|
||
### Enterprise WeChat App common issues | ||
|
||
1. Enterprise WeChat App did not receive the alarm notification. | ||
> Please check if the user has application permissions. | ||
> Please check if the enterprise application callback address settings are normal. | ||
> Please check if the server IP is on the enterprise application whitelist. | ||
Other issues can be fed back through the communication group ISSUE! |
34 changes: 34 additions & 0 deletions
34
...h-cn/docusaurus-plugin-content-docs/current/help/alert_enterprise_wechat_app.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: alert_enterprise_wechat_app | ||
title: 企业微信应用告警通知 | ||
sidebar_label: 企业微信应用告警通知 | ||
keywords: [开源告警系统, 开源监控告警系统, 企业微信应用告警通知] | ||
--- | ||
|
||
> 阈值触发后发送告警信息,通过企业微信应用通知到接收人. | ||
### Operation steps | ||
|
||
1. **【企业微信后台管理】-> 【App管理】-> 【创建一个新的应用】-> 【设置应用信息】->【添加成功后复制应用的AgentId和Secret】** | ||
|
||
![email](/img/docs/help/alert-wechat-1.jpg) | ||
|
||
2. **【告警通知】->【新增接收人】 ->【选择企业微信应用通知方式】->【设置企业ID,企业应用id和应用的secret 】-> 【确定】** | ||
|
||
![email](/img/docs/help/alert-wechat-2.jpg) | ||
|
||
3. **配置关联的告警通知策略⚠️ 【新增通知策略】-> 【将刚设置的接收人关联】-> 【确定】** | ||
|
||
> **注意⚠️ 新增了接收人并不代表已经生效可以接收告警信息,还需配置关联的告警通知策略,即指定哪些消息发给哪些接收人。** | ||
![email](/img/docs/help/alert-wechat-3.jpg) | ||
|
||
|
||
### 企业微信应用通知常见问题 | ||
|
||
1. 企业微信应用未收到告警通知. | ||
> 请检查用户是否具有应用程序权限. | ||
> 请检查企业应用程序回调地址设置是否正常. | ||
> 请检查服务器IP是否在企业应用程序白名单上. | ||
其它问题可以通过交流群ISSUE反馈哦! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 46 additions & 9 deletions
55
...dromara/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,59 @@ | ||
package org.dromara.hertzbeat.manager.component.alerter.impl; | ||
|
||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.springframework.web.client.RestTemplate; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.dromara.hertzbeat.common.entity.alerter.Alert; | ||
import org.dromara.hertzbeat.common.entity.manager.NoticeReceiver; | ||
import org.dromara.hertzbeat.common.util.CommonConstants; | ||
import org.dromara.hertzbeat.manager.AbstractSpringIntegrationTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.util.StringUtils; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @description: | ||
* unit test case for WeChatAppAlertNotifyHandlerImpl | ||
* | ||
* | ||
* @create: 2023/04/05 | ||
* @create 2023/04/05 | ||
*/ | ||
public class WeChatAppAlertNotifyHandlerImplTest { | ||
@Slf4j | ||
public class WeChatAppAlertNotifyHandlerImplTest extends AbstractSpringIntegrationTest { | ||
|
||
|
||
@InjectMocks | ||
@Resource | ||
private WeChatAppAlertNotifyHandlerImpl weChatAppAlertNotifyHandler; | ||
|
||
@Mock | ||
private RestTemplate restTemplate; | ||
|
||
@Test | ||
public void send() { | ||
String corpId = System.getenv("CORP_ID"); | ||
String agentId = System.getenv("AGENT_ID"); | ||
String appSecret = System.getenv("APP_SECRET"); | ||
if (!StringUtils.hasText(corpId) || !StringUtils.hasText(agentId) || !StringUtils.hasText(appSecret)) { | ||
log.warn("Please provide environment variables CORP_ID, TG_USER_ID APP_SECRET"); | ||
return; | ||
} | ||
NoticeReceiver receiver = new NoticeReceiver(); | ||
receiver.setId(1L); | ||
receiver.setName("WeChat App 告警"); | ||
receiver.setCorpId(corpId); | ||
receiver.setAgentId(Integer.valueOf(agentId)); | ||
receiver.setAppSecret(appSecret); | ||
Alert alert = new Alert(); | ||
alert.setId(1L); | ||
alert.setTarget("Mock Target"); | ||
Map<String, String> map = new HashMap<>(); | ||
map.put(CommonConstants.TAG_MONITOR_ID, "Mock monitor id"); | ||
map.put(CommonConstants.TAG_MONITOR_NAME, "Mock monitor name"); | ||
alert.setTags(map); | ||
alert.setContent("mock content"); | ||
alert.setPriority((byte) 0); | ||
alert.setLastTriggerTime(System.currentTimeMillis()); | ||
|
||
weChatAppAlertNotifyHandler.send(receiver, alert); | ||
} | ||
|
||
|
||
} |