What Is kafka-consumer-groups.sh?

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"]
        
FIG 1 — Lag is the distance between the group’s bookmark and the newest event
Simple Analogy

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.

i
Helpful Note

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"]
        
FIG 2 — Where the tool finds its information
Simple Analogy

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.

SituationWhat You Need to Give the Tool
Local practice cluster with no securityJust a bootstrap server address
Production cluster with encryption and loginA bootstrap server address and a properties file with security settings
Fine-grained access rulesAn identity that has been granted the needed rights on the group and its topics
Simple Analogy

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.

!
Common Mistake

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.

Action 1

List

Shows the names of the consumer groups known to the cluster.

Action 2

Describe

Shows a group’s progress per partition, its lag, its members, or its state.

Action 3

Reset offsets

Moves a group’s bookmarks to a chosen position, such as the start, the end, or a point in time.

Action 4

Delete

Removes an inactive group and its saved bookmarks from the cluster.

Action 5

Delete offsets

Removes a group’s saved bookmarks for particular topics, without deleting the group itself.

The supporting options

OptionWhat It DoesUsed With
bootstrap serverTells the tool which broker to contactEvery action
command configPoints to a file with security settingsEvery action on a secured cluster
groupNames the group to act onDescribe, reset, delete
all groupsActs on every groupDescribe, reset, delete
topicLimits the action to a topic, or to particular partitions of itReset, delete offsets
all topicsActs on every topic the group has bookmarks forReset
membersShows the consumers currently in the groupDescribe
stateShows the group’s current state and coordinatorDescribe
verboseAdds extra details, such as partition assignmentsDescribe with members
dry run and executePreview a change, or actually apply itReset
exportWrites the planned new bookmarks to a fileReset
Simple Analogy

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.

i
Helpful Note

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.

Simple Analogy

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.

!
Common Mistake

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.

Column 1

Topic and partition

Which slice of which topic this line describes.

Column 2

Current offset

The group’s committed bookmark for that partition: the next event it will read.

Column 3

Log end offset

The position just after the newest event in the partition.

Column 4

Lag

The number of events between the two, meaning how many are waiting.

Column 5

Consumer identity

Which member currently owns this partition, with its host and client name. Missing when nobody owns it.

Reading the lag

What You SeeWhat It Usually MeansWhat to Do
Small lag on every partition, changing up and downThe group keeps paceNothing to do
Lag growing steadily on all partitionsConsumers are too slow for the incoming loadSpeed up processing or add members, up to the partition count
Large lag on one partition onlyA hot key, a stuck consumer, or a poisonous eventInvestigate the owner of that partition and the keys feeding it
Lag is large but the consumer columns are emptyNobody is currently reading; the group has stoppedCheck whether the application is running
Lag suddenly jumps to zeroSomeone reset the bookmarks to the newest position, or events expiredFind 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"]
        
FIG 3 — A simple way to read a lag report
Simple Analogy

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.

i
Helpful Note

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.

StateMeaningTypical Concern
StableMembers are in place, partitions are assigned, and reading is under wayNone; this is the healthy state
Preparing rebalanceA change happened, and the group is gathering members for a reshuffleBrief is normal; long means a slow member is holding things up
Completing rebalanceThe new plan is being handed out to membersBrief is normal; long can point to trouble with the leader member
EmptyThe group exists but has no active members, though it may still hold bookmarksApplications are stopped, or crashed
DeadThe group has been removed or is being removedGroup 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
        
FIG 4 — The life cycle of a consumer group’s state
Simple Analogy

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.

!
Common Mistake

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

ChoiceWhat It DoesTypical Use
To earliestMoves to the oldest event still storedReprocess everything available
To latestMoves to the end, skipping everything currently storedIgnore the backlog and start fresh
To a date and timeMoves to the first event at or after that momentRewind to just before an incident
To a specific offsetMoves each chosen partition to a given positionPrecise repair of a known spot
Shift by a numberMoves forward or backward by a number of events from the current positionReplay or skip a small, known amount
By a durationMoves back by a length of time from nowReplay the last few hours
To currentKeeps the present bookmarksUseful for writing out the current state to a file
From a fileMoves each partition to the positions written in a fileRepeating 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"]
        
FIG 5 — The bookmark can be moved anywhere between the earliest and the latest event
Simple Analogy

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.

1

Decide the target

Agree exactly where the group should restart, and which topics and partitions are affected.

2

Stop the consumers

Shut down every member of the group and confirm through the state view that the group is empty.

3

Save the current bookmarks

Export the present positions to a file so you can undo the change.

4

