Monitoring logs
Log Classification
The logs of a MySQL instance include three types: Binary Logs (BinLog), Slow Query Logs (SlowLog), and Error Logs (ErrorLog).
Binary Logs (BinLog) are logs that record SQL statements that cause or potentially cause changes to the data, and are saved in binary form.
Slow Query Logs (SlowLog) refer to the logs where the MySQL instance records all SQL statements that exceed the time threshold set by the long_query_time parameter.
Error Logs (ErrorLog) are logs that record the error information encountered by the MySQL instance service process mysqld during startup/shutdown or operation.
Query Logs
MySQL supports console queries for historical logs and real-time logs. In the instance details page, select log management, select the log type and query type, and click query log:
Log Download
In the detail page, select log management, and choose the log package in the page. You can then package slow query logs (SlowLog) and error logs (ErrorLog), and download them.
The slow query log seen in the console is the original log, and the downloaded slow query log is the log processed by pt-query-digest.
In the detail page, select backup management, and choose Binlog in the page. You can then package binary logs (BinLog), clean up logs, and download and delete them.
Clear Logs
Select "Backup Management" on the "Details" page, select "Binlog Log Package" in the left navigation bar, and click "Clear Logs".
The clearing of logs will first check the time that can be cleared, returning the start time, end time, and safe time that can be cleared. The start time is the time of the first Binlog that can be cleared for the instance. For high-availability instances, it will comprehensively display the earliest time of the two nodes. The end time is the latest time for Binlog cleaning, considering the limit cleaning time of the instance retaining two Binlogs, the time of the high-availability unsynchronized Binlog, and the time of the replication unsynchronized Binlog. The safe time is the time when Binlog can be safely cleared without affecting the DB rollback function. Currently, this time is only meaningful when using the Binlog dump function.