iloveeyjafjalla opened a new issue, #6875:
URL: https://github.com/apache/rocketmq-dashboard/issues/6875

   ## Summary
   
   The rule editor's test run (the 测试 button: "would this rule fire?") 
evaluates the freshly collected sample, while the live evaluation first 
aggregates the samples stored for the same series over the rule's window. For a 
rule that asks for a window and an aggregation other than `LAST`, the two 
answer different questions — the preview is the only way to check a rule before 
enabling it.
   
   ## Why
   
   - Live evaluation: `NativeAlertEvaluationService.evaluate` starts with 
`MetricSample evaluatedSample = aggregate(rule, sample);` 
(`server/src/main/java/org/apache/rocketmq/studio/ops/alert/NativeAlertEvaluationService.java:56`),
 and `aggregate` (`:106-124`) reads 
`MetricSnapshotRepository.findRecent(sample, collectedAt - windowSeconds)` and 
applies `MIN`/`MAX`/`AVG`/`SUM`, or the last stored sample for `LAST`.
   - Test run: `NativeAlertRuleTestService` filters the collected samples and 
evaluates them directly — `evaluator.evaluate(rule, sample)` (`:81`) — so 
`rule.getWindowSeconds()` / `rule.getAggregation()` are never consulted, and 
`AlertRuleTestResultVO.Sample` carries no aggregated value that would disclose 
the difference.
   
   ## Impact
   
   A rule with `窗口聚合 = AVG` and `窗口秒数 = 300` on `consumer.lag.total > 100`, 
whose stored window is `[500, 500]` while the sample collected now is `10`:
   
   - preview: `10`, "condition not met", 0 matched;
   - production: `AVG = 336.67` > 100, FIRING.
   
   Operators tune thresholds against the preview, so the editor's two fields 
(窗口聚合 / 窗口秒数, both named in the UI) currently describe a condition the runtime 
does not use.
   
   ## Reproduction
   
   
`server/src/test/java/org/apache/rocketmq/studio/ops/alert/NativeAlertRuleTestServiceTest.java`
 → `aggregatesTheStoredWindowBeforeEvaluatingARuleTest` collects the sample 
`10`, stores `[500, 500, 10]` for the window and asks for `AVG`/300s:
   
   ```
   Expecting actual:
     10.0
   to be close to:
     336.67
   ```
   
   ## Expected
   
   The test run evaluates the same sample the evaluator would, so the reported 
value and `conditionMatched` are the ones a real breach would produce.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to