Challenge - 5 Problems
Kafka JMX Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this JMX query for Kafka broker metrics?
Given the following JMX query executed against a Kafka broker's MBean server, what is the output?
Kafka
ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec"); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); AttributeList attributes = mbs.getAttributes(name, new String[]{"Count"}); for (Attribute attr : attributes.asList()) { System.out.println(attr.getName() + ": " + attr.getValue()); }
Attempts:
2 left
💡 Hint
Think about the default state of the metric if no messages have been processed yet.
✗ Incorrect
The 'MessagesInPerSec' metric's 'Count' attribute starts at 0 before any messages are processed. The code queries this attribute and prints its value.
❓ Predict Output
intermediate2:00remaining
What error does this JMX code produce when querying a non-existent Kafka metric?
Consider this Java code snippet querying a Kafka JMX metric that does not exist. What error will it produce?
Kafka
ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=NonExistentMetric"); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.getAttribute(name, "Count");
Attempts:
2 left
💡 Hint
The MBean server throws an exception if the MBean name is not registered.
✗ Incorrect
If the MBean with the given ObjectName does not exist, the MBeanServer throws InstanceNotFoundException.
🔧 Debug
advanced2:00remaining
Why does this JMX Kafka metric query return null instead of the expected value?
This Java code queries the 'BytesInPerSec' metric from Kafka but prints 'null'. What is the likely cause?
Kafka
ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec"); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); Object value = mbs.getAttribute(name, "OneMinuteRate"); System.out.println(value);
Attempts:
2 left
💡 Hint
Check the attributes exposed by the 'BytesInPerSec' MBean carefully.
✗ Incorrect
The 'BytesInPerSec' MBean exposes attributes like 'Count' and 'MeanRate', but not 'OneMinuteRate'. Querying a non-existent attribute returns null.
🧠 Conceptual
advanced2:00remaining
Which JMX metric best indicates the current number of active Kafka connections?
Among Kafka JMX metrics, which one best reflects the current active network connections to the broker?
Attempts:
2 left
💡 Hint
Look for a metric that counts connections, not rates or percentages.
✗ Incorrect
The 'ConnectionCount' metric under 'kafka.network:type=SocketServer' shows the current number of active connections.
❓ Predict Output
expert2:00remaining
What is the output of this JMX query code snippet for Kafka's UnderReplicatedPartitions metric?
Analyze the following Java code querying Kafka's 'UnderReplicatedPartitions' metric. What will it print?
Kafka
ObjectName name = new ObjectName("kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions"); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); Integer count = (Integer) mbs.getAttribute(name, "Value"); System.out.println("UnderReplicatedPartitions: " + count);
Attempts:
2 left
💡 Hint
Check if the ObjectName and attribute name are correct for this metric.
✗ Incorrect
The 'UnderReplicatedPartitions' metric is under 'kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions' but the attribute 'Value' does not exist; also, this MBean is not always registered, causing InstanceNotFoundException.