The number of messages in a Kafka Topic
This is how you find out how many messages exist for a kafka topic.
/opt/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list kafka:9092 --topic test --time -2
This gives output like this
test:1:28179212
test:0:28180921
/opt/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list kafka:9092 --topic test --time -1
This gives output like this
test:1:28228989
test:0:28230734
Simply subtract these values and you get the sizes.
0:28230734 – 28180921 = 49813
1:28228989 – 28179212 = 49777