Reputation: 85
How do you know when was a topic created in Kafka?
It seems that a few of the topics were created with a wrong number of partitions. Is there a way to know the date the topic was created? Supposedly, a topic with the name "test" was created with n
number of partitions. How can I find the date and time when this "test" topic was created on Kafka?
Upvotes: 7
Views: 11582
Reputation: 20840
You can see the Kafka topic creation time(ctime) and last modified time(mtime) in zookeeper stat.
First login to zookeeper shell and add command "stat "
kafka % bin/zookeeper-shell.sh localhost:2181 stat /brokers/topics/test-events
It will return below details:
Connecting to localhost:2181
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
cZxid = 0x1007ac74c
ctime = Thu Nov 01 10:38:39 UTC 2018
mZxid = 0x4000f6e26
mtime = Mon Jan 07 05:22:25 UTC 2019
pZxid = 0x1007ac74d
cversion = 1
dataVersion = 8
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 112
numChildren = 1
You can refer this to understand the attributes : https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_zkStatStructure
Upvotes: 10
Reputation: 1651
You can tell the topic creation time by checking the zookeeper node creation time for the topic. Given that "zookeeper001:2181/foo" is the Kafka zookeeper connection string, and "test_topic" is the topic name, you can check the stat of znode to get the topic creation time:
/foo/brokers/topics/test_tpopic
I don't think that there is a way to check number of partitions at the topic creation time. You can always increase the topic partition number by using :
kafka-topics.sh --alter ...
Upvotes: 2