Key Kafka Metrics: Broker, Producer and Consumer
A beginner-friendly guide to the numbers that tell you whether a Kafka system is healthy: what each important metric means, why it matters, what a worrying value looks like, and how to read the broker, producer and consumer sides together.
Picture the dashboard of a car. You do not need to be a mechanic to understand it. The speedometer tells you how fast you are going, the fuel gauge tells you how far you can still drive, the temperature light warns you before the engine overheats, and the oil light tells you to stop. Without the dashboard, you would only discover problems when the car breaks down on the highway. A Kafka system needs a dashboard too. It has dozens of machines and applications, and thousands of things that can quietly go wrong. Kafka metrics are the gauges and warning lights of that dashboard. This guide explains the most important ones for the three main parts of Kafka: the broker, the producer and the consumer, using plain language and everyday comparisons, so that you can follow it even if you have never looked at a Kafka metric before.
1Why Kafka Metrics Matter
Kafka runs quietly in the background. That is exactly why you need numbers to tell you how it is doing.
Kafka in one paragraph
Apache Kafka is a system for moving streams of messages between applications. Applications that write messages are called producers. Applications that read messages are called consumers. In between sit the Kafka servers, called brokers, which store messages safely on disk in channels called topics. Each topic is split into smaller pieces called partitions, and each partition is copied to several brokers, so that data survives when a machine fails.
What goes wrong without visibility
Problems grow silently
A disk fills up slowly for weeks. A consumer falls a little further behind every hour. A replica quietly stops keeping up. Nothing crashes, so nobody notices, until one day the broker stops accepting data or the reports are twelve hours late.
Guessing is slow and expensive
When something feels slow, teams without metrics argue about the cause: is it the network, the brokers, the application? With metrics, the data points to the answer in minutes instead of days.
Capacity planning becomes guesswork
Without knowing how much traffic each broker handles and how it grows, you cannot say when you need more machines. You either overspend or run out of room at the worst moment.
Running Kafka without metrics is like flying an aeroplane with a covered instrument panel. Everything may feel fine for a while, and then the fuel runs out with no warning. Metrics are the instruments that let you steer before trouble arrives.
The goal of monitoring
Good monitoring answers three questions. First, is the system working right now? Second, is it about to have a problem? Third, when something breaks, where is the cause? The metrics in this guide were chosen because they answer these questions for the three main parts of Kafka.
2What Is a Metric? Understanding the Types
A metric is simply a number that is measured again and again. The way that number behaves decides how you read it.
Metrics are measurements over time
A single measurement, such as “the broker handled 5,000 messages this second”, tells you little. A series of measurements over minutes, hours and days tells a story: whether traffic is rising, whether a spike is normal for Monday mornings, whether a dip appeared right after a deployment. Always look at metrics as lines on a chart, not as isolated numbers.
The common kinds of metrics
Gauge
A number that goes up and down and shows the current value, such as the number of partitions on a broker or the amount of free memory.
Rate (meter)
How many things happen per second, such as messages arriving each second. Often shown as a one-minute or five-minute average.
Counter
A total that only grows, such as the total number of errors since start. You usually look at how fast it grows.
Latency or timing
How long something takes, often reported as an average, a maximum and percentiles such as the 99th percentile.
A gauge is the fuel level right now. A rate is your speed in kilometres per hour. A counter is the trip odometer. A latency figure is the time your last journey took.
Averages hide pain: why percentiles matter
Suppose ninety-nine requests take one millisecond and one request takes five seconds. The average looks very healthy, yet one user had a terrible experience. That is why timing metrics are often reported as percentiles. The 99th percentile means “ninety-nine out of a hundred requests were faster than this.” Watching it shows the slow tail that averages hide. Whenever you can, look at the maximum and the high percentiles next to the average.
Judging health by averages alone. A system can have a wonderful average and still be failing a small but important group of requests. Always check the slow tail too.
3How Kafka Exposes Its Metrics
Kafka is written in Java, and it publishes its numbers through a standard Java mechanism. Everything else is built on top of that.
JMX: the built-in window
Java programs can expose internal measurements through a technology called JMX, which stands for Java Management Extensions. Brokers, producers and consumers all register their metrics as named entries, and any tool that can talk JMX can read them. The names follow a pattern that starts with a group, such as the server, the network or the log, followed by the type and the name of the metric. You will see names like this in documentation, and they tell you where in Kafka the number lives.
From JMX to dashboards
Reading JMX by hand is possible but painful. In practice, teams place a small helper next to each Kafka process that reads JMX and republishes the numbers in a friendlier form. A monitoring system then collects those numbers every few seconds, stores them, draws charts and sends alerts. Many products can do this job, including open-source stacks and commercial platforms. The helper and the storage differ from company to company, but the metric names and meanings stay the same.
flowchart LR
B[Broker JMX] --> X[Metrics exporter]
P[Producer JMX] --> X
C[Consumer JMX] --> X
X --> S[Metrics storage]
S --> D[Dashboards]
S --> A[Alerts]
A --> N[People on call]
Two important sources
Server-side metrics
Published by the brokers. They describe the cluster itself: traffic, replication, request handling and disks. They show the health of the shared infrastructure that every application depends on.
Client-side metrics
Published by each producer and consumer application inside its own process. They describe that one application’s experience: how fast it sends, how long requests take, how far behind it is. You must collect these from your applications, because the brokers cannot see everything from their side.
Broker metrics show what the cluster feels. Client metrics show what your applications feel. A healthy cluster can still serve an unhappy application, so you need both views.
Other sources worth combining
Kafka’s own metrics do not tell the whole story. You should also collect numbers from the machines and the Java runtime that host Kafka: processor use, memory, disk space, disk speed, network traffic, open file counts and garbage collection pauses. When a Kafka metric looks bad, the cause very often shows up first in one of these host-level numbers.
4A Simple Map: Four Golden Signals for Kafka
With hundreds of metrics available, a simple mental map keeps you from getting lost.
Engineers who run large systems often use four questions as a map, sometimes called the four golden signals. They apply nicely to Kafka.
Traffic
How much work is the system doing? Messages per second, bytes per second, requests per second.
Latency
How long does the work take? Request times, send times, fetch times, end-to-end delay.
Errors
How much work is failing? Failed requests, retried sends, dropped connections, offline partitions.
Saturation
How full is the system? Disk space, thread idleness, memory buffers, queue sizes, consumer lag.
Think of a busy restaurant. Traffic is the number of customers arriving. Latency is how long they wait for food. Errors are wrong or cancelled orders. Saturation is how full the kitchen and tables are. A manager who watches all four knows exactly how the evening is going.
How the map applies to each part of Kafka
| Signal | Broker examples | Producer examples | Consumer examples |
|---|---|---|---|
| Traffic | Bytes in and out per second, messages in per second | Record send rate, outgoing byte rate | Records consumed rate, bytes consumed rate |
| Latency | Total request time for produce and fetch | Request latency, record queue time | Fetch latency, commit latency |
| Errors | Failed produce and fetch requests, offline partitions | Record error rate, record retry rate | Failed rebalances, commit failures |
| Saturation | Disk usage, handler idle percentage, request queue size | Buffer available bytes, buffer wait time | Records lag, time between polls |
When you build a dashboard, arrange it by these four signals, not by internal component names. People under pressure think “is it slow, is it failing, is it full?” and not “which JMX group is this from?”
5Where Each Metric Lives in the Big Picture
Knowing the journey of a message tells you where each group of metrics measures.
flowchart LR
subgraph PA[Producer application]
PM[Producer metrics]
end
subgraph BR[Kafka cluster]
BM[Broker metrics]
L[(Partition logs)]
end
subgraph CA[Consumer application]
CM[Consumer metrics]
end
PA -->|Send batches| BR
BR -->|Replicate to followers| BR
BR -->|Deliver fetches| CA
The producer batches and sends
Producer metrics tell you how many records are sent, how big the batches are, how long requests take and how many fail or are retried.
The leader broker receives and stores
Broker metrics show incoming traffic, request waiting time, processing time and disk writes.
Followers copy the data
Replication metrics show whether follower brokers are keeping up, and whether every partition still has its full set of copies in sync.
The consumer fetches and processes
Consumer metrics reveal how quickly data is fetched, how far behind the consumer is and how healthy its group is.
Because the three views describe the same journey from different positions, a problem in one place often leaves fingerprints in the others. A slow disk on a broker raises broker request times, which raises producer request latency, which may fill the producer’s buffer, and which may leave consumers waiting for fresh data. Keeping this chain in mind is the key to reading metrics well, and we will practise it in later chapters.
6Broker Metrics: The Health of the Cluster
Brokers are the heart of Kafka. Their metrics fall into a few families, and each family answers a different question.
Traffic
How much data enters and leaves each broker.
Replication and availability
Whether every partition has healthy copies and a working leader.
Request handling
How quickly and how comfortably the broker serves requests.
Storage and hosts
Disks, memory, processors and the Java runtime that carry the load.
Think of a broker as a busy post office branch. Traffic is the number of parcels arriving and leaving. Replication is whether every parcel has a spare copy in another branch. Request handling is how fast the counter staff serve customers. Storage is how full the warehouse is.
Why watch every broker separately
A cluster average can hide a struggling machine. If one broker out of six is overloaded, the average across the cluster still looks fine, yet all the partitions led by that broker suffer. Always chart broker metrics per broker, and compare brokers against each other. A broker that behaves very differently from its neighbours is worth investigating.
Showing only cluster totals on the dashboard. Problems often begin on one broker, and the total smooths them away until they become big.
7Broker Traffic Metrics
Traffic metrics tell you how busy each broker is and how that changes over time.
MessagesInPerSec
How many messages per second arrive at the broker. Useful for seeing the rhythm of your business and unusual spikes or drops.
BytesInPerSec
How many bytes per second producers write to the broker, including data copied from other brokers.
BytesOutPerSec
How many bytes per second leave the broker to consumers and follower brokers. It is usually larger than bytes in, because several consumers may read the same data.
TotalProduceRequestsPerSec
How many write requests arrive each second. Compare it with messages in per second to estimate batch sizes.
TotalFetchRequestsPerSec
How many read requests arrive each second from consumers and followers.
FailedProduceRequestsPerSec and FailedFetchRequestsPerSec
How many requests fail. In a healthy system these stay very close to zero.
How to read them
Shape matters more than the exact number
Every business has a normal daily and weekly shape. Learn it. A sudden change in that shape, such as a sharp drop in messages in during business hours, often signals that a producer has stopped or a network path is broken, long before anyone complains.
Compare bytes in with bytes out
The ratio reveals how many times each byte is read. If bytes out grow while bytes in stay flat, more consumers or more replaying is happening. That is not wrong, but it explains network growth.
Look for imbalance between brokers
If one broker has far more bytes in than the others, some partitions or topics are unevenly spread, or a few busy partitions live together. Rebalancing partitions may help.
Watching traffic metrics is like watching the number of cars on a road. A rush hour jam is normal, but an empty road at noon on a working day tells you something is wrong somewhere upstream.
Compare today’s traffic with the same hour last week, not only with a minute ago. Week-over-week comparison separates normal patterns from real anomalies.
Per-topic traffic
The same traffic metrics are also available per topic. When the total traffic grows, per-topic charts tell you which topic caused it. This is very useful for finding a noisy application, planning capacity and sharing costs between teams.
8Broker Replication and Availability Metrics
These are the most important broker metrics of all, because they tell you whether your data is safe and reachable.
A quick reminder about replication
Each partition has one leader broker, which handles reads and writes, and several follower brokers, which copy the data. The set of copies that are fully caught up with the leader is called the in-sync replicas, or ISR. If a follower falls too far behind, it is removed from the ISR. When the ISR gets smaller, your data has fewer safe copies, and you are one failure closer to losing availability or data.
Imagine an important document that must always have three photocopies in three different buildings. If one building falls behind on updating its copy, you are down to two safe copies. You need to know at once, because a second problem would leave you with just one.
UnderReplicatedPartitions
The number of partitions on this broker whose followers are not fully in sync. In a healthy cluster it stays at zero. A value that stays above zero deserves attention.
OfflinePartitionsCount
The number of partitions that have no active leader. These partitions cannot be read or written at all, so anything above zero is an emergency.
ActiveControllerCount
Whether a broker is currently acting as the cluster’s controller, which manages leaders and assignments. Across the whole cluster the sum should be exactly one.
IsrShrinksPerSec and IsrExpandsPerSec
How often replicas leave and rejoin the in-sync set. Frequent flapping suggests slow followers or network trouble.
UnderMinIsrPartitionCount
Partitions with fewer in-sync replicas than the minimum required for writes. Producers using strict acknowledgements will be rejected for these partitions.
UncleanLeaderElectionsPerSec
How often a leader was chosen from a copy that was not fully in sync. Each one risks losing acknowledged data, so it should be zero.
LeaderCount and PartitionCount
How many leaders and partition copies each broker holds. Big differences between brokers mean uneven load.
Replica fetcher MaxLag
The largest number of messages any follower on this broker is behind its leaders. Growth shows replication struggling to keep up.
flowchart TD
A[Follower falls behind] --> B[Removed from in-sync set]
B --> C[UnderReplicatedPartitions rises]
C --> D{Fewer copies than minimum needed?}
D -- Yes --> E[Writes with strict acknowledgements are rejected]
D -- No --> F[Writes continue with reduced safety]
C --> G{Leader also fails?}
G -- Yes --> H[Risk of offline partition or data loss]
G -- No --> I[Follower catches up and rejoins]
What a worrying pattern looks like
Under-replicated partitions spike briefly, then return to zero
Usually a routine event such as a broker restart or a short network hiccup. Watch the recovery time. A quick return is fine.
Under-replicated partitions stay above zero for a long time
Something is wrong: a broker is down, a disk is slow, the network between brokers is poor, or replication cannot keep up with the write rate. Start with which broker’s partitions are affected.
Active controller count is zero or greater than one
The cluster is either leaderless in management terms or suffering a confused state. Both need urgent attention because leader changes may not be processed properly.
Ignoring under-replicated partitions because “clients still work.” Clients work until the next failure. Under-replication means your safety margin has already been used up.
Note that cluster designs differ. Newer Kafka versions manage the controller through a built-in quorum instead of an external coordination service, and some controller-related metrics have different names or additional companions in that design. The ideas remain the same, so check the documentation for your version when building alerts.
9Broker Request Handling: Latency and Saturation
These metrics tell you how comfortably a broker serves its clients, and whether it is close to its limits.
The life of a request
When a producer sends data or a consumer asks for data, the broker treats it as a request. Each request passes through several stages, and Kafka measures how long is spent in each stage. This breakdown is one of the most powerful tools for finding where slowness comes from.
Request queue time
The request waits in line until a request handler thread is free. Long waits mean the broker’s threads are too busy.
Local time
The leader does its own work: for a write, appending to its log, and for a read, finding the data. Long local times often point to slow disks.
Remote time
The request waits for others. For writes that need all replicas to confirm, this is the time waiting for followers. For consumer reads, it can include a deliberate wait for enough data to arrive.
Response queue time
The finished answer waits for a network thread to send it. Long waits point to busy network threads.
Response send time
The time to actually send the answer over the network. Slow sends can indicate network limits or slow clients.
The sum of these stages is the total time of the request. It is reported separately for produce requests, consumer fetch requests and follower fetch requests. When total time is high, look at the stage breakdown to see which stage grew.
| Stage that grew | What it usually means | Where to look next |
|---|---|---|
| Request queue time | Not enough handler capacity for the load | Handler idle percentage and request queue size |
| Local time | Slow disk writes or reads, or heavy processing | Disk speed, log flush time and page cache |
| Remote time (produce) | Followers are slow to confirm | Replication lag and follower broker health |
| Remote time (consumer fetch) | Often normal, since the broker waits for new data | Only worry if it grows unexpectedly with busy topics |
| Response queue or send time | Network threads or the network itself are strained | Network idle percentage and network throughput |
Ordering a pizza has stages: waiting to place the order, cooking, waiting for the delivery rider, and the ride itself. If the whole thing takes too long, you look at which stage stretched. Request metrics let you do exactly this for Kafka.
Saturation signals
RequestHandlerAvgIdlePercent
The share of time that request handler threads are idle. Values dropping low mean the threads are almost fully busy, and queueing will begin.
NetworkProcessorAvgIdlePercent
The share of time that network threads are idle. Low values mean the broker is struggling to move bytes on and off the network.
RequestQueueSize
How many requests are waiting for a handler. A queue that keeps growing means the broker cannot keep up.
Purgatory size
How many requests are parked waiting for a condition, such as acknowledgements from followers or enough new data for a fetch.
Treat idle percentages like the free space on a highway. When they get low, everything still moves, but any extra traffic will cause a sudden jam. Act before they reach the floor, not after.
10Broker Storage and Host Metrics
Kafka stores everything on disk and leans heavily on the operating system. Host metrics explain many Kafka symptoms.
Disk space
Kafka keeps messages for a configured time or up to a configured size. If traffic grows faster than expected, the disks fill. A full disk can make a broker stop or corrupt its work, so disk usage is one of the most important numbers to watch. Chart it per broker, look at how fast it is growing and calculate how many days remain until it is full. Growth rate matters even more than the current percentage.
Disk speed and the page cache
Kafka writes to disk sequentially, which is fast, and relies on the operating system’s page cache, a part of memory used to hold recently used file data. Consumers that read recent data are usually served straight from memory. But consumers that read very old data, for example after a long outage, force the disk to work hard, and can evict useful cached data for everyone else. Watch disk read and write speed, wait times and memory use to see when this is happening.
The page cache is like the desk in front of you. Recent papers are within arm’s reach. Old papers are in the archive room down the corridor. A person asking for very old papers sends you walking to the archive again and again, and slows down everyone waiting at your desk.
Disk usage and growth
How full each disk is and how quickly it is filling. Alert early, with plenty of time to react.
Disk input and output
How busy and how slow the disks are. High wait times point to a disk bottleneck.
Processor use
Sustained high use can come from compression, encryption or too many connections.
Network throughput
How close the network cards are to their limit, on both incoming and outgoing directions.
Java memory and garbage collection
Long garbage collection pauses can freeze a broker and cause followers to drop out of the in-sync set.
Open file counts
Kafka keeps many files open. Running out of allowed file handles causes strange failures.
Log flush metrics
Kafka also reports how often and how long its log flushes to disk take. In most setups Kafka lets the operating system decide when to flush, so these numbers are informational, but unusually high flush times can reveal a struggling disk.
Watching only the current disk percentage. A disk at seventy percent that fills by five percent an hour is in worse trouble than a disk at ninety percent that is barely growing. Always check the trend.
11Producer Metrics: The View From the Sender
A producer application sees the cluster through its own eyes. Its metrics show how well it is delivering messages.
A quick reminder of how a producer works
A Kafka producer does not send each message on its own. It gathers messages into batches in memory, one waiting area per partition, and sends a batch when it is full or when a small waiting time has passed. A background thread carries the batches to the brokers and waits for acknowledgements. Producer metrics describe each step of this process.
A producer is like a courier who collects parcels at a counter, packs them into vans, and drives them to the depot. How full the vans are, how long the drive takes, how many parcels come back undelivered and how crowded the counter is are all things a good courier manager wants to know.
Throughput and batching
How much is sent and how efficiently it is packed.
Latency
How long sending takes from the producer’s point of view.
Errors and retries
How often sending fails or has to be repeated.
Buffers and throttling
Whether the producer is running out of room or being slowed down by the cluster.
Each producer reports its metrics under its own client identifier. Give every application a meaningful client identifier, otherwise the metrics of many producers blur together and become hard to read.
12Producer Throughput and Batching Metrics
Efficient batching is the secret of a fast producer. These metrics show how well it is doing.
record-send-rate
How many records per second the producer sends. This is your main throughput number for the application.
outgoing-byte-rate
How many bytes per second leave the producer, including protocol overhead.
request-rate
How many requests per second the producer sends. Fewer requests for the same data usually means better batching.
batch-size-avg
The average size in bytes of a batch. Compare it with the configured maximum to see how full batches are.
records-per-request-avg
The average number of records in each request. Higher usually means more efficient use of the network.
compression-rate-avg
How much batches shrink when compressed, as a ratio. Lower values mean better compression.
Reading the batching story
Small average batches with a high request rate
The producer is sending many small requests. It may be waiting too little before sending, spreading data over too many partitions, or sending at a low volume. Increasing the small waiting time can create fuller batches at little cost.
Batches consistently at the maximum size
Batches fill up before the waiting time ends. A larger maximum batch size may help throughput if memory allows.
Poor compression ratio
Data that is already compressed or random, such as images, gains little from compression. Then the processor time spent is wasted, and compression could be switched off.
Batch size is how full the delivery vans are. A van that leaves with two parcels wastes fuel. A van that leaves full is efficient. The average batch size metric is the van fullness gauge.
When you change batching settings, watch batch size, request rate and latency together. They move as a team, and improving one while ignoring the others can hurt your application.
13Producer Latency, Errors and Retries
Speed is only useful if messages arrive. These metrics show how reliably and how quickly.
request-latency-avg and request-latency-max
How long a request takes from being sent until the acknowledgement returns. Rising values usually mean brokers or the network are under strain.
record-queue-time-avg
How long records wait in the producer’s memory before being sent. It includes the deliberate small waiting time and any delay caused by busy connections.
record-error-rate
How many records per second fail permanently. This should be zero, and any sustained value means data is being lost or rejected.
record-retry-rate
How many records per second had to be sent again. Some retries are normal during restarts, but a steady stream signals instability.
connection-count and metadata-age
How many connections are open, and how old the producer’s picture of the cluster is. Very old metadata can hint at trouble refreshing.
Why retries matter
When a send fails temporarily, the producer retries automatically. That is helpful, but retries have costs. They add delay, they load the brokers a second time, and, unless the producer is set to avoid duplicates, they can create duplicate messages. A rising retry rate is often the first visible symptom of a problem that will later become failures. Treat it as an early warning.
flowchart TD
A[Producer sends batch] --> B{Broker acknowledges in time?}
B -- Yes --> C[Record delivered]
B -- No --> D{Error can be retried?}
D -- Yes --> E[Retry counted, delay added]
E --> A
D -- No --> F[Record error counted]
E --> G{Retry time exhausted?}
G -- Yes --> F
Watching only the error rate. Retries can hide trouble for a long time, so the error rate stays at zero while latency creeps up and the retry rate climbs. Watch all three.
Latency as the application sees it
Your application does not care about broker internals. It cares about how long it waits. If your application blocks while sending, high producer latency directly slows your users. Compare the producer’s request latency with the broker’s own produce total time. If the producer’s number is much larger, the extra delay lives in the network or in the producer’s own queueing, not inside the broker.
14Producer Buffers and Throttling
A producer has a limited amount of memory. When it runs short, the application starts to feel it.
The buffer
The producer keeps unsent batches in a memory area of fixed size. If the application produces faster than the cluster accepts, the buffer fills. When it is full, the send call must wait, and if the wait is too long it fails with an error. This is a form of automatic back-pressure, and the metrics let you see it building before it hurts.
buffer-available-bytes
How much buffer memory is still free. If it trends toward zero, the producer is outrunning the cluster.
buffer wait time
How long application threads spend waiting for buffer space. Any noticeable value means producing is being slowed by a full buffer.
waiting-threads
How many application threads are blocked waiting for buffer memory right now.
produce-throttle-time-avg
How long the broker asked the producer to slow down because it exceeded a quota. Non-zero values mean the producer is being deliberately held back.
The buffer is the loading dock in front of the depot. When vans leave quickly, the dock stays clear. When the road is jammed, parcels pile up, and eventually the dock is full and workers must stand idle. Watching the free space on the dock warns you long before workers stop.
Throttling: a message from the cluster
Cluster administrators can set quotas that limit how much data a client may send or read per second, so that one noisy application cannot harm the rest. When a producer exceeds its quota, the broker delays its responses, and the producer records the time it was held back. A throttled producer is not broken, it is being told to slow down. The fix is either to reduce its rate or to ask for a larger quota.
When a producer suddenly becomes slow but brokers look healthy, check throttle time first. It is a quick way to discover that a quota, not a fault, is the cause.
15Consumer Metrics: Lag, the Most Famous Number
For consumers, one number stands above the others. Understanding it well is worth the effort.
What is consumer lag?
Every message in a partition has a position number called an offset. The newest message sits at the end of the log. A consumer keeps track of how far it has read. Consumer lag is the distance between the end of the log and the consumer’s position, counted in messages. It answers a simple question: how far behind is this consumer?
Imagine a conveyor belt bringing letters to a clerk. The number of unopened letters piled up in front of the clerk is the lag. A small, steady pile is normal. A pile that keeps growing means the clerk is slower than the belt.
flowchart LR
A[Start of log] --> B[Consumer position]
B -->|Lag = messages not yet read| C[End of log]
Reading lag correctly
A constant small lag is normal
A consumer is always slightly behind, because new messages keep arriving. A steady small gap means it keeps up.
A growing lag is the warning sign
If lag rises over time, the consumer is slower than the producers. Unless it catches up, it will fall further behind, and results become stale.
A sudden jump followed by recovery
Often caused by a burst of traffic, a restart or a rebalance. Watch how quickly it drains.
Lag stuck at a high, flat value
The consumer may be stuck on a message it cannot process, or it may have stopped entirely. A flat line with no progress is worse than a slowly moving one.
Where to see lag
Each consumer reports its own maximum lag across the partitions it reads, and per-partition lag as well. Lag is also visible from outside, by comparing the group’s committed positions with the end of each log. Many teams collect lag from outside with a dedicated monitor, because it also works when a consumer has died and stopped reporting anything about itself.
Relying only on numbers reported by the consumer itself. If the consumer crashes, its own metrics disappear, and your chart shows nothing instead of a scream. Also collect lag from outside the consumers.
Lag in messages versus lag in time
A lag of ten thousand messages may mean two seconds on a fast topic and two hours on a slow one. Business users care about time. Where possible, estimate how long the backlog would take to drain, or how old the oldest unread message is. That number is far easier to explain and to set alerts on.
16Consumer Fetch and Processing Metrics
Lag says that something is slow. Fetch and poll metrics help explain where.
How a consumer works, briefly
A consumer runs a loop. It asks the brokers for a batch of messages, which is a fetch, then processes them, and then asks again by calling poll. If it takes too long to come back to poll, the group decides the consumer is dead and reassigns its work. So the balance between fetching and processing time is central.
records-consumed-rate and bytes-consumed-rate
How many records and bytes per second this consumer reads. Compare with the producing rate to know whether it keeps up.
fetch-rate
How many fetch requests per second the consumer makes.
fetch-size-avg and records-per-request-avg
How much data each fetch brings back. Very small fetches mean many round-trips for little data.
fetch-latency-avg
How long fetch requests take. It includes a deliberate wait when the broker holds the request until data is available, so interpret it with care.
time-between-poll and last-poll-seconds-ago
How long it has been between calls to poll. If this approaches the allowed maximum, the consumer risks being removed from its group.
poll-idle-ratio
The share of time the consumer spends waiting in poll rather than working. A very low ratio means the application is busy processing and rarely waiting for data.
fetch-throttle-time-avg
How long the broker delayed the consumer because of read quotas.
flowchart TD
A[Lag is growing] --> B{Is poll idle ratio very low?}
B -- Yes --> C[Application processing is the bottleneck]
B -- No --> D{Is fetch latency high?}
D -- Yes --> E[Broker or network is slow]
D -- No --> F{Are all partitions being read?}
F -- No --> G[Group assignment or a stuck consumer]
F -- Yes --> H[Add consumers up to partition count or tune fetch sizes]
A clerk who spends most of the time working and rarely waits for new letters is fully busy. A clerk who mostly waits is underused. The poll idle ratio tells you which clerk you have.
If a consumer is busy and lag grows, adding more consumers helps only up to the number of partitions in the topic. Beyond that, extra consumers sit idle, and the fix must be faster processing or more partitions.
17Consumer Group Health: Rebalances and Commits
Consumers work in groups. The health of the group is as important as the health of each member.
What a rebalance is
Consumers in a group share the partitions of a topic. When a consumer joins, leaves, crashes or is considered dead, the group performs a rebalance and redistributes the partitions. During a rebalance, some or all consumers may pause reading for a short time. Occasional rebalances are normal. Frequent ones hurt throughput and increase lag.
A rebalance is like redistributing checkout lanes when a cashier arrives or leaves. It is fine once in a while, but if lanes are reshuffled every few minutes, customers spend more time waiting for the reshuffle than being served.
rebalance-total and rebalance rate
How many rebalances have happened and how often. A rising rate points to unstable consumers.
rebalance-latency-avg
How long each rebalance takes. Long rebalances mean long pauses in reading.
failed-rebalance-total
How many rebalances failed and had to be retried. Any steady growth needs investigation.
assigned-partitions
How many partitions this consumer currently owns. Big differences within a group show uneven distribution, or idle members with none.
heartbeat-rate
How often the consumer signals to the group that it is alive. Missing heartbeats lead to the consumer being removed.
commit-rate and commit-latency-avg
How often and how fast the consumer saves its position. Slow or failing commits risk repeated processing after restarts.
Common causes of frequent rebalances
Processing takes too long between polls
The consumer does not call poll in time and is judged dead, even though it is busy. Shorten batches or allow more time.
Unstable applications
Crashes, out-of-memory errors and frequent restarts make consumers leave and rejoin again and again.
Long pauses in the application
Garbage collection freezes may stop heartbeats long enough for the group to give up on the consumer.
Deployments
Rolling out new versions restarts consumers one by one. Careful rollout settings and cooperative assignment strategies reduce the disruption.
Treating rebalances as rare background noise. In some systems, a hidden rebalance storm is the real reason for lag, and fixing it is worth more than adding machines.
18Reading the Three Views Together
The real skill of monitoring is connecting a symptom on one side to its cause on another.
| What you notice | Producer view | Broker view | Consumer view | Likely cause |
|---|---|---|---|---|
| Data arrives late | Normal | Normal | Lag growing, poll idle ratio low | Consumer processing is too slow |
| Sends are slow | Latency and retries rising | Produce total time up, local time high | May show lag later | Broker disk is slow |
| Sends fail with strict acknowledgements | Record errors up | Under-replicated and under-minimum partitions | Fresh data stops appearing | Replicas out of sync |
| Sudden drop in traffic | Send rate fell | Messages in fell on all brokers | Lag shrinks toward zero | Producer application stopped or was blocked |
| Everything slows during deployments | Retries briefly rise | Leader changes and ISR flapping | Rebalances spike | Rolling restart without care |
| One partition always lags | Uneven key distribution possible | One broker has higher load | One consumer holds a heavy partition | Hot key or uneven partitioning |
A walk-through
Imagine that a business report is late every morning. You open the consumer dashboard and see that lag grows for hours after midnight. You check the poll idle ratio: it is near zero, meaning consumers are busy all the time. Fetch latency is normal, and broker metrics look calm. The story is now clear: the cluster is fine, and the consumer application cannot process the night-time surge fast enough. The fix lies in the consumer’s processing speed or in the number of partitions and consumers, not in the brokers. Without the three views, the team might have wasted a day tuning the wrong thing.
19Alerting: Which Metrics Deserve to Wake Someone Up
Too few alerts means missed problems. Too many alerts means people ignore them all. The trick is to alert on what truly matters.
Two kinds of alerts
Urgent alerts that page a person
Reserved for situations where users are already affected or data is at risk right now, and a human must act soon.
Warning alerts that create a ticket
For slow-building problems that need attention during working hours, such as steadily growing disk use.
| Metric | Concerning condition | Severity idea |
|---|---|---|
| Offline partitions | Anything above zero | Urgent |
| Active controller count | Cluster total not equal to one | Urgent |
| Under-replicated partitions | Above zero for more than a few minutes | Urgent, or warning if very short-lived |
| Under minimum in-sync replicas | Above zero | Urgent for topics with strict write rules |
| Unclean leader elections | Any occurrence | Urgent, since data may be lost |
| Disk usage | High percentage, or projected to fill within days | Warning first, then urgent |
| Request handler idle percentage | Persistently low | Warning |
| Produce and fetch total time | High percentile above your agreed target | Warning or urgent by business impact |
| Producer record errors | Sustained above zero | Urgent for important data |
| Consumer lag or lag time | Growing steadily or above the business tolerance | Warning, urgent when deadlines are at risk |
| Consumer group rebalances | High rate over a period | Warning |
Exact thresholds depend on your workload and your promises to users, so treat the table as a starting point and tune it against real history. Base alerts on duration and trend, not only on single readings. A metric that touches a bad value for one second is often harmless, while a metric that stays bad for ten minutes is not.
flowchart LR
M[Metric readings] --> R{Rule: bad value for long enough?}
R -- No --> OK[No alert]
R -- Yes --> S{User impact or data risk now?}
S -- Yes --> PG[Page the on-call person]
S -- No --> TK[Create a ticket]
For every alert, write down what it means, why it matters and what to check first. An alert without a next step just creates worry.
20Designing Useful Dashboards
A dashboard is a story told in charts. A cluttered one hides the plot.
Start with an overview page
Show only the vital signs: offline partitions, under-replicated partitions, active controller, total traffic, worst consumer lag and error rates.
Give each broker its own view
Line up per-broker charts side by side so outliers stand out immediately.
Create views per application
Each producer and consumer team gets a page for its own client metrics, tagged with client and group names.
Show trends over days and weeks
Include long time ranges for capacity planning, and week-over-week comparison lines.
Mark events on the charts
Add markers for deployments, restarts and configuration changes so that cause and effect are easy to spot.
Keep charts few and purposeful
Each chart should answer one clear question, with a title that says what it shows.
Use consistent time ranges
Aligned charts let you see cause and effect across brokers and clients.
Walls of hundreds of graphs
Too many charts hide the important ones and slow people down in an incident.
Unlabelled axes and mystery units
Always show units such as bytes per second or milliseconds, so the meaning is instant.
21Best Practices and Anti-Patterns
Habits that keep monitoring trustworthy, and traps that make it useless.
Good habits
Monitor all three sides
Collect broker, producer and consumer metrics, plus host and Java runtime metrics.
Learn your normal
Know the usual daily and weekly patterns, so that anomalies are obvious.
Prefer trends and durations over single readings
Alert on values that stay bad, or grow steadily, rather than on brief blips.
Name clients and groups meaningfully
Good client identifiers and group names make every chart readable and every alert traceable to an owner.
Measure lag from outside as well
Use an independent lag monitor so a dead consumer is noticed rather than silent.
Review and tune alerts regularly
Remove noisy alerts and add missing ones after every incident.
Anti-patterns to avoid
Problem
Monitoring only the brokers and assuming that healthy brokers mean healthy applications.
Why It’s Harmful
Producer and consumer problems, such as growing lag, full buffers and rebalance storms, are invisible from the broker side alone.
Correct Approach
Collect client-side metrics from every important producer and consumer, and view them next to the broker metrics.
Problem
Alerting on every metric with tight thresholds until dozens of alerts fire each day.
Why It’s Harmful
People learn to ignore the noise, and the one real emergency is lost among false alarms.
Correct Approach
Alert only on user impact and data risk, with durations and trends, and keep everything else on dashboards.
Problem
Looking only at cluster-wide averages and totals.
Why It’s Harmful
One overloaded broker or one lagging partition disappears inside the average until it becomes a large problem.
Correct Approach
Chart per broker, per partition where useful, and watch the maximum and high percentiles next to the average.
Problem
Setting alert thresholds copied from a blog post and never adjusting them to the real workload.
Why It’s Harmful
What is dangerous for one system may be perfectly normal for another, so the alerts are either useless or constantly noisy.
Correct Approach
Use general advice as a starting point, then tune every threshold against your own history and your business targets.
Problem
Ignoring the host machines and the Java runtime because “we only care about Kafka numbers.”
Why It’s Harmful
Many Kafka symptoms are caused by disks, memory pressure, garbage collection or network limits, and only host metrics reveal them.
Correct Approach
Collect machine and runtime metrics alongside Kafka’s own, and read them together.
22Real-World Scenarios
Let us see how the metrics tell stories in situations that teams meet all the time.
A broker restarts during a deployment
Under-replicated partitions rise while followers catch up, in-sync replica counts shrink and expand, and producers show a short burst of retries. Everything returns to normal within minutes. The metrics confirm a healthy recovery, and the team learns how long a restart takes to settle, so the next rolling restart waits long enough between machines.
A disk slowly fills over a weekend
Disk usage on one broker climbs faster than on others, because a new topic with large messages was created without a retention limit. A growth-based alert warns on Friday afternoon, not Sunday night when the disk is full, and the team adjusts retention before any outage.
A nightly batch job overwhelms consumers
Every night at one o’clock, traffic multiplies. Lag grows for two hours and drains by morning. Consumer metrics show busy processing and low idle ratio. The team adds partitions and consumers before the busy hours, and the morning reports are on time again.
A single hot customer creates an uneven partition
One partition receives far more traffic because a very active customer’s messages all share a key. Per-partition lag shows one consumer far behind while the others are idle. The team changes the key design to spread the load.
A slow network link between data centres
Replica lag rises, in-sync replica sets flap, and produce total time grows in the remote-time stage. Host network metrics confirm a saturated link. Kafka metrics pointed to replication, and network metrics revealed why.
23Frequently Asked Questions
If you must choose one on the broker side, choose under-replicated partitions, because it reflects the safety of your data. On the consumer side, choose consumer lag, and on the producer side, the error and retry rates.
Zero in steady state. Short spikes can happen during restarts or brief network issues, but a value that stays above zero means followers are not keeping up and needs investigation.
Lag is the number of messages a consumer has not yet read. Some lag is normal, because new messages keep arriving. Growing or stuck lag is the warning sign.
Because healthy brokers do not guarantee happy applications. Full producer buffers, slow processing in consumers and rebalance storms are visible only from the client side.
Averages hide slow requests. High percentiles and maximums reveal the slow tail that some of your users or applications actually experience.
Kafka publishes them through JMX. A helper component reads them and passes them to a monitoring system, which stores them, draws charts and sends alerts.
Consumer fetch requests may be held by the broker on purpose until enough data arrives or a waiting limit passes. This waiting is part of normal operation, so judge fetch latency together with throughput and lag.
The broker’s handler threads are almost always busy. Requests begin to queue, latency rises, and any extra traffic can cause a sudden slowdown. Investigate load, disk speed and configuration before it gets worse.
During a rebalance, consumers may pause reading, so frequent rebalances reduce throughput and increase lag. Investigate unstable consumers, long processing between polls and deployment practices.
Mostly they are stable, but some are added, renamed or deprecated over time, and clusters without an external coordination service expose additional controller metrics. Always check the documentation for the version you run.
As few as possible while still catching real user impact and data risk. Put everything else on dashboards. Review alerts after every incident and remove those that create noise.
Yes, if the library exposes the standard client metrics. If it hides them, add an external lag monitor so that you are never blind to how far behind a consumer group is.
24Summary and Key Takeaways
Kafka metrics are the dashboard of your streaming platform. The broker side tells you about traffic, replication safety, request handling and storage. The producer side shows how efficiently and reliably applications send data. The consumer side reveals how well applications keep up, above all through lag, and how healthy their groups are. No single view tells the whole story. Problems usually leave clues in several places, and the skill lies in following those clues from the symptom to the cause. With sensible alerts, clear dashboards and the habit of watching trends, you can catch trouble long before your users do.
Key Takeaways
- Watch all three sides — broker, producer and consumer metrics, plus host and Java runtime metrics, together give the full picture.
- Use the four golden signals — traffic, latency, errors and saturation organise hundreds of metrics into four questions.
- Replication health comes first on brokers — offline partitions, under-replicated partitions, active controller count and unclean elections protect your data.
- Request time breakdowns find the slow stage — queue, local, remote and response times show where slowness lives.
- Producers need batching, retry and buffer views — batch size, retry rate, error rate, buffer space and throttle time tell the sender’s story.
- Consumer lag is about trend — steady small lag is fine, growing or stuck lag is the warning, and lag measured from outside catches dead consumers.
- Rebalances are a hidden cost — frequent rebalances cause pauses and lag, so track their rate and causes.
- Alert on impact, not on everything — use durations and trends, tune thresholds to your workload and give every alert a clear next step.