[SOP Series 35] Checking Cluster Creation Time

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 【SOP 系列 35】查看集群创建时间

| username: Billmay表妹

Thanks to @Liuhaoao for the content:

Why Write This Article

Today, while browsing the community, I saw an article about how to check the cluster creation time. I remembered that I had done this before, so I read the article by that expert. The link is here: How to Get the Cluster Creation Time in TiDB. After reading it, I felt that the expert’s method was a bit cumbersome… So here, I will briefly introduce my method. Although the demand scenario might be rare, or you might never encounter it, it’s always good to have more skills. Moreover, my method is indeed simple (dog.jpg). Without further ado, let’s get straight to the method!

Operation Method

As we all know, Tiup is a cluster management tool introduced from version 4.0. It can manage core components like PD, TiKV, TiDB, TiFlash, as well as tool components like DM, TiCDC, and TiDB Binlog. It is quite feature-rich. To check the cluster creation time, you only need to use the tiup command with the cluster component:

First, execute tiup cluster --help to see which specific command we need:

You can see there is an audit command. The official explanation is: Query Cluster Operation Audit Logs, which means checking what commands have been executed on all clusters historically and the execution logs of each command. The effect is as follows:

You can clearly see the execution results, including the time and what command was executed at each time point. The most recent deploy command corresponds to the time we need for the cluster creation time.

Summary

In fact, the audit logs can meet more needs than just checking the cluster creation time. For example, you can check when a restart was done, when parameter modifications were made, etc. It can meet quite a few needs. Also, you can check out the official documentation. You might discover other less commonly used but very useful features of tiup. If you have other methods to check the cluster creation time or find new surprises in the official documentation, feel free to share in the comments.

| username: TiDBer_jYQINSnf | Original post link

When the cluster starts, it writes a key to record the time.


You can see it using pd-ctl cluster status
image

| username: Ti青涩 | Original post link

Directly extract the timestamp of the deploy operation
tiup cluster audit 2> /dev/null | grep deploy | awk ‘{print $2}’