I have Kafka 0.10.0, which, if I understand correctly, adds timestamps to all of the messages. For monitoring purposes, I want to pull out the timestamp of the newest message for a given topic. I did not see an API field for it in any of the Python libraries I have looked at.
There is not straightforward method to get the latest message Timestamp from Kafka topics. But the work around is using kafka consumer, and use seek_to_end()
to seek the most available offset for partitions.
consumer.seek_to_end()
for message in consumer:
print(message.timestamp)
You can refer the details here :
https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html#kafka.KafkaConsumer.seek_to_end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With