diff --git a/alerter/src/main/resources/alerter_en_US.properties b/alerter/src/main/resources/alerter_en_US.properties index 2b22b3e7085..938da98ac31 100644 --- a/alerter/src/main/resources/alerter_en_US.properties +++ b/alerter/src/main/resources/alerter_en_US.properties @@ -19,6 +19,7 @@ alerter.notify.title = HertzBeat Alert Notify alerter.notify.target = Monitor Target alerter.notify.monitorId = Monitor ID alerter.notify.monitorName = Monitor Name +alerter.notify.monitorHost = Monitor Host alerter.notify.priority = Alert Priority alerter.notify.triggerTime = Alert Trigger Time alerter.notify.restoreTime = Alert Restore Time diff --git a/alerter/src/main/resources/alerter_zh_CN.properties b/alerter/src/main/resources/alerter_zh_CN.properties index cdf213f7f20..b1f11e284de 100644 --- a/alerter/src/main/resources/alerter_zh_CN.properties +++ b/alerter/src/main/resources/alerter_zh_CN.properties @@ -19,6 +19,7 @@ alerter.notify.title = HertzBeat告警通知 alerter.notify.target = 告警目标对象 alerter.notify.monitorId = 所属监控任务ID alerter.notify.monitorName = 所属任务名称 +alerter.notify.monitorHost = 所属任务主机 alerter.notify.priority = 告警级别 alerter.notify.triggerTime = 告警触发时间 alerter.notify.restoreTime = 告警恢复时间 diff --git a/common/src/main/java/org/dromara/hertzbeat/common/constants/CommonConstants.java b/common/src/main/java/org/dromara/hertzbeat/common/constants/CommonConstants.java index 02f43b4d39c..a1f8c257340 100644 --- a/common/src/main/java/org/dromara/hertzbeat/common/constants/CommonConstants.java +++ b/common/src/main/java/org/dromara/hertzbeat/common/constants/CommonConstants.java @@ -239,6 +239,11 @@ public interface CommonConstants { */ String TAG_MONITOR_NAME = "monitorName"; + /** + * 内有标签: monitorHost 任务主机 + */ + String TAG_MONITOR_HOST = "monitorHost"; + /** * 内有标签: policyId 告警阈值规则ID */ diff --git a/common/src/main/java/org/dromara/hertzbeat/common/entity/manager/NoticeTemplate.java b/common/src/main/java/org/dromara/hertzbeat/common/entity/manager/NoticeTemplate.java index c8f02cd1732..4fcb6766a5f 100644 --- a/common/src/main/java/org/dromara/hertzbeat/common/entity/manager/NoticeTemplate.java +++ b/common/src/main/java/org/dromara/hertzbeat/common/entity/manager/NoticeTemplate.java @@ -86,6 +86,7 @@ public class NoticeTemplate { "${targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}", accessMode = READ_WRITE) diff --git a/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/AbstractAlertNotifyHandlerImpl.java b/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/AbstractAlertNotifyHandlerImpl.java index 2008ef5e0d5..8035df24c3c 100644 --- a/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/AbstractAlertNotifyHandlerImpl.java +++ b/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/AbstractAlertNotifyHandlerImpl.java @@ -79,6 +79,10 @@ protected String renderContent(NoticeTemplate noticeTemplate, Alert alert) throw if (monitorName != null) { model.put("monitorName", monitorName); } + String monitorHost = alert.getTags().get(CommonConstants.TAG_MONITOR_HOST); + if (monitorHost != null) { + model.put("monitorHost", monitorHost); + } String thresholdId = alert.getTags().get(CommonConstants.TAG_THRESHOLD_ID); if (thresholdId != null) { model.put("thresholdId", thresholdId); @@ -88,6 +92,7 @@ protected String renderContent(NoticeTemplate noticeTemplate, Alert alert) throw model.put("status", alert.getStatus()); model.put("monitorIdLabel", bundle.getString("alerter.notify.monitorId")); model.put("monitorNameLabel", bundle.getString("alerter.notify.monitorName")); + model.put("monitorHostLabel", bundle.getString("alerter.notify.monitorHost")); model.put("target", alert.getTarget()); model.put("targetLabel", bundle.getString("alerter.notify.target")); model.put("priorityLabel", bundle.getString("alerter.notify.priority")); diff --git a/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/DbAlertStoreHandlerImpl.java b/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/DbAlertStoreHandlerImpl.java index 19d698cc7ce..45e9903336b 100644 --- a/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/DbAlertStoreHandlerImpl.java +++ b/manager/src/main/java/org/dromara/hertzbeat/manager/component/alerter/impl/DbAlertStoreHandlerImpl.java @@ -59,6 +59,9 @@ public void store(Alert alert) { if (!tags.containsKey(CommonConstants.TAG_MONITOR_NAME)) { tags.put(CommonConstants.TAG_MONITOR_NAME, monitor.getName()); } + if (!tags.containsKey(CommonConstants.TAG_MONITOR_HOST)) { + tags.put(CommonConstants.TAG_MONITOR_HOST, monitor.getHost()); + } if (monitor.getStatus() == CommonConstants.UN_MANAGE_CODE) { // When monitoring is not monitored, ignore and silence its alarm messages return; diff --git a/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MailServiceImpl.java b/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MailServiceImpl.java index 0c58c5041f6..66e5fb13978 100644 --- a/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MailServiceImpl.java +++ b/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MailServiceImpl.java @@ -68,20 +68,25 @@ public String buildAlertHtmlTemplate(final Alert alert, NoticeTemplate noticeTem Configuration cfg = new Configuration(Configuration.VERSION_2_3_0); String monitorId = null; String monitorName = null; + String monitorHost = null; if (alert.getTags() != null) { monitorId = alert.getTags().get(CommonConstants.TAG_MONITOR_ID); monitorName = alert.getTags().get(CommonConstants.TAG_MONITOR_NAME); + monitorHost = alert.getTags().get(CommonConstants.TAG_MONITOR_HOST); } monitorId = monitorId == null ? "External Alarm, No ID" : monitorId; monitorName = monitorName == null ? "External Alarm, No Name" : monitorName; + monitorHost = monitorHost == null ? "External Alarm, No Host" : monitorHost; // Introduce context parameters to render pages Map model = new HashMap<>(16); model.put("nameTitle", bundle.getString("alerter.notify.title")); model.put("nameMonitorId", bundle.getString("alerter.notify.monitorId")); model.put("nameMonitorName", bundle.getString("alerter.notify.monitorName")); + model.put("nameMonitorHost", bundle.getString("alerter.notify.monitorHost")); model.put("target", alert.getTarget()); model.put("monitorId", monitorId); model.put("monitorName", monitorName); + model.put("monitorHost", monitorHost); model.put("nameTarget", bundle.getString("alerter.notify.target")); model.put("nameConsole", bundle.getString("alerter.notify.console")); model.put("namePriority", bundle.getString("alerter.notify.priority")); diff --git a/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/NoticeConfigServiceImpl.java b/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/NoticeConfigServiceImpl.java index 566324732e5..39d71ca15ef 100644 --- a/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/NoticeConfigServiceImpl.java +++ b/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/NoticeConfigServiceImpl.java @@ -247,6 +247,7 @@ public boolean sendTestMsg(NoticeReceiver noticeReceiver) { Map tags = new HashMap<>(8); tags.put(CommonConstants.TAG_MONITOR_ID, "100"); tags.put(CommonConstants.TAG_MONITOR_NAME, "100Name"); + tags.put(CommonConstants.TAG_MONITOR_HOST, "127.0.0.1"); tags.put(CommonConstants.TAG_THRESHOLD_ID, "200"); Alert alert = new Alert(); alert.setTags(tags); diff --git a/manager/src/main/resources/templates/1-EmailTemplate.html b/manager/src/main/resources/templates/1-EmailTemplate.html index 785836e3208..b54ae2953c4 100644 --- a/manager/src/main/resources/templates/1-EmailTemplate.html +++ b/manager/src/main/resources/templates/1-EmailTemplate.html @@ -658,6 +658,17 @@ ${monitorName} + + + + ${nameMonitorHost} + + + + ${monitorHost} + + @@ -665,8 +676,8 @@ ${namePriority} - ${priority} + + ${priority} diff --git a/manager/src/main/resources/templates/10-WeWorkAppTemplate.txt b/manager/src/main/resources/templates/10-WeWorkAppTemplate.txt index 095e51c65e9..62f7643591e 100644 --- a/manager/src/main/resources/templates/10-WeWorkAppTemplate.txt +++ b/manager/src/main/resources/templates/10-WeWorkAppTemplate.txt @@ -2,6 +2,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/main/resources/templates/11-HuaweiCloudSmnTemplate.txt b/manager/src/main/resources/templates/11-HuaweiCloudSmnTemplate.txt index 095e51c65e9..62f7643591e 100644 --- a/manager/src/main/resources/templates/11-HuaweiCloudSmnTemplate.txt +++ b/manager/src/main/resources/templates/11-HuaweiCloudSmnTemplate.txt @@ -2,6 +2,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/main/resources/templates/12-ServerChanTemplate.txt b/manager/src/main/resources/templates/12-ServerChanTemplate.txt index c51b2add44c..0336291db5a 100644 --- a/manager/src/main/resources/templates/12-ServerChanTemplate.txt +++ b/manager/src/main/resources/templates/12-ServerChanTemplate.txt @@ -2,6 +2,7 @@ ##### **${targetLabel}** : ${target} <#if (monitorId??)>##### **${monitorIdLabel}** : ${monitorId} <#if (monitorName??)>##### **${monitorNameLabel}** : ${monitorName} +<#if (monitorHost??)>##### **${monitorHostLabel}** : ${monitorHost} ##### **${priorityLabel}** : ${priority} ##### **${triggerTimeLabel}** : ${triggerTime} <#if (restoreTimeLabel??)>##### **${restoreTimeLabel}** : ${restoreTime} diff --git a/manager/src/main/resources/templates/4-WeWorkRobotTemplate.txt b/manager/src/main/resources/templates/4-WeWorkRobotTemplate.txt index 095e51c65e9..62f7643591e 100644 --- a/manager/src/main/resources/templates/4-WeWorkRobotTemplate.txt +++ b/manager/src/main/resources/templates/4-WeWorkRobotTemplate.txt @@ -2,6 +2,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/main/resources/templates/5-DingTalkRobotTemplate.txt b/manager/src/main/resources/templates/5-DingTalkRobotTemplate.txt index c51b2add44c..0336291db5a 100644 --- a/manager/src/main/resources/templates/5-DingTalkRobotTemplate.txt +++ b/manager/src/main/resources/templates/5-DingTalkRobotTemplate.txt @@ -2,6 +2,7 @@ ##### **${targetLabel}** : ${target} <#if (monitorId??)>##### **${monitorIdLabel}** : ${monitorId} <#if (monitorName??)>##### **${monitorNameLabel}** : ${monitorName} +<#if (monitorHost??)>##### **${monitorHostLabel}** : ${monitorHost} ##### **${priorityLabel}** : ${priority} ##### **${triggerTimeLabel}** : ${triggerTime} <#if (restoreTimeLabel??)>##### **${restoreTimeLabel}** : ${restoreTime} diff --git a/manager/src/main/resources/templates/6-FlyBookRobotTemplate.txt b/manager/src/main/resources/templates/6-FlyBookRobotTemplate.txt index 33d0cd3fc60..d4fedd5bfd3 100644 --- a/manager/src/main/resources/templates/6-FlyBookRobotTemplate.txt +++ b/manager/src/main/resources/templates/6-FlyBookRobotTemplate.txt @@ -1,6 +1,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/main/resources/templates/7-TelegramBotTemplate.txt b/manager/src/main/resources/templates/7-TelegramBotTemplate.txt index 095e51c65e9..62f7643591e 100644 --- a/manager/src/main/resources/templates/7-TelegramBotTemplate.txt +++ b/manager/src/main/resources/templates/7-TelegramBotTemplate.txt @@ -2,6 +2,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/main/resources/templates/8-SlackTemplate.txt b/manager/src/main/resources/templates/8-SlackTemplate.txt index 4b22b840808..70ff47292e2 100644 --- a/manager/src/main/resources/templates/8-SlackTemplate.txt +++ b/manager/src/main/resources/templates/8-SlackTemplate.txt @@ -2,6 +2,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/main/resources/templates/9-DiscordBotTemplate.txt b/manager/src/main/resources/templates/9-DiscordBotTemplate.txt index 33d0cd3fc60..d4fedd5bfd3 100644 --- a/manager/src/main/resources/templates/9-DiscordBotTemplate.txt +++ b/manager/src/main/resources/templates/9-DiscordBotTemplate.txt @@ -1,6 +1,7 @@ ${targetLabel} : ${target} <#if (monitorId??)>${monitorIdLabel} : ${monitorId} <#if (monitorName??)>${monitorNameLabel} : ${monitorName} +<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} ${priorityLabel} : ${priority} ${triggerTimeLabel} : ${triggerTime} <#if (restoreTimeLabel??)>${restoreTimeLabel} : ${restoreTime} diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java index 147d74199c1..00aeb293c8a 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DingTalkRobotAlertNotifyHandlerImplTest.java @@ -40,6 +40,7 @@ void send() { "##### **${targetLabel}** : ${target}\n" + "<#if (monitorId??)>##### **${monitorIdLabel}** : ${monitorId} \n" + "<#if (monitorName??)>##### **${monitorNameLabel}** : ${monitorName} \n" + + "<#if (monitorHost??)>##### **${monitorHostLabel}** : ${monitorHost} \n" + "##### **${priorityLabel}** : ${priority}\n" + "##### **${triggerTimeLabel}** : ${triggerTime}\n" + "##### **${contentLabel}** : ${content}"); @@ -49,6 +50,7 @@ void send() { Map map = new HashMap<>(); map.put(CommonConstants.TAG_MONITOR_ID, "Mock monitor id"); map.put(CommonConstants.TAG_MONITOR_NAME, "Mock monitor name"); + map.put(CommonConstants.TAG_MONITOR_HOST, "Mock monitor Host"); alert.setTags(map); alert.setContent("mock content"); alert.setPriority((byte) 0); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java index 2f9fc81ad99..605f2972b3e 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/DiscordBotAlertNotifyHandlerImplTest.java @@ -43,6 +43,7 @@ void send() { noticeTemplate.setContent("${targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}"); @@ -51,7 +52,8 @@ void send() { alert.setTarget("Mock Target"); var map = Map.of( CommonConstants.TAG_MONITOR_ID, "Mock monitor id", - CommonConstants.TAG_MONITOR_NAME, "Mock monitor name" + CommonConstants.TAG_MONITOR_NAME, "Mock monitor name", + CommonConstants.TAG_MONITOR_HOST, "Mock monitor host" ); alert.setTags(map); alert.setContent("mock content"); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java index 035ac914341..1176bfb7c43 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImplTest.java @@ -39,6 +39,7 @@ void send() { noticeTemplate.setContent("{targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}"); @@ -48,6 +49,7 @@ void send() { Map map = new HashMap<>(); map.put(CommonConstants.TAG_MONITOR_ID, "Mock monitor id"); map.put(CommonConstants.TAG_MONITOR_NAME, "Mock monitor name"); + map.put(CommonConstants.TAG_MONITOR_HOST, "Mock monitor host"); alert.setTags(map); alert.setContent("mock content"); alert.setPriority((byte) 0); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java index 915c3deb5dd..3e8cd3e6c50 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/HuaweiCloudSmnAlertNotifyHandlerImplTest.java @@ -79,6 +79,7 @@ void send() throws InterruptedException { "${targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}"); @@ -87,7 +88,8 @@ void send() throws InterruptedException { alert.setTarget("Mock Target"); var map = Map.of( CommonConstants.TAG_MONITOR_ID, "Mock monitor id", - CommonConstants.TAG_MONITOR_NAME, "Mock monitor name" + CommonConstants.TAG_MONITOR_NAME, "Mock monitor name", + CommonConstants.TAG_MONITOR_HOST, "Mock monitor host" ); alert.setTags(map); alert.setContent("mock content"); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java index 28eabeb9929..d62c4394ebc 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/SlackAlertNotifyHandlerImplTest.java @@ -46,12 +46,14 @@ void send() { "${targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}"); var map = Map.of( CommonConstants.TAG_MONITOR_ID, "Mock monitor id", - CommonConstants.TAG_MONITOR_NAME, "Mock monitor name" + CommonConstants.TAG_MONITOR_NAME, "Mock monitor name", + CommonConstants.TAG_MONITOR_HOST, "Mock monitor host" ); alert.setTags(map); alert.setContent("mock content"); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java index d62d288c71c..d77aa4ad2b3 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/TelegramBotAlertNotifyHandlerImplTest.java @@ -47,12 +47,14 @@ void send() { "${targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}"); Map map = new HashMap<>(); map.put(CommonConstants.TAG_MONITOR_ID, "Mock monitor id"); map.put(CommonConstants.TAG_MONITOR_NAME, "Mock monitor name"); + map.put(CommonConstants.TAG_MONITOR_HOST, "Mock monitor host"); alert.setTags(map); alert.setContent("mock content"); alert.setPriority((byte) 0); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java index 27e4d059bc8..db94fe66c0e 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeChatAppAlertNotifyHandlerImplTest.java @@ -52,6 +52,7 @@ public void send() { Map map = new HashMap<>(); map.put(CommonConstants.TAG_MONITOR_ID, "Mock monitor id"); map.put(CommonConstants.TAG_MONITOR_NAME, "Mock monitor name"); + map.put(CommonConstants.TAG_MONITOR_HOST, "Mock monitor host"); alert.setTags(map); alert.setContent("mock content"); alert.setPriority((byte) 0); diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java index 68f48ab2f45..994665e7e3f 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/component/alerter/impl/WeWorkRobotAlertNotifyHandlerImplTest.java @@ -43,12 +43,14 @@ void send() { "${targetLabel} : ${target}\n" + "<#if (monitorId??)>${monitorIdLabel} : ${monitorId} \n" + "<#if (monitorName??)>${monitorNameLabel} : ${monitorName} \n" + + "<#if (monitorHost??)>${monitorHostLabel} : ${monitorHost} \n" + "${priorityLabel} : ${priority}\n" + "${triggerTimeLabel} : ${triggerTime}\n" + "${contentLabel} : ${content}"); Map map = new HashMap<>(); map.put(CommonConstants.TAG_MONITOR_ID, "Mock monitor id"); map.put(CommonConstants.TAG_MONITOR_NAME, "Mock monitor name"); + map.put(CommonConstants.TAG_MONITOR_HOST, "Mock monitor host"); alert.setTags(map); alert.setContent("mock content"); alert.setPriority((byte) 0);