Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

how to get offsets with specific topic from kafka commands?

I have a kafka topic test

I want to get the following style information

[console-consumer-46965,test,2]::[OffsetMetadata[21,NO_METADATA],CommitTime 1479092279434,ExpirationTime 1479178679434]
[console-consumer-46965,test,1]::[OffsetMetadata[21,NO_METADATA],CommitTime 1479092284246,ExpirationTime 1479178684246]
[console-consumer-46965,test,0]::[OffsetMetadata[22,NO_METADATA],CommitTime 1479092284246,ExpirationTime 1479178684246]
[console-consumer-46965,test,2]::[OffsetMetadata[21,NO_METADATA],CommitTime 1479092284246,ExpirationTime 1479178684246]
[console-consumer-46965,test,1]::[OffsetMetadata[21,NO_METADATA],CommitTime 1479092284436,ExpirationTime 1479178684436]
[console-consumer-46965,test,0]::[OffsetMetadata[22,NO_METADATA],CommitTime 1479092284436,ExpirationTime 1479178684436]
[console-consumer-46965,test,2]::[OffsetMetadata[21,NO_METADATA],CommitTime 1479092284436,ExpirationTime 1479178684436]

Questions:
How to get the above log with kafka command?

My Effort:
I knew the command from older version of kafka is:

bin/kafka-simple-consumer-shell.sh --topic __consumer_offsets --partition 11 
    --broker-list localhost:9092,localhost:9093,localhost:9094 
    --formatter "kafka.coordinator.group.GroupMetadataManager$OffsetsMessageFormatter"

But now my kafka version is 2.5.0

need your help,thanks~!

question from:https://stackoverflow.com/questions/65872108/how-to-get-offsets-with-specific-topic-from-kafka-commands

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are only interested in the highest offset you can run:

$KAFKA_HOME/bin/kafka-run-class.sh kafka.tools.GetOffsetShell 
    --broker-list :9092 --topic my-topic --partitions 0,1 --time -1

Remove --partitions to get the offsets for all topic's partitions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...