What Is kafka-consumer-groups.sh?
A beginner-friendly guide to the command-line tool that shows how far each consumer group has read, how far behind it is, who is in it, and how to safely move its bookmarks when something goes wrong.
Imagine a large school where teams of teachers mark piles of exam papers. Each team keeps a shared notebook that records the last paper it finished. A supervisor walks the corridors with a clipboard and needs answers to simple questions. Which teams exist? Who is on each team? How tall is the pile of unmarked papers waiting for each team? Has a team stopped working? And, occasionally, the supervisor must correct a notebook, for example telling a team to start again from the first paper after a marking mistake was found. In Apache Kafka, the teams are consumer groups, the notebooks are committed offsets, and the supervisor’s clipboard is a small command-line tool called kafka-consumer-groups.sh. This guide explains what it shows, what it can change, and how to use it safely, in simple words.
1The Background: Groups, Bookmarks, and Lag
To understand a tool that inspects consumer groups, we first need to recall what a consumer group is and what it remembers.
Topics, partitions, and consumers
Apache Kafka stores streams of events, such as orders, payments, clicks, or sensor readings, in topics. Each topic is split into partitions, and every event in a partition has a position number called an offset. Applications that read events are called consumers.
Consumer groups share the work
Consumers that share the same group name form a consumer group. Kafka divides the partitions of a topic among the members of the group, so that each partition is read by exactly one member at a time. Different groups read the same topic independently, each keeping its own progress.
The bookmark
As a group reads, it periodically saves the offset it has reached for each partition. This saved number is the committed offset, and it means “everything before this has been handled”. The bookmarks are stored inside Kafka, in a special internal topic. If a consumer crashes, the replacement starts from the last saved bookmark.
Lag: the height of the unmarked pile
For each partition, the newest event has a position called the log end offset. The difference between the log end offset and the group’s committed offset is called lag. It says how many events are waiting to be processed. Small, steady lag is normal, because events arrive all the time. Growing lag means the group cannot keep up.
flowchart LR
A["Events already handled - up to committed offset"] --> B["Lag - events waiting to be processed"]
B --> C["Log end offset - newest event in the partition"]
Picture a teacher marking exam papers from a stack. The bookmark is the last paper marked. The newest paper on the stack is the log end. The number of papers between them is the lag. A supervisor who wants to know how a team is doing simply looks at that gap.
The bookmarks belong to the group, not to individual consumers. That is why they can be inspected and changed from outside, by a tool that never touches the consumers themselves.
2What Is kafka-consumer-groups.sh?
It is a small program, shipped with Kafka, that lets you look at and manage consumer groups from a terminal.
The simple definition
kafka-consumer-groups.sh is a command-line script in the bin folder of every Kafka download. When you run it, it connects to a Kafka cluster, asks about consumer groups or asks to change their saved positions, and prints the result. It can list all groups, describe a group’s progress and members, show a group’s state, delete a group, and reset a group’s bookmarks.
Where it comes from
It belongs to a family of small administrative scripts shipped with Kafka, each starting with “kafka-” and doing one job. On Windows, the same tools appear as batch files. In some packaged distributions, such as Confluent’s, the script is provided without the “.sh” ending, but behaves the same.
What happens when you run it
The script starts a small Java program that uses Kafka’s administrative client library. It contacts the brokers you name, sends a request such as “describe this group”, and prints the reply. For a consumer group, the broker that acts as the group coordinator holds the group’s membership and state, and the internal offsets topic holds its bookmarks. The tool reads the bookmarks, and compares them with the newest events in each partition, to calculate lag.
flowchart LR
U["You in a terminal"] --> S["kafka-consumer-groups.sh"]
S --> A["Kafka admin client library"]
A --> B["Bootstrap broker"]
B --> GC["Group coordinator"]
A --> OT["Internal offsets topic - bookmarks"]
A --> LP["Partition logs - newest offsets"]
The supervisor’s clipboard does not do any marking. It only reads the team notebooks and counts the papers left in the stack. The tool is a read-mostly window onto the group’s records, with a few careful editing powers.
3How the Tool Finds Your Cluster
Before anything else, the tool must know where the cluster is and how to log in.
The bootstrap server option
Every use requires the address of at least one broker through the bootstrap server option. It is like the first phone number in a contact book: the tool contacts that broker, which tells it about the rest of the cluster. Giving two or three addresses is wise, in case one broker is down.
Talking to a secured cluster
Production clusters normally require encrypted connections and proof of identity. The tool supports this through the command config option, which points to a small properties file holding the connection and login settings. Without it, a secured cluster will refuse the tool.
Permissions matter
What you can see and do depends on the identity you present. Describing a group needs permission to read information about that group and its topics. Deleting a group or resetting its bookmarks needs stronger rights over the group. On a secured cluster, the same command may work for one person and be refused for another.
| Situation | What You Need to Give the Tool |
|---|---|
| Local practice cluster with no security | Just a bootstrap server address |
| Production cluster with encryption and login | A bootstrap server address and a properties file with security settings |
| Fine-grained access rules | An identity that has been granted the needed rights on the group and its topics |
To walk the school corridors, the supervisor needs the school address and a badge. The badge also decides which staff rooms can be entered and which notebooks may be edited.
Concluding that a group does not exist because the list is empty. On a secured cluster, an identity without the right permissions may simply not be allowed to see it.
4The Main Actions at a Glance
The tool has a small set of actions. Each run performs one of them.
List
Shows the names of the consumer groups known to the cluster.
Describe
Shows a group’s progress per partition, its lag, its members, or its state.
Reset offsets
Moves a group’s bookmarks to a chosen position, such as the start, the end, or a point in time.
Delete
Removes an inactive group and its saved bookmarks from the cluster.
Delete offsets
Removes a group’s saved bookmarks for particular topics, without deleting the group itself.
The supporting options
| Option | What It Does | Used With |
|---|---|---|
| bootstrap server | Tells the tool which broker to contact | Every action |
| command config | Points to a file with security settings | Every action on a secured cluster |
| group | Names the group to act on | Describe, reset, delete |
| all groups | Acts on every group | Describe, reset, delete |
| topic | Limits the action to a topic, or to particular partitions of it | Reset, delete offsets |
| all topics | Acts on every topic the group has bookmarks for | Reset |
| members | Shows the consumers currently in the group | Describe |
| state | Shows the group’s current state and coordinator | Describe |
| verbose | Adds extra details, such as partition assignments | Describe with members |
| dry run and execute | Preview a change, or actually apply it | Reset |
| export | Writes the planned new bookmarks to a file | Reset |
The supervisor’s clipboard has a few sections: a list of teams, a detail page for each team, a form for correcting a notebook, and a form for closing a team down. Modifiers such as “preview only” prevent accidents.
Running the tool with its help option prints the complete, current option list for your version. Options are added and retired over time, so this is the most reliable reference.
5Listing Groups
Listing is the simplest action: it answers “which consumer groups exist?”
What you see
The list action prints the name of every group the cluster knows, one per line. On a busy cluster this can be a long list, including groups of many teams, groups created by tools, and groups left over from old experiments.
Why a group appears even when nobody is running
A group is remembered as long as its bookmarks are stored. A group with no active members can still appear in the list until its bookmarks expire. So the list shows groups that are working now and groups that stopped some time ago.
Practical uses
Finding the exact group name
Before inspecting a group, confirm its exact name. Names are case-sensitive, and small differences point to different groups.
Auditing what is running
Compare the list with your documentation to find forgotten, misnamed, or unexpected groups.
Spotting accidental groups
Console tools and quick tests often create groups with random names. A cluster crowded with these is a sign of untidy habits.
Listing groups is like reading the register of every marking team in the school, including teams that are on holiday and teams formed for a one-day experiment that nobody has closed.
Assuming that every listed group is active. A listed group may have no members at all. Check its state before drawing conclusions.
6Describing a Group: Reading Progress and Lag
Describe is the most used action. It answers “how is this group doing?”
The default view: offsets and lag
The basic description prints one line for every partition the group has bookmarks for. Each line shows the group name, the topic, the partition number, the committed offset, the log end offset, the lag, and, if the partition is currently owned by a running consumer, the identity of that consumer, its host, and its client name.
Topic and partition
Which slice of which topic this line describes.
Current offset
The group’s committed bookmark for that partition: the next event it will read.
Log end offset
The position just after the newest event in the partition.
Lag
The number of events between the two, meaning how many are waiting.
Consumer identity
Which member currently owns this partition, with its host and client name. Missing when nobody owns it.
Reading the lag
| What You See | What It Usually Means | What to Do |
|---|---|---|
| Small lag on every partition, changing up and down | The group keeps pace | Nothing to do |
| Lag growing steadily on all partitions | Consumers are too slow for the incoming load | Speed up processing or add members, up to the partition count |
| Large lag on one partition only | A hot key, a stuck consumer, or a poisonous event | Investigate the owner of that partition and the keys feeding it |
| Lag is large but the consumer columns are empty | Nobody is currently reading; the group has stopped | Check whether the application is running |
| Lag suddenly jumps to zero | Someone reset the bookmarks to the newest position, or events expired | Find out what changed, since events may have been skipped |
flowchart TD
D["Describe the group"] --> Q1{"Is lag growing over time?"}
Q1 -->|"No"| H["Healthy"]
Q1 -->|"Yes"| Q2{"On all partitions?"}
Q2 -->|"Yes"| S["Consumers too slow: tune or add members"]
Q2 -->|"No"| Q3{"Does the lagging partition have an owner?"}
Q3 -->|"Yes"| K["Look for a hot key or stuck processing"]
Q3 -->|"No"| N["Nobody owns it: check group state and members"]
A supervisor looking at the marking teams notes how tall each pile is. If every pile grows, the school needs more teachers. If only one pile is huge, that particular teacher is stuck or has been given very hard papers. If a pile has no teacher name beside it, nobody is marking it at all.
The report is a snapshot of a single moment. Run it several times a minute apart to see whether lag is growing, shrinking, or steady. A single number tells little; the trend tells a lot.
7Describing Members and State
Besides progress, the tool can show who is in the group and what the group is doing right now.
The members view
The members option lists the consumers currently in the group. Each line shows the consumer’s identity, its host, its client name, and how many partitions it owns. With the verbose option, it also lists exactly which partitions each member owns. In groups that use stable, static member names, the fixed name of each member also appears.
What the members view teaches
Uneven sharing
If one member owns many more partitions than the others, work is unevenly shared, perhaps because of the assignment strategy or a recent change.
Idle members
A member owning zero partitions is a spare. It happens when there are more members than partitions.
Unexpected members
A member with an unfamiliar host or client name may be a forgotten test program, or a second copy of an application started by mistake.
The state view
The state option shows the group’s current state, its coordinator, the assignment strategy, and the number of members. The state tells you what the group is doing at this moment.
| State | Meaning | Typical Concern |
|---|---|---|
| Stable | Members are in place, partitions are assigned, and reading is under way | None; this is the healthy state |
| Preparing rebalance | A change happened, and the group is gathering members for a reshuffle | Brief is normal; long means a slow member is holding things up |
| Completing rebalance | The new plan is being handed out to members | Brief is normal; long can point to trouble with the leader member |
| Empty | The group exists but has no active members, though it may still hold bookmarks | Applications are stopped, or crashed |
| Dead | The group has been removed or is being removed | Group was deleted or has expired |
stateDiagram-v2
[*] --> Empty
Empty --> PreparingRebalance: First member joins
PreparingRebalance --> CompletingRebalance: Members have rejoined
CompletingRebalance --> Stable: Assignments delivered
Stable --> PreparingRebalance: Member joins, leaves, or fails
Stable --> Empty: All members leave
Empty --> Dead: Group deleted or offsets expire
A team can be hard at work, gathered in a short meeting to reassign tasks, waiting for the new task list to be handed out, or empty because everyone has gone home. The state view tells the supervisor which of these it is right now.
Ignoring a group that sits for a long time in the preparing or completing rebalance states. That is a sign that a member is slow to rejoin or that the group is stuck in repeated reshuffles, and lag will usually be growing too.
8Resetting Offsets: Moving the Bookmarks
Reset is the most powerful action of the tool. It can rewind time for a group or push it forward.
Why anyone would reset a group
Reprocess after a bug fix
A consumer handled events wrongly for two days. After fixing the code, the team moves the group back to before the mistake, so the events are processed again correctly.
Start a new consumer with history
A new application wants to read everything still stored, so its group is set to the earliest position.
Skip a burst of unwanted events
A flood of test or corrupt events arrived, and the team decides to skip them by moving the group past that point.
Recover after data loss elsewhere
A downstream database was restored to an earlier time, and the group is moved back to match, so the missing events are replayed.
Where to move the bookmark
| Choice | What It Does | Typical Use |
|---|---|---|
| To earliest | Moves to the oldest event still stored | Reprocess everything available |
| To latest | Moves to the end, skipping everything currently stored | Ignore the backlog and start fresh |
| To a date and time | Moves to the first event at or after that moment | Rewind to just before an incident |
| To a specific offset | Moves each chosen partition to a given position | Precise repair of a known spot |
| Shift by a number | Moves forward or backward by a number of events from the current position | Replay or skip a small, known amount |
| By a duration | Moves back by a length of time from now | Replay the last few hours |
| To current | Keeps the present bookmarks | Useful for writing out the current state to a file |
| From a file | Moves each partition to the positions written in a file | Repeating an earlier plan or applying a prepared one |
flowchart LR
E["Earliest stored event"] --- M1["Rewind to a time or offset"] --- C["Current bookmark"] --- M2["Shift forward"] --- L["Latest event"]
Correcting a team’s notebook is like moving a bookmark in a long book. You can put it back to the first page, forward to the last page, or to the page reached last Tuesday. The book itself never changes, only the bookmark does.
9The Safety Rules of Resetting
Because a reset can cause large reprocessing or permanent skipping, the tool builds in safeguards. Understand them well.
Rule 1: The group must be inactive
The tool refuses to reset a group that has active members. Otherwise, the running consumers would keep their own positions in memory and later overwrite the new bookmarks. Stop all consumers of the group first, or wait until the group’s state is empty.
Rule 2: The default is a preview
By default, a reset only shows what it would do, without changing anything. This preview, called a dry run, prints the planned new positions for every partition. Only when you add the execute option does the tool actually save the new bookmarks. Always look at the preview first.
Rule 3: Record the old positions
Before executing a reset, save the current bookmarks, for example by writing them to a file with the export option. If the reset turns out to be a mistake, that file lets you put the bookmarks back where they were.
Decide the target
Agree exactly where the group should restart, and which topics and partitions are affected.
Stop the consumers
Shut down every member of the group and confirm through the state view that the group is empty.
Save the current bookmarks
Export the present positions to a file so you can undo the change.
Run the preview
Run the reset without the execute option and read the planned positions carefully.
Execute
Repeat the command with the execute option. The new bookmarks are saved.
Verify
Describe the group again to confirm that the positions are as planned.
Restart the consumers and watch
Start the members and watch lag and any downstream systems, since reprocessing may create heavy load or duplicates.
Before altering a bank’s official ledger, an auditor makes sure nobody is writing in it at that moment, photocopies the pages to be changed, writes the intended change on a draft for review, and only then makes it official. The dry run and the export are the draft and the photocopy.
Running a reset with the execute option straight away, without reading the preview. A wrong topic name, a wrong time zone, or a wrong group can reprocess or skip millions of events in an instant.
10What Happens After a Reset
Changing a bookmark is easy. Living with the consequences takes thought.
Moving backwards: reprocessing
When a group is rewound, its consumers will read events they have already handled. If their processing is safe to repeat, no harm is done. If not, duplicates appear: emails sent twice, records inserted twice, totals counted twice. Before rewinding, check that the consumers, and the systems they write to, tolerate repeats, or clean up the affected downstream data first.
Moving forwards: skipping
When a group is moved forward, everything in the skipped range is never processed by that group. Those events remain in Kafka until retention removes them, but the group will not see them unless it is rewound again. Skipping is often chosen to clear a huge backlog, but it should be a conscious decision, ideally recorded and approved.
The load spike
Rewinding a group to the earliest position on a big topic may force consumers to process days or weeks of events as fast as they can. This can overwhelm databases and other downstream services. Consider adding consumers, throttling, or resetting in stages.
| Direction | Main Risk | Protection |
|---|---|---|
| Backwards | Duplicate effects and a burst of load | Repeat-safe consumers, downstream cleanup, scaling, throttling |
| Forwards | Permanently unprocessed events for that group | Approval, records of what was skipped, alternative processing of skipped data |
| To a wrong time | Missing or excess data | Check the time zone and the preview, and verify after |
Rewinding a team’s bookmark makes them re-mark papers already graded. If the grades were already sent to students, students get two grades unless someone handles it. Fast-forwarding the bookmark leaves some papers permanently unmarked by that team.
Time-based resets depend on event timestamps and on time zones. Write the time in an unambiguous form, and confirm in the preview that the resulting positions look reasonable.
11Deleting Groups and Deleting Offsets
Groups and their bookmarks can be removed, either wholly or in part.
Deleting a group
The delete action removes a group and all its saved bookmarks. Like reset, it works only when the group has no active members. After deletion, if an application starts again with the same group name, it is treated as a brand-new group, with no history, and will start according to its reset rule, either from the earliest available event or from the newest.
When deletion makes sense
Cleaning up abandoned groups
Old experiments and one-off console sessions leave groups behind. Removing them tidies the cluster and its dashboards.
Starting a group from scratch
Sometimes a team wants a clean start. Deleting the group removes its bookmarks, so the next start follows the application’s reset rule.
Deleting offsets for chosen topics
The delete offsets action removes only the bookmarks for chosen topics in a group, leaving the group and its other bookmarks intact. This is useful when a group stops reading a topic for good, and the old bookmarks would otherwise sit around and keep showing up as lag in monitoring.
| Action | What Is Removed | Requirement |
|---|---|---|
| Delete group | The whole group and all its bookmarks | No active members |
| Delete offsets for a topic | Only that topic’s bookmarks in the group | The group must not be currently subscribed to that topic |
| Reset offsets | Nothing is removed; bookmarks are moved | No active members |
Deleting a group is like throwing away a team’s notebook entirely. Deleting offsets for a topic is like tearing out only the pages about a subject the team no longer marks. Resetting is like moving the bookmark without touching any page.
Deleting a group that is only paused, such as a monthly job, and then being surprised that its next run reprocesses everything or skips everything. Confirm a group is truly retired before removing it.
12Common Troubleshooting Situations
The tool shines during incidents. Here are frequent situations and how it helps.
“Messages are delayed”
Describe the group and look at lag. Growing lag on all partitions means consumers are too slow. Lag on one partition suggests a hot key or a stuck member.
“The consumer seems to be running but nothing happens”
Check the members and state views. The consumer may not be in the group at all, or the group may be stuck in a rebalance, or the partitions may be assigned to a different member than expected.
“Events are processed twice”
Check whether the group was recently reset backwards, and whether it is rebalancing often. Frequent reshuffles lead to repeated reading of events after the last saved bookmark.
“Some events were never processed”
Compare the group’s positions with earlier records, and look for a forward reset, a jump in the bookmark, or an out-of-range recovery after events expired.
“A new deployment did not pick up work”
Confirm the group name in the new deployment matches the intended one, since a typo creates a brand-new group with no bookmarks.
“Monitoring shows lag for a topic nobody reads anymore”
An old group still holds bookmarks for it. Delete the group, or delete its bookmarks for that topic.
flowchart TD
P["Problem reported"] --> L["List groups: is the group name correct?"]
L --> S["Describe state: Stable, rebalancing, or Empty?"]
S --> M["Describe members: who owns which partitions?"]
M --> O["Describe offsets: where is the lag?"]
O --> A["Decide: tune, scale, fix code, or reset"]
A doctor checks the patient’s chart in a sensible order: confirm identity, check vital signs, then look at specific symptoms, and only then decide on treatment. The tool’s views support the same steady order.
13The Tool and Real Monitoring
The tool is a snapshot. Serious operations need continuous watching as well.
Limits of a snapshot
Running the tool by hand tells you what the group looks like right now. It does not warn you at night, and it does not show the history of lag over hours. For that, teams add continuous monitoring: exporters that publish lag numbers to a metrics system, dashboards that draw lag over time, and alerts that fire when lag keeps growing.
How the two fit together
| Need | Best Tool |
|---|---|
| Quick look during an incident | kafka-consumer-groups.sh |
| Trend of lag over days | A metrics dashboard fed by a lag exporter or built-in client metrics |
| Wake someone at night when lag grows | An alerting rule on lag and on group state |
| Correcting bookmarks safely | kafka-consumer-groups.sh, with the safety steps |
| Repeatable resets in a pipeline | Scripts or admin client programs, with review and records |
A supervisor’s clipboard check is a spot inspection. A permanent gauge on the wall showing the height of each pile, with an alarm bell, is continuous monitoring. Good schools use both.
For the alarm to be useful, alert on lag that keeps growing for several minutes, not on brief spikes, and also alert when a busy group falls into the empty state unexpectedly.
14Security and Permissions
Because the tool can move bookmarks and delete groups, who may use it matters greatly.
The tool has no powers of its own
The script is only a messenger. What it can do depends entirely on the identity it presents and the permissions that identity holds. Reading a group’s information, reading topic details for lag calculation, deleting a group, and changing bookmarks are separate permissions that administrators can grant or withhold.
Sensible arrangements
Read-only access for many
Let developers and support staff describe groups and see lag, since this is safe and helps them troubleshoot.
Change rights for few
Restrict resets and deletions to trusted administrators or an approved pipeline, especially on production.
Require review for production changes
Have a second person check the target, the group, and the preview before an execute run.
Protect credentials and keep records
Keep security properties files out of shared places and version control, and log who changed which group, when, and why.
Many staff may read the notebooks, but only a senior supervisor may change a team’s official record, and every change is written in a logbook with a reason. The tool is the door, and permissions are the keys.
15Advantages and Trade-offs of the Tool
Like every tool, it has strengths and limits.
Advantages
- Ships with Kafka, so it is available everywhere from day one
- Instantly shows lag, members, and group state
- Safe defaults for resets, with a preview before any change
- Flexible reset choices by time, offset, duration, or file
- Easy to script and to combine with other tools
- No extra software to install or license
Disadvantages / Trade-offs
- A snapshot only: no history, trend, or alerting
- Text output is designed for people, so scripts must parse it carefully
- Resets require the group to be stopped, which may mean downtime
- Powerful actions can cause large reprocessing or permanent skipping
- Options and output formats change between versions
- Needs a Java runtime and network access to the brokers
16Anti-Patterns and Best Practices
Most trouble with this tool repeats across teams.
Problem
Resetting a group to the latest position to “clear the backlog” without asking what will be skipped.
Why It’s Harmful
Every unprocessed event in the skipped range is permanently ignored by that group, possibly including orders or payments.
Correct Approach
Prefer catching up by scaling consumers or fixing the slowness. If skipping is truly needed, get approval, record the skipped range, and process it another way if it matters.
Problem
Executing a reset without reading the preview, saving the old positions, or double-checking the group name.
Why It’s Harmful
A small mistake, such as a wrong time zone or a similar group name, can cause huge reprocessing or loss, and there is no undo.
Correct Approach
Follow the safety steps: stop the group, export current positions, run the preview, execute, and verify.
Problem
Rewinding a group whose consumers or downstream systems are not safe against repeated events.
Why It’s Harmful
Reprocessing duplicates emails, payments, or database rows, and the cleanup is costly.
Correct Approach
Make consumers repeat-safe first, or clean or isolate the downstream data before rewinding.
Problem
Relying on occasional manual runs of the tool as the only monitoring.
Why It’s Harmful
Problems are noticed only when someone thinks to look, often after customers complain.
Correct Approach
Add continuous lag and state monitoring with alerts, and use the tool for investigation and repair.
Problem
Leaving cluttered groups from old tests and console sessions, with random names, forever.
Why It’s Harmful
Dashboards fill with meaningless lag, real problems hide in the noise, and bookmarks waste storage.
Correct Approach
Name groups clearly, tidy up unused ones regularly, and delete bookmarks for topics that are no longer read.
Best practices at a glance
Start with state and members
Know whether the group is stable, rebalancing, or empty before reading lag.
Read trends, not snapshots
Run repeated checks or use dashboards to see whether lag is growing.
Always preview resets
Read the planned positions before adding the execute option.
Save before you change
Export current positions so you can restore them.
Stop the group first
Confirm that the group is empty before a reset or deletion.
Plan for repeats
Only rewind groups whose processing tolerates seeing an event twice.
Limit and review change rights
Give resets and deletions to few people, with a second pair of eyes for production.
Name and tidy groups
Clear names and regular clean-up keep the group list meaningful.
17A Real-World Walk-Through
Let us follow an on-call engineer at an online shop during an incident.
The alert
At night, an alert fires: lag on the email service group has been growing for twenty minutes. Customers are not receiving order confirmations.
Check the state
The engineer describes the group’s state. It is stable, with three members, so it is not stuck in a reshuffle and has not stopped.
Check the members
The members view shows three consumers owning four partitions each, evenly spread. No unexpected hosts appear.
Check the lag
The offsets view shows lag growing on all twelve partitions, so the consumers are slow overall, not stuck on one partition.
Find the cause and act
The email provider has become slow. The engineer scales the application to six members, and lag starts to fall within minutes. No reset is needed.
The next morning: a real reset
The team discovers a bug that sent wrong discount codes in yesterday’s emails. They plan a correction run for the affected hour.
The careful reset
They create a separate correction group rather than rewinding the live one, stop it, export its positions, preview a time-based reset to the start of the bad hour, execute, verify, and run it with a repeat-safe correction program.
Tidy up
Afterwards, the temporary group is deleted, the incident is written up, and the lag alert is tuned to trigger earlier.
sequenceDiagram
participant E as On-call Engineer
participant T as kafka-consumer-groups.sh
participant K as Kafka Cluster
E->>T: Describe state of email group
T->>K: Ask coordinator
K-->>T: Stable, 3 members
E->>T: Describe offsets
T->>K: Read bookmarks and log ends
K-->>T: Lag growing on all partitions
E->>E: Scale consumers to six
E->>T: Describe again after some minutes
K-->>T: Lag falling
18Frequently Asked Questions
It is the command-line tool shipped with Kafka for listing consumer groups, seeing their progress, lag, members, and state, and for resetting or deleting their saved positions.
No. It reads only bookmarks and log positions to calculate lag, and it changes bookmarks when asked. Your consumers do the actual processing.
Lag is the number of events between the group’s committed bookmark and the newest event of a partition, meaning how many events are waiting to be processed.
Because no running consumer currently owns those partitions. The group may be stopped, in the middle of a rebalance, or the partition has no assigned member.
No. The tool refuses, because running consumers would overwrite the new bookmarks. Stop the group and confirm its state is empty first.
Not by default. The default is a preview that changes nothing. You must add the execute option to save the new positions.
The group and all its bookmarks are removed. If an application starts with the same name, it behaves as a new group and begins from the earliest or the newest event according to its reset rule.
Because its bookmarks are still stored. It remains visible in an empty state until its bookmarks expire or it is deleted.
It is great for investigation but gives only a snapshot. Use continuous monitoring and alerting on lag and group state for day-to-day safety.
You can, but for repeatable production changes many teams prefer the admin client library, which is easier to test and does not depend on parsing text. Whichever you choose, keep the safety steps, reviews, and records.
19Summary and Key Takeaways
We began with a school where a supervisor walks the corridors with a clipboard, checking the height of each team’s pile of unmarked papers, who is on each team, and occasionally correcting a team’s notebook. kafka-consumer-groups.sh is that clipboard for Kafka. It ships with Kafka, connects through a bootstrap broker, and offers a few actions: list the groups, describe their progress, lag, members, and state, reset their bookmarks, and delete groups or their bookmarks. Describing is safe and constantly useful, especially when read in a sensible order: name, state, members, then lag. Resetting is powerful and dangerous: it works only when the group is inactive, previews by default, can move bookmarks by time, offset, duration, or file, and can cause heavy reprocessing or permanent skipping, so it demands stopped consumers, a saved copy of the old positions, a read preview, verification afterwards, and repeat-safe consumers. The tool is a snapshot, so it must be paired with continuous lag and state monitoring, and permissions should give read access widely and change rights sparingly. Learn to read a group calmly, and change one only with a plan.
Key Takeaways
- It inspects and manages consumer groups — list groups, describe offsets, lag, members, and state, and reset or delete bookmarks, using a bootstrap broker and security settings for protected clusters.
- Lag is the key number — the gap between the committed offset and the log end shows how many events wait; the trend and the distribution across partitions matter more than any single value.
- Read state and members first — Stable, rebalancing, and Empty tell you what the group is doing, and the members view shows who owns which partitions.
- Resets need discipline — the group must be empty, the default is a preview, and old positions should be saved before any executed change.
- Direction has consequences — rewinding causes reprocessing and load, while moving forward permanently skips events for that group.
- Deleting is final for the bookmarks — a deleted group restarts as brand new, so confirm a group is truly retired before removing it.
- Pair it with monitoring and permissions — use dashboards and alerts for continuous watching, grant read access widely and change rights narrowly, and keep records of every change.