From e8462715cfb60a418347e26f838585bcf4fda40d Mon Sep 17 00:00:00 2001 From: "saimu.msm" Date: Thu, 4 Jul 2024 14:03:44 +0800 Subject: [PATCH] alarm rule url --- .../common/dao/entity/dto/NotificationTemplate.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/NotificationTemplate.java b/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/NotificationTemplate.java index 60be5119e..2502b6839 100644 --- a/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/NotificationTemplate.java +++ b/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/NotificationTemplate.java @@ -58,6 +58,7 @@ public static NotificationTemplate defaultMiniappDingtalkTemplate(TemplateValue template.fieldMap.put("告警触发数值", AlertTemplateField.ALERT_VALUE); template.fieldMap.put("聚合条数", AlertTemplateField.AGGREGATION_NUM); template.fieldMap.put("告警来源", AlertTemplateField.SOURCE_TYPE); + template.fieldMap.put("链接", AlertTemplateField.ruleUrl); if (templateValue != null && StringUtils.isNotEmpty(templateValue.getLogContent())) { template.fieldMap.put("日志内容", AlertTemplateField.LOG_CONTENT); } @@ -90,7 +91,7 @@ public String getTemplateMarkdown(String textTitle) { msg.append("## ").append(textTitle).append(" \n\n\n "); for (Map.Entry entry : this.fieldMap.entrySet()) { AlertTemplateField field = entry.getValue(); - if (field == AlertTemplateField.LINK || field == AlertTemplateField.ruleUrl) { + if (field == AlertTemplateField.LINK) { continue; } else if (field == AlertTemplateField.ALERT_SCOPE || field == AlertTemplateField.alarmTags) { msg.append(String.format("- **%s**: \n\n ", entry.getKey())); @@ -185,7 +186,7 @@ private String getValue(TemplateValue templateValue, AlertTemplateField field, case LINK: // return link; case ruleUrl: - return templateValue.getRuleUrl(); + return buildRuleUrl(templateValue.getRuleUrl(), tagMarkdown); case TENANT: case tenant: return templateValue.getTenant(); @@ -202,6 +203,13 @@ private String getValue(TemplateValue templateValue, AlertTemplateField field, return StringUtils.EMPTY; } + private String buildRuleUrl(String ruleUrl, boolean tagMarkdown) { + if (tagMarkdown) { + return "[告警规则链接](http://roar.alibaba-inc.com/urlRoute.jsp?url=" + ruleUrl + ")"; + } + return ruleUrl; + } + private String buildTagValue(String alarmTags, boolean tagMarkdown) { if (tagMarkdown) { if (StringUtils.isEmpty(alarmTags)) {