rmoff
1
I want to know how many messages are in the topic, how can I do this?
shree
2
@rmoff don’t we all want to know the answer to this 
But I am certainly interested to know what others are doing to handle this.
rmoff
3
Here are a few options: Counting the number of messages in a Kafka topic 
Also check out this cool vid from @gAmUssA
Another option is using the kafka.tools.GetOffsetShell command:
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list <BROKER_LIST> --topic <TOPIC_NAME> --time -1 --offsets 1 | awk -F ":" '{sum += $3} END {print sum}'
The source-code of this command is not very intuitive (Scala
) but it may provide an idea about how it works: