retrieve the total number of messages published to a kafka topic for a specific interval of time (1 minute)

Viewed 77

I would like to use a kafka command that gets the total number of messages that were published to a kafka topic during an interval of time (ideally 1 minute). Does a command like this exists? Preferably in an efficient way to get the count, without having to fetch the content of the messages to then count them for example.

Im thinking kafka-console-consumer.sh could help

1 Answers

An ideal solution can be if you have Prometheus server on top of your Kafka cluster with jmx_exporter so you can get it by a simple promQL query.

If not you can use offsetsManager tool, and filter by the timestamp.

Last solution, you can reset offset of some consumer group using timestamp, look at it’s offset and subtract it from the current topic offset

Related