0
0
Kafkadevops~20 mins

Key broker metrics in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Broker Metrics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Kafka broker metric query
Given the following Kafka broker metrics query snippet, what is the output when querying the metric kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=TestTopic?
Kafka
kafka-run-class kafka.tools.JmxTool --jmx-url service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi --object-name kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=TestTopic
A{"Count": 0, "MeanRate": 0.0, "OneMinuteRate": 0.0}
B{"Count": 1500, "MeanRate": 10.5, "OneMinuteRate": 12.3}
CError: Metric kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=TestTopic not found
DSyntaxError: Invalid JMX URL format
Attempts:
2 left
💡 Hint
Check the metric name and topic parameter carefully.
🧠 Conceptual
intermediate
1:30remaining
Understanding Kafka broker metric 'UnderReplicatedPartitions'
What does the Kafka broker metric UnderReplicatedPartitions indicate?
AThe number of partitions currently being created
BThe total number of partitions in the broker
CThe number of partitions that have fewer replicas in sync than the configured replication factor
DThe number of partitions that have no leader assigned
Attempts:
2 left
💡 Hint
Think about replication health and data safety.
🔧 Debug
advanced
2:00remaining
Identify the error in Kafka broker metric retrieval code
What error will the following code produce when trying to fetch the broker metric kafka.network:type=RequestMetrics,name=RequestsPerSec,request=Produce?
from kafka import KafkaAdminClient

admin_client = KafkaAdminClient(bootstrap_servers='localhost:9092')
metric = admin_client.get_metric('kafka.network:type=RequestMetrics,name=RequestsPerSec,request=Produce')
print(metric)
AAttributeError: 'KafkaAdminClient' object has no attribute 'get_metric'
B{'Count': 500, 'MeanRate': 20.0, 'OneMinuteRate': 18.5}
CConnectionError: Failed to connect to localhost:9092
DTypeError: get_metric() missing 1 required positional argument
Attempts:
2 left
💡 Hint
Check if KafkaAdminClient supports metric retrieval directly.
📝 Syntax
advanced
1:30remaining
Correct syntax for filtering Kafka broker metrics by topic
Which of the following JMX object names correctly filters the Kafka broker metric BytesInPerSec for the topic myTopic?
Akafka.server:type=BrokerTopicMetrics,name=BytesInPerSec?topic=myTopic
Bkafka.server:type=BrokerTopicMetrics,name=BytesInPerSec;topic=myTopic
Ckafka.server:type=BrokerTopicMetrics,name=BytesInPerSec/topic=myTopic
Dkafka.server:type=BrokerTopicMetrics,name=BytesInPerSec,topic=myTopic
Attempts:
2 left
💡 Hint
JMX object names use commas to separate key-value pairs.
🚀 Application
expert
2:00remaining
Calculate total messages in per second across all topics
You have the following metrics for two topics on a Kafka broker: - kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=TopicA: Count=1000, MeanRate=15.0 - kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=TopicB: Count=2000, MeanRate=25.0 What is the total MeanRate of messages in per second across both topics?
A40.0
B25.0
C15.0
D3000
Attempts:
2 left
💡 Hint
Add the MeanRate values for both topics.