Bird
Raised Fist0
Kafkadevops~5 mins

Prometheus and Grafana integration in Kafka - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is Prometheus used for in monitoring Kafka?
Prometheus collects and stores metrics from Kafka brokers and topics, allowing you to monitor performance and health over time.
Click to reveal answer
beginner
How does Grafana work with Prometheus for Kafka monitoring?
Grafana connects to Prometheus as a data source and visualizes Kafka metrics in dashboards, making it easy to understand system status.
Click to reveal answer
intermediate
What is the role of exporters in Prometheus and Kafka integration?
Exporters collect Kafka metrics and expose them in a format Prometheus can scrape. For Kafka, the JMX exporter is commonly used.
Click to reveal answer
intermediate
Which configuration file is used to tell Prometheus where to find Kafka metrics?
The prometheus.yml file contains scrape_configs that specify the Kafka exporter endpoints to collect metrics from.
Click to reveal answer
intermediate
Why is it important to set up alerting rules in Prometheus for Kafka?
Alerting rules notify you when Kafka metrics cross thresholds, helping you catch issues early before they affect users.
Click to reveal answer
What component exposes Kafka metrics for Prometheus to scrape?
AJMX Exporter
BKafka Broker
CGrafana Dashboard
DKafka Producer
Which file configures Prometheus to scrape Kafka metrics?
Aprometheus.yml
Bgrafana.ini
Ckafka.properties
Ddocker-compose.yml
What does Grafana do with data from Prometheus?
ACollects metrics from Kafka
BSends alerts directly
CVisualizes metrics in dashboards
DStores raw metrics data
Why use alerting rules in Prometheus for Kafka?
ATo backup Kafka data
BTo increase Kafka throughput
CTo configure Kafka topics
DTo get notified about issues early
Which protocol does Prometheus use to collect metrics from exporters?
ASMTP
BHTTP
CSSH
DFTP
Explain the steps to integrate Prometheus and Grafana for monitoring Kafka.
Think about how data flows from Kafka to Prometheus to Grafana.
You got /4 concepts.
    Describe why monitoring Kafka with Prometheus and Grafana is useful for system reliability.
    Consider how monitoring helps prevent downtime.
    You got /4 concepts.

      Practice

      (1/5)
      1. What is the main role of Prometheus in Kafka monitoring when integrated with Grafana?
      easy
      A. To collect Kafka metrics by scraping the metrics endpoint
      B. To display visual dashboards of Kafka metrics
      C. To send alerts directly to Kafka topics
      D. To store Kafka messages for backup

      Solution

      1. Step 1: Understand Prometheus function

        Prometheus collects metrics by scraping endpoints exposed by applications like Kafka.
      2. Step 2: Differentiate roles of Prometheus and Grafana

        Grafana is used for visualization, not data collection.
      3. Final Answer:

        To collect Kafka metrics by scraping the metrics endpoint -> Option A
      4. Quick Check:

        Prometheus collects metrics = A [OK]
      Hint: Remember: Prometheus collects, Grafana displays [OK]
      Common Mistakes:
      • Confusing Grafana as the collector
      • Thinking Prometheus stores Kafka messages
      • Assuming Prometheus sends alerts to Kafka
      2. Which of the following is the correct Prometheus scrape configuration snippet to monitor Kafka metrics exposed at port 9090?
      easy
      A. - job_name: 'kafka'\n static_configs:\n - targets: ['localhost:9090']
      B. - job_name: 'kafka'\n static_configs:\n - targets: ['localhost:2181']
      C. - job_name: 'kafka'\n static_configs:\n - targets: ['localhost:8080']
      D. - job_name: 'kafka'\n static_configs:\n - targets: ['localhost:1234']

      Solution

      1. Step 1: Identify Kafka metrics port

        Kafka metrics exporter commonly exposes metrics on port 9090.
      2. Step 2: Match correct target in Prometheus config

        Only - job_name: 'kafka'\n static_configs:\n - targets: ['localhost:9090'] uses port 9090, which is correct for scraping Kafka metrics.
      3. Final Answer:

        - job_name: 'kafka'\n static_configs:\n - targets: ['localhost:9090'] -> Option A
      4. Quick Check:

        Port 9090 for Kafka metrics = A [OK]
      Hint: Kafka metrics usually on port 9090, check targets carefully [OK]
      Common Mistakes:
      • Using Kafka broker port 2181 (Zookeeper port) instead of metrics port
      • Confusing HTTP ports like 8080 for metrics
      • Using random ports not related to Kafka metrics
      3. Given this Prometheus query to monitor Kafka consumer lag:
      sum(kafka_consumer_group_lag) by (group)
      What output will this query produce?
      medium
      A. Current CPU usage of Kafka brokers
      B. Total lag per consumer group as a number
      C. Number of active Kafka brokers
      D. List of all Kafka topics with their lag

      Solution

      1. Step 1: Understand the metric and aggregation

        The metric kafka_consumer_group_lag measures lag per consumer group and partition. Summing by group aggregates lag per group.
      2. Step 2: Interpret the query output

        The query returns total lag number for each consumer group, not topics or CPU usage.
      3. Final Answer:

        Total lag per consumer group as a number -> Option B
      4. Quick Check:

        sum by group = total lag per group [OK]
      Hint: sum(... by (group)) means total per group [OK]
      Common Mistakes:
      • Thinking it lists topics instead of groups
      • Confusing lag with broker count
      • Assuming CPU metrics from Kafka lag metric
      4. You configured Prometheus to scrape Kafka metrics but Grafana shows no data. Which is the most likely cause?
      medium
      A. Prometheus scrape interval is too short
      B. Grafana dashboard is not connected to Prometheus
      C. Kafka metrics endpoint is not exposed or unreachable
      D. Kafka broker is down

      Solution

      1. Step 1: Check Prometheus scraping setup

        If Kafka metrics endpoint is not exposed or unreachable, Prometheus cannot collect data.
      2. Step 2: Understand impact on Grafana

        Without data in Prometheus, Grafana dashboards show no metrics.
      3. Final Answer:

        Kafka metrics endpoint is not exposed or unreachable -> Option C
      4. Quick Check:

        No data means no scrape target reachable [OK]
      Hint: No data? Check if metrics endpoint is reachable first [OK]
      Common Mistakes:
      • Blaming Grafana connection before checking Prometheus data
      • Assuming Kafka broker down always causes no data
      • Thinking scrape interval too short causes no data
      5. You want to create a Grafana dashboard showing Kafka broker CPU usage and consumer lag side by side. Which data sources and queries should you use?
      hard
      A. Connect Grafana to Prometheus; use queries kafka_cpu_usage and kafka_topic_lag
      B. Connect Grafana directly to Kafka; use queries kafka_cpu and kafka_lag
      C. Connect Grafana to Kafka Connect; use queries cpu_usage and consumer_lag
      D. Connect Grafana to Prometheus; use queries kafka_broker_cpu_usage and sum(kafka_consumer_group_lag) by (group)

      Solution

      1. Step 1: Identify correct data source for metrics

        Prometheus collects Kafka metrics; Grafana connects to Prometheus for queries.
      2. Step 2: Choose correct metric names and queries

        Common metrics are kafka_broker_cpu_usage and kafka_consumer_group_lag aggregated by group.
      3. Final Answer:

        Connect Grafana to Prometheus; use queries kafka_broker_cpu_usage and sum(kafka_consumer_group_lag) by (group) -> Option D
      4. Quick Check:

        Prometheus + correct queries = C [OK]
      Hint: Grafana queries Prometheus metrics, not Kafka directly [OK]
      Common Mistakes:
      • Trying to connect Grafana directly to Kafka brokers
      • Using wrong metric names or unaggregated lag
      • Confusing Kafka Connect with Kafka broker metrics
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard