zjncs opened a new pull request, #4126: URL: https://github.com/apache/rocketmq-dashboard/pull/4126
### Motivation `AlertRuleEvaluator` matches a rule against a sample using the trimmed metric key (`rule.getMetric().trim()`), but two ratio-aware code paths still consult `RATIO_METRICS` with the raw stored key: - `AlertRuleSemanticFingerprint.normalizedThreshold` checks `RATIO_METRICS.contains(rule.getMetric())` - `AlertNotificationTemplate.formattedValue` checks `RATIO_METRICS.contains(rule.getMetric())` For a rule stored with a padded metric like `" broker.disk.usage_ratio "` and a `%` threshold of 85: - the threshold is **not** divided by 100, so the evaluator compares the raw ratio `0.9 >= 85` and the rule never fires (or fires on every healthy disk with `<=`) - the notification renders the raw ratio next to the unit, e.g. `0.865%/85` instead of `86.5%/85` `AlertRuleSemanticFingerprint.of()` already trims every field for identity and the request DTO normalizes the metric key on write, so this only affects rules persisted through other paths. ### Modifications - `AlertRuleSemanticFingerprint.normalizedThreshold`: look up `RATIO_METRICS` with the existing `normalize()` helper instead of the raw metric - `AlertNotificationTemplate.formattedValue`: compare against the trimmed metric ### Verification Fail-before (both tests added in this PR, run against the unpatched code): ``` [ERROR] Tests run: 6, Failures: 1 -- AlertRuleEvaluatorTest Expecting value to be true but was false [ERROR] Tests run: 4, Failures: 1 -- AlertNotificationTemplateTest expected: "86.5%" but was: "0.865%" ``` Pass-after: ``` Tests run: 6, Failures: 0, Errors: 0 -- AlertRuleEvaluatorTest Tests run: 4, Failures: 0, Errors: 0 -- AlertNotificationTemplateTest Tests run: 3, Failures: 0, Errors: 0 -- AlertRuleSemanticFingerprintTest Tests run: 13, Failures: 0, Errors: 0 ``` -- 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]