Run the preview

Run the reset without the execute option and read the planned positions carefully.

5

Execute

Repeat the command with the execute option. The new bookmarks are saved.

6

Verify

Describe the group again to confirm that the positions are as planned.

7

Restart the consumers and watch

Start the members and watch lag and any downstream systems, since reprocessing may create heavy load or duplicates.

Simple Analogy

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.

!
Common Mistake

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.

DirectionMain RiskProtection
BackwardsDuplicate effects and a burst of loadRepeat-safe consumers, downstream cleanup, scaling, throttling
ForwardsPermanently unprocessed events for that groupApproval, records of what was skipped, alternative processing of skipped data
To a wrong timeMissing or excess dataCheck the time zone and the preview, and verify after
Simple Analogy

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.

i
Helpful Note

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.

ActionWhat Is RemovedRequirement
Delete groupThe whole group and all its bookmarksNo active members
Delete offsets for a topicOnly that topic’s bookmarks in the groupThe group must not be currently subscribed to that topic
Reset offsetsNothing is removed; bookmarks are movedNo active members
Simple Analogy

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.

!
Common Mistake

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"]
        
FIG 6 — A calm order of checks during an incident
Simple Analogy

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

NeedBest Tool
Quick look during an incidentkafka-consumer-groups.sh
Trend of lag over daysA metrics dashboard fed by a lag exporter or built-in client metrics
Wake someone at night when lag growsAn alerting rule on lag and on group state
Correcting bookmarks safelykafka-consumer-groups.sh, with the safety steps
Repeatable resets in a pipelineScripts or admin client programs, with review and records
Lag
How many events are waiting, per partition
State
Stable, rebalancing, or empty
Members
How many consumers hold partitions
Simple Analogy

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.

i
Helpful Note

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

1

Read-only access for many

Let developers and support staff describe groups and see lag, since this is safe and helps them troubleshoot.

2

Change rights for few

Restrict resets and deletions to trusted administrators or an approved pipeline, especially on production.

3

Require review for production changes

Have a second person check the target, the group, and the preview before an execute run.

4

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.

Simple Analogy

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.

ANTI-PATTERN-01 Avoid
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.

ANTI-PATTERN-02 Avoid
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.

ANTI-PATTERN-03 Avoid
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.

ANTI-PATTERN-04 Avoid
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.

ANTI-PATTERN-05 Avoid
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

Habit 1

Start with state and members

Know whether the group is stable, rebalancing, or empty before reading lag.

Habit 2

Read trends, not snapshots

Run repeated checks or use dashboards to see whether lag is growing.

Habit 3

Always preview resets

Read the planned positions before adding the execute option.

Habit 4

Save before you change

Export current positions so you can restore them.

Habit 5

Stop the group first

Confirm that the group is empty before a reset or deletion.

Habit 6

Plan for repeats

Only rewind groups whose processing tolerates seeing an event twice.

Habit 7

Limit and review change rights

Give resets and deletions to few people, with a second pair of eyes for production.

Habit 8

Name and tidy groups

Clear names and regular clean-up keep the group list meaningful.

“Reading a consumer group is safe and useful; changing one deserves a plan, a preview, and a second pair of eyes.”

17A Real-World Walk-Through

Let us follow an on-call engineer at an online shop during an incident.

1

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.

2

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.

3

Check the members

The members view shows three consumers owning four partitions each, evenly spread. No unexpected hosts appear.

4

Check the lag

The offsets view shows lag growing on all twelve partitions, so the consumers are slow overall, not stuck on one partition.

5

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.

6

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.

7

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.

8

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
        
FIG 7 — Using the tool to diagnose and confirm a fix

18Frequently Asked Questions

Q1What is kafka-consumer-groups.sh in one sentence?

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.

Q2Does the tool read or process my events?

No. It reads only bookmarks and log positions to calculate lag, and it changes bookmarks when asked. Your consumers do the actual processing.

Q3What does lag mean in its output?

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.

Q4Why are the consumer columns empty for some partitions?

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.

Q5Can I reset offsets while my consumers are running?

No. The tool refuses, because running consumers would overwrite the new bookmarks. Stop the group and confirm its state is empty first.

Q6Is a reset applied immediately?

Not by default. The default is a preview that changes nothing. You must add the execute option to save the new positions.

Q7What happens if I delete a group?

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.

Q8Why does a group with no running consumers still show up?

Because its bookmarks are still stored. It remains visible in an empty state until its bookmarks expire or it is deleted.

Q9Is the tool enough for monitoring?

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.

Q10Should I use it in automated pipelines?

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.