QnaList > Groups > Incubator-Kafka-Users > Oct 2014
faq

Programmatically Get Number Of Items In Topic/partition

Hi,
How can I programmatically get the number of items in a topic, pending for
consumption?
If no programmatic way is avail, what other method is available?
Shlomi

asked Oct 1 2014 at 02:10

Shlomi Hazan 's gravatar image



5 Replies for : Programmatically Get Number Of Items In Topic/partition
Take a look at ConsumerOffsetChecker. It does just that: print the
offset and lag for each consumer and partition.
You can either use that class directly, or use it as a guideline for
your implementation

answered Oct 1 2014 at 08:28

Gwen Shapira 's gravatar image


actually this tool is not a 100% match to what I need, since it can only
provide information on topics that have comsumers: Is there also another
equivalent tool/method of querying topics that have no consumers ? in this
case this tool will not help as it requires a group id as a mandatory
parameter...

answered Oct 5 2014 at 05:35

Shlomi Hazan 's gravatar image


Take a look into how Offset Requests are made and handled.  You could do
that to get the low and high watermarks for the stream.  With the high and
low watermark just subtract them to get total. This will be in the consumer
api part of whatever language client your using. The specs for this are
https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-OffsetAPI
/*******************************************
Joe Stein
Founder, Principal Consultant
Big Data Open Source Security LLC
http://www.stealth.ly
Twitter: @allthingshadoop
********************************************/
actually this tool is not a 100% match to what I need, since it can only
provide information on topics that have comsumers: Is there also another
equivalent tool/method of querying topics that have no consumers ? in this
case this tool will not help as it requires a group id as a mandatory
parameter...
https://cwiki.apache.org/confluence/display/KAFKA/System+Tools#SystemTools-ConsumerOffsetChecker
https://apache.googlesource.com/kafka/+/0.8.0-beta1-candidate1/core/src/main/scala/kafka/tools/ConsumerOffsetChecker.scala
pending

answered Oct 5 2014 at 07:05

Joe Stein 's gravatar image


Related discussions

Tagged

Group Incubator-kafka-users

asked Oct 1 2014 at 02:10

active Oct 5 2014 at 07:05

posts:6

users:4

©2013 QnaList.com