Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Is there a tool to export offsets?

avatar
New Member
 
1 ACCEPTED SOLUTION

avatar
Super Guru

@Connor O'Neal

There is no named script to export offsets, but we are able to use the kafka-run-class.sh script to execute the underlying Java class for the tool in the proper environment. Exporting offsets will produce a file that contains each topic partition for the group and it’s offsets in a defined format that the import tool can read. The file that is created will have one topic partition per line, with the following format:

/consumers/GROUPNAME/offsets/topic/TOPICNAME/PARTITIONID-0:OFFSET 

Let's assume export the offsets for the consumer group named “testconsumergroup” to a file named “offsets”:

# kafka-run-class.sh kafka.tools.ExportZkOffsets --zkconnect mykafka.abc.com:2181/kafka-cluster --group testconsumergroup --output-file offsets

# cat offsets

/consumers/testconsumergroup/offsets/my-topic/0:8905 /consumers/testconsumergroup/offsets/my-topic/1:8915 /consumers/testconsumergroup/offsets/my-topic/2:9845 /consumers/testconsumergroup/offsets/my-topic/3:8072 /consumers/testconsumergroup/offsets/my-topic/4:8008 /consumers/testconsumergroup/offsets/my-topic/5:8319 /consumers/testconsumergroup/offsets/my-topic/6:8102 /consumers/testconsumergroup/offsets/my-topic/7:12739

+++

If this helped, please vote/accept response.

View solution in original post

1 REPLY 1

avatar
Super Guru

@Connor O'Neal

There is no named script to export offsets, but we are able to use the kafka-run-class.sh script to execute the underlying Java class for the tool in the proper environment. Exporting offsets will produce a file that contains each topic partition for the group and it’s offsets in a defined format that the import tool can read. The file that is created will have one topic partition per line, with the following format:

/consumers/GROUPNAME/offsets/topic/TOPICNAME/PARTITIONID-0:OFFSET 

Let's assume export the offsets for the consumer group named “testconsumergroup” to a file named “offsets”:

# kafka-run-class.sh kafka.tools.ExportZkOffsets --zkconnect mykafka.abc.com:2181/kafka-cluster --group testconsumergroup --output-file offsets

# cat offsets

/consumers/testconsumergroup/offsets/my-topic/0:8905 /consumers/testconsumergroup/offsets/my-topic/1:8915 /consumers/testconsumergroup/offsets/my-topic/2:9845 /consumers/testconsumergroup/offsets/my-topic/3:8072 /consumers/testconsumergroup/offsets/my-topic/4:8008 /consumers/testconsumergroup/offsets/my-topic/5:8319 /consumers/testconsumergroup/offsets/my-topic/6:8102 /consumers/testconsumergroup/offsets/my-topic/7:12739

+++

If this helped, please vote/accept response.