Reputation: 77
I know that is possible to get the latest offset of a kafka but is it possible to get the timestamp of the last change of a kafka topic via the kafka console scripts ?
I saw this question Kafka: How to get last modified time for a topic i.e. last message added to any partition of the topic but with no real answer to my question.
Upvotes: 5
Views: 5728
Reputation: 20840
You can't get the timestamp straight forward from the script. Instead you can see the timestamp using the console-consumer script. It shows the CreateTime
for a message
As mentioned by @Sreekiran also, use the property "print.timestamp" as below :
ncsv@ubuntu:/data/softwares/kafka_2.11-2.0.0$ bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testJsonTopic1 --property print.timestamp=true --from-beginning
CreateTime:1544445041225 {"id": "9","name": "wis"}
CreateTime:1544518616282 {"id": "19","name": "wes"}
CreateTime:1544520723808 {"id": "1","name": "test1"}
CreateTime:1544446690508 {"id": "9","name": "wes"}
CreateTime:1544445375123 {"id": "9","name": "wes"}
CreateTime:1544520388080 {"id": "20","name": "test1"}
It will show the time when the event was written in the cluster.
Upvotes: 5
Reputation: 3421
Add this to the current command --property print.timestamp=true
That will print the timestamp CreateTime:1544706749268
.
Upvotes: 6