unbridled-41 opened a new pull request, #5421:
URL: https://github.com/apache/rocketmq-dashboard/pull/5421
## Problem / Evidence
The bundled "RocketMQ Cluster Overview" dashboard
(`server/src/main/resources/grafana/rocketmq-overview.json:316`, generated by
`server/scripts/gen_grafana_dashboards.py:176`) shows a stat panel titled
**Broker Count** computed as:
```
count(rocketmq_messages_in_total{cluster="$cluster"})
```
`rocketmq_messages_in_total` carries a `broker` label *and* a `topic` label
— the very same dashboard derives its `$broker` and `$topic` template variables
from that metric (`"query":
"label_values(rocketmq_messages_in_total{cluster=\"$cluster\"}, broker)"` and
`..., topic)`). `count()` therefore counts broker/topic series, not brokers: a
two-broker cluster with 300 topics renders **600** as the broker count.
The neighbouring panel makes the intended idiom explicit — "Total Topics" is
`count(count by (topic) (rocketmq_messages_in_total{cluster="$cluster"}))`.
The dashboard is user-facing: `GrafanaDashboardController` lists it, serves
its JSON and packs the whole set into `rocketmq-grafana-dashboards.zip` for
import into Grafana.
## Root cause / Fix
A bare `count()` was used where a distinct-label count was intended. Fix:
```
count(count by (broker) (rocketmq_messages_in_total{cluster="$cluster"}))
```
Changed in the generator and the checked-in JSON regenerated from it (the
only line that differs).
## Priority & scoring
PRIORITY 61 = 影响 20 (a headline cluster stat is wrong by orders of
magnitude) + 波及 9 (overview dashboard shipped to every user who imports the
bundle) + 可复现 20 (deterministic PromQL semantics) + 维护价值 12.
FIX_CONFIDENCE 90: standard distinct-count idiom matching the adjacent
panel; no layout, uid or title change.
## Tests
```
cd server/scripts && python3 -m unittest test_gen_grafana_dashboards
```
- Red before the fix: `'count(count by (broker)
(rocketmq_messages_in_total{cluster="$cluster"}))' !=
'count(rocketmq_messages_in_total{cluster="$cluster"})'`
- Green after: `Ran 5 tests ... OK`
- Regenerating all 12 dashboards reproduces the checked-in
`server/src/main/resources/grafana` directory byte for byte (`diff -rq` clean).
## Risk
Low. One `expr` string in one panel; panel id, title, unit and layout are
untouched, so dashboard imports/overwrites behave identically.
--
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]