From 91ac0d4f6ee2319a11eeb5ac547f318d9e9298f1 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Fri, 7 Jun 2024 08:44:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[bug]=EF=BC=9Afix=20alert=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alert/reduce/AlarmConvergeReduce.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java index b2c13509458..6004d5b3ca3 100644 --- a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java +++ b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java @@ -17,10 +17,7 @@ package org.apache.hertzbeat.alert.reduce; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import org.apache.hertzbeat.alert.dao.AlertConvergeDao; import org.apache.hertzbeat.common.cache.CacheFactory; @@ -55,25 +52,34 @@ public AlarmConvergeReduce(AlertConvergeDao alertConvergeDao) { @SuppressWarnings("unchecked") public boolean filterConverge(Alert currentAlert) { // ignore monitor status auto recover notice - if (currentAlert.getTags() != null && currentAlert.getTags().containsKey(CommonConstants.IGNORE)) { - return true; - } - if (currentAlert.getStatus() == CommonConstants.ALERT_STATUS_CODE_RESTORED) { + if ((currentAlert.getTags() != null && currentAlert.getTags().containsKey(CommonConstants.IGNORE)) + || currentAlert.getStatus() == CommonConstants.ALERT_STATUS_CODE_RESTORED) { // restored alert + boolean isHasIgnore = false; + Map tags = currentAlert.getTags(); + if (tags.containsKey(CommonConstants.IGNORE)) { + isHasIgnore = true; + tags.remove(CommonConstants.IGNORE); + } int alertHash = Objects.hash(CommonConstants.ALERT_PRIORITY_CODE_CRITICAL) - + Arrays.hashCode(currentAlert.getTags().keySet().toArray(new String[0])) - + Arrays.hashCode(currentAlert.getTags().values().toArray(new String[0])); + + Arrays.hashCode(tags.keySet().toArray(new String[0])) + + Arrays.hashCode(tags.values().toArray(new String[0])); converageAlertMap.remove(alertHash); alertHash = Objects.hash(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY) - + Arrays.hashCode(currentAlert.getTags().keySet().toArray(new String[0])) - + Arrays.hashCode(currentAlert.getTags().values().toArray(new String[0])); + + Arrays.hashCode(tags.keySet().toArray(new String[0])) + + Arrays.hashCode(tags.values().toArray(new String[0])); converageAlertMap.remove(alertHash); alertHash = Objects.hash(CommonConstants.ALERT_PRIORITY_CODE_WARNING) - + Arrays.hashCode(currentAlert.getTags().keySet().toArray(new String[0])) - + Arrays.hashCode(currentAlert.getTags().values().toArray(new String[0])); + + Arrays.hashCode(tags.keySet().toArray(new String[0])) + + Arrays.hashCode(tags.values().toArray(new String[0])); converageAlertMap.remove(alertHash); + if (isHasIgnore) { + tags.put(CommonConstants.IGNORE, CommonConstants.IGNORE); + + } return true; } + CommonCacheService convergeCache = CacheFactory.getAlertConvergeCache(); List alertConvergeList = (List) convergeCache.get(CommonConstants.CACHE_ALERT_CONVERGE); if (alertConvergeList == null) { From 6cd7d1720417b65b8c2b7c62187a5adf298b033a Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Fri, 7 Jun 2024 20:59:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[bug]=EF=BC=9Afix=20the=20monitor=20status?= =?UTF-8?q?=20is=20abnormal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java | 1 - 1 file changed, 1 deletion(-) diff --git a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java index 6004d5b3ca3..e8ad4d07deb 100644 --- a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java +++ b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java @@ -75,7 +75,6 @@ public boolean filterConverge(Alert currentAlert) { converageAlertMap.remove(alertHash); if (isHasIgnore) { tags.put(CommonConstants.IGNORE, CommonConstants.IGNORE); - } return true; } From bf12e9d5259b1866167c015acbb3f72d82596105 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sat, 8 Jun 2024 11:59:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[bug]=EF=BC=9Afix=20the=20monitor=20status?= =?UTF-8?q?=20is=20abnormal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java index e8ad4d07deb..ce4a055f7a2 100644 --- a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java +++ b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java @@ -17,7 +17,10 @@ package org.apache.hertzbeat.alert.reduce; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import org.apache.hertzbeat.alert.dao.AlertConvergeDao; import org.apache.hertzbeat.common.cache.CacheFactory;