Bird
Raised Fist0

You want to write a Java method that returns the total bytes in per second across all Kafka brokers using JMX. Which approach is best?

hard🚀 Application Q9 of Q15
Kafka - Monitoring and Operations
You want to write a Java method that returns the total bytes in per second across all Kafka brokers using JMX. Which approach is best?
AQuery all ObjectNames matching "kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec" and sum their "Count" attributes
BQuery a single ObjectName "kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec" and return its "Count"
CUse KafkaConsumer to read bytes from topics
DRead bytes from Kafka logs on disk
Step-by-Step Solution
Solution:
  1. Step 1: Understand metric distribution

    BytesInPerSec metrics exist per broker and topic, so multiple ObjectNames exist.
  2. Step 2: Aggregate counts from all matching ObjectNames

    Summing "Count" attributes from all matching beans gives total bytes per second.
  3. Final Answer:

    Query all ObjectNames matching "kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec" and sum their "Count" attributes -> Option A
  4. Quick Check:

    Aggregate metrics from all brokers for total [OK]
Quick Trick: Sum metrics from all brokers for total value [OK]
Common Mistakes:
MISTAKES
  • Querying only one broker's metric
  • Using KafkaConsumer for JMX metrics
  • Reading logs instead of JMX

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes