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

   ## Motivation
   
   `AlertService.labelSelector` only forwards `clusterName` and `brokerName` 
when building the exported PromQL selector. Alert rules scoped to a **consumer 
group** or **topic** — first-class scope fields on `AlertRuleVO`, validated by 
`NativeAlertRulePolicy` for the group-scoped business metrics 
(`consumer.lag.total`, `consumer.lag.max_queue`, `consumer.delay.seconds`, 
`topic.backlog.total`, `dlq.message.count`) — therefore export as a bare 
`metric > threshold` expression.
   
   The exported alert then evaluates **every series** of the metric: a rule 
configured as "cg-orders lag > 5000" fires when *any* consumer group's lag 
crosses the threshold, and a topic-scoped rule alerts on every topic. The 
configured boundary is silently widened to the whole cluster, which is the 
opposite of what the rule author asked to be alerted on.
   
   ## Modification
   
   Forward the rule's `consumerGroup` and `topic` fields as selector labels:
   
   - the consumer-group label is named **`group`**, matching the official 
rocketmq-exporter, which labels all of its consumer-group series 
`cluster`/`broker`/`topic`/`group` (`rocketmq_consumer_offset`, 
`rocketmq_group_diff`, `rocketmq_group_dlqdiff`, …);
   - empty and `*` wildcard scopes keep exporting without the label (existing 
`appendLabel` behavior);
   - the label order in the selector is cluster, broker, group, topic.
   
   ## Verification
   
   Two regression tests in `AlertServiceTest` (both **fail on the base branch** 
— the expr exports without the selector):
   
   - `exportPrometheusRulesYamlShouldKeepConsumerGroupScopeTest` — asserts 
`expr: rocketmq_consumer_lag_messages{group=\"cg-orders\"} > 5000`;
   - `exportPrometheusRulesYamlShouldKeepTopicScopeTest` — asserts the combined 
selector 
`{cluster=\"DefaultCluster\",group=\"cg-payments\",topic=\"payments\"}`.
   
   `mvn -pl server test -Dtest='AlertServiceTest'` → 75/75, BUILD SUCCESS. 
(`NotificationOutboxServiceTest` has a pre-existing 4F/1E mock-environment 
failure reproducible on the base commit, unrelated to this change.)


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