Why monitoring prevents outages
📖 Scenario: You are managing a Kafka message system that processes orders for an online store. To keep the system healthy, you want to monitor the number of messages waiting in the queue. If the queue grows too large, it might mean the system is slow or stuck, which can cause outages.
🎯 Goal: Build a simple monitoring script that tracks the number of messages in a Kafka topic and alerts if the count exceeds a safe limit. This helps prevent outages by catching problems early.
📋 What You'll Learn
Create a dictionary called
kafka_queues with these exact entries: 'orders': 120, 'payments': 80, 'shipments': 50Create a variable called
threshold and set it to 100Use a
for loop with variables topic and count to iterate over kafka_queues.items() and create a list alerts of topics where count is greater than thresholdPrint the
alerts list to show which topics need attention💡 Why This Matters
🌍 Real World
Monitoring Kafka queues helps catch problems early, like slow consumers or stuck messages, preventing system outages.
💼 Career
DevOps engineers use monitoring scripts like this to keep message systems healthy and ensure smooth data flow in production.
Progress0 / 4 steps