BE: Fall back to per-topic rates for cluster throughput when broker aggregate is absent#1875
Conversation
…egate is absent - InternalClusterState derived cluster bytesIn/Out solely from the per-broker topic-less BrokerTopicMetrics aggregate; brokers that don't expose it over JMX (e.g. Confluent cp-kafka) left the per-broker map empty, so the dashboard showed 0 B/s even though every per-topic rate was scraped correctly. - Sum per-topic rates when the per-broker map is empty; this equals the all-topics broker aggregate since bytes in/out are additive across topics (counted once at the leader broker). - Add InternalClusterStateTest covering broker-present, topic-fallback, empty cases.
|
AI Summary The issue describes a problem where Kafka UI's cluster dashboard incorrectly shows zero throughput when the per-broker topic-less |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates ChangesFallback aggregation for cluster IO rates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hi Sangyong-Jeon! 👋
Welcome, and thank you for opening your first PR in the repo!
Please wait for triaging by our maintainers.
Please take a look at our contributing guide.
Real-world verification on Confluent cp-kafkaBuilt this PR's branch into a Docker image (JDK 25) and ran it side by side with the current
This broker only surfaces per-topic
this PR (after):
|


What changes did you make? (Give an overview)
Closes #1874.
When the per-broker topic-less
BrokerTopicMetricsaggregate is absent from the scraped metrics,InternalClusterStateresolved clusterbytesInPerSec/bytesOutPerSectonull("0 B/s") even though every per-topic rate was scraped successfully. This affects brokers that don't surface the topic-less aggregate over JMX (observed on Confluentcp-kafka7.9.7): the cluster dashboard shows 0 throughput while topic details show real numbers.InternalClusterStatenow falls back to summing the per-topic rates when the per-broker map is empty. This is exact, since bytes in/out are additive across topics and counted once at the leader broker, sosum(per-topic) == all-topics broker aggregate.Is there anything you'd like reviewers to focus on?
Whether the fallback belongs in
InternalClusterState(cluster aggregate) orIoRatesMetricsScanner(per-broker). The per-broker map can't be reconstructed in the scanner becausetopicBytes*PerSecis already cluster-wide (merged across brokers), so the cluster aggregate is the correct layer for the fallback. Per-broker dashboard values for such brokers remain a separate, lower-impact gap.How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)
InternalClusterStateTest: per-broker present (used as-is), per-broker empty + per-topic present (fallback), both empty (null).cp-kafka7.9.7 broker: the globalBrokerTopicMetrics:BytesInPerSecMBean is present viaJmxToolbut absent from kafka-ui's scraped set; per-topic throughput populated, cluster shows 0.Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)
Summary by CodeRabbit