zjncs opened a new pull request, #7260:
URL: https://github.com/apache/rocketmq-dashboard/pull/7260

   ## Problem
   
   The percent convention for ratio metrics (`broker.disk.usage_ratio` and 
siblings) exists in exactly two places: the notification template scales the 
value by 100 when `thresholdUnit="%"` (`AlertNotificationTemplate.java:67-73`, 
"Ratio metrics are stored as fractions of the whole…") and the threshold side 
normalizes the same way (`AlertRuleSemanticFingerprint.java:82-84` divides by 
100). But the `currentValue` written onto alert events 
(`NativeAlertEvaluationService.java:84`, 
`NativeAlertProcessor.emitLifecycleEvent`) and onto rule-test results 
(`NativeAlertRuleTestService.java:86`) — consumed by the System Alerts feed 
(`systemAlerts.tsx:749`) and the rule-test drawer — is never scaled. For one 
firing disk alert at 91%: the DingTalk body says **91**, the rule list says **> 
85%**, and the alerts feed says **0.91** right next to that percent threshold — 
which reads as healthy.
   
   ## Fix
   
   Apply the same scaling at the event/rule-test build sites via a shared 
helper next to the existing threshold normalization, and scale the processor's 
lifecycle events too (resolved events would otherwise disagree with firing 
ones). The notification template consumes the already-scaled value.
   
   ## Verification
   
   - Regression tests written first, both RED (`expected: 91.0 but was: 0.91`): 
`NativeAlertRuleTestServiceTest.scalesRatioSamplesToTheRulePercentUnitTest`, 
`NativeAlertEvaluationTransactionTest.scalesRatioEventValuesToTheRulePercentUnitTest`;
 template tests updated to the scaled contract.
   - GREEN: full alert suite — 464 tests, 0 failures. Verification note: alert 
tests run via `mvn -Dtest='org.apache.rocketmq.studio.ops.alert.**.*Test' 
-Dspring.profiles.active=dev test` from `server/` (the dev profile provides H2; 
a plain run needs MySQL, which is pre-existing behavior), JDK 21.
   
   ## Risk
   
   Notification text is unchanged (it already scaled); the change makes the 
feed, the rule list and the notification agree. Non-ratio metrics are untouched.


-- 
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