Skip to content

Commit

Permalink
alarm rule url
Browse files Browse the repository at this point in the history
  • Loading branch information
saimu.msm committed Jul 4, 2024
1 parent 3df55b7 commit e846271
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -90,7 +91,7 @@ public String getTemplateMarkdown(String textTitle) {
msg.append("## ").append(textTitle).append(" \n\n\n ");
for (Map.Entry<String, AlertTemplateField> 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()));
Expand Down Expand Up @@ -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();
Expand All @@ -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)) {
Expand Down

0 comments on commit e846271

Please sign in to comment.