0
0
Kafkadevops~30 mins

Key broker metrics in Kafka - Mini Project: Build & Apply

Choose your learning style9 modes available
Key broker metrics
📖 Scenario: You are working with a Kafka cluster and want to monitor key broker metrics to ensure the system is running smoothly.
🎯 Goal: Build a simple program that collects and displays key Kafka broker metrics such as bytes in/out per second and request rates.
📋 What You'll Learn
Create a dictionary with exact metric names and initial values
Add a configuration variable for the minimum threshold to alert
Use a loop to filter metrics above the threshold
Print the filtered metrics
💡 Why This Matters
🌍 Real World
Monitoring Kafka broker metrics helps keep the system healthy and detect issues early.
💼 Career
Understanding how to filter and display key metrics is useful for roles in DevOps, site reliability engineering, and backend development.
Progress0 / 4 steps
1
Create initial metrics dictionary
Create a dictionary called broker_metrics with these exact entries: 'BytesInPerSec': 1200, 'BytesOutPerSec': 1500, 'RequestRate': 300, 'FailedRequests': 5
Kafka
Need a hint?

Use curly braces to create a dictionary with the exact keys and values.

2
Add threshold configuration
Create a variable called threshold and set it to 1000 to filter important metrics
Kafka
Need a hint?

Just assign the number 1000 to the variable threshold.

3
Filter metrics above threshold
Create a new dictionary called important_metrics using a dictionary comprehension that includes only items from broker_metrics where the value is greater than threshold
Kafka
Need a hint?

Use a dictionary comprehension with for key, value in broker_metrics.items() and an if condition.

4
Print the filtered metrics
Write a print statement to display the important_metrics dictionary
Kafka
Need a hint?

Use print(important_metrics) to show the filtered dictionary.