This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e155e0d4 [improve] when multiple lines are returned, each alarm is 
triggered instead of only the first alarm (#1797)
5e155e0d4 is described below

commit 5e155e0d453970b3e2da8160414246246ecbcf98
Author: 栗磊 <[email protected]>
AuthorDate: Sun Apr 21 11:18:53 2024 +0800

    [improve] when multiple lines are returned, each alarm is triggered instead 
of only the first alarm (#1797)
    
    Co-authored-by: tomsun28 <[email protected]>
---
 .../org/apache/hertzbeat/alert/calculate/CalculateAlarm.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git 
a/alerter/src/main/java/org/apache/hertzbeat/alert/calculate/CalculateAlarm.java
 
b/alerter/src/main/java/org/apache/hertzbeat/alert/calculate/CalculateAlarm.java
index 559670baf..b2e0f4291 100644
--- 
a/alerter/src/main/java/org/apache/hertzbeat/alert/calculate/CalculateAlarm.java
+++ 
b/alerter/src/main/java/org/apache/hertzbeat/alert/calculate/CalculateAlarm.java
@@ -175,7 +175,7 @@ public class CalculateAlarm {
                         } catch (Exception e) {
                             log.error(e.getMessage(), e);
                         }
-                    } catch (Exception ignored) {} 
+                    } catch (Exception ignored) {}
                 }
                 for (CollectRep.ValueRow valueRow : 
metricsData.getValuesList()) {
 
@@ -220,15 +220,13 @@ public class CalculateAlarm {
                             if (match) {
                                 // If the threshold rule matches, the number 
of times the threshold has been triggered is determined and an alarm is 
triggered
                                 afterThresholdRuleMatch(currentTimeMilli, 
monitorId, app, metrics, tagBuilder.toString(), fieldValueMap, define);
-                                // if the threshold is triggered, ignore other 
data rows
-                                break;
                             } else {
                                 String alarmKey = String.valueOf(monitorId) + 
define.getId() + tagBuilder;
                                 triggeredAlertMap.remove(alarmKey);
                                 if (define.isRecoverNotice()) {
                                     handleRecoveredAlert(currentTimeMilli, 
define, expr, alarmKey);
                                 }
-                            }   
+                            }
                         } catch (Exception e) {
                             log.error(e.getMessage(), e);
                         }
@@ -258,7 +256,7 @@ public class CalculateAlarm {
         }
     }
 
-    private void afterThresholdRuleMatch(long currentTimeMilli, long 
monitorId, String app, String metrics, String tagStr, 
+    private void afterThresholdRuleMatch(long currentTimeMilli, long 
monitorId, String app, String metrics, String tagStr,
                                          Map<String, Object> fieldValueMap, 
AlertDefine define) {
         String alarmKey = String.valueOf(monitorId) + define.getId() + tagStr;
         Alert triggeredAlert = triggeredAlertMap.get(alarmKey);
@@ -377,7 +375,7 @@ public class CalculateAlarm {
                     notRecoveredAlertMap.put(notResolvedAlertKey, 
alertBuilder.build());
                     alarmCommonReduce.reduceAndSendAlarm(alertBuilder.build());
                 } else {
-                    triggeredAlertMap.put(String.valueOf(monitorId), 
alertBuilder.build());   
+                    triggeredAlertMap.put(String.valueOf(monitorId), 
alertBuilder.build());
                 }
             } else {
                 int times = preAlert.getTriggerTimes() + 1;
@@ -418,7 +416,7 @@ public class CalculateAlarm {
                         .build();
                 alarmCommonReduce.reduceAndSendAlarm(resumeAlert);
                 Runnable updateStatusJob = () -> {
-                    // todo update pre all type alarm status 
+                    // todo update pre all type alarm status
                     updateAvailabilityAlertStatus(monitorId, resumeAlert);
                 };
                 workerPool.executeJob(updateStatusJob);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to