MySQL sync cluster logs
For a MySQL semi-sync Managed Database cluster, MySQL service events and slow queries are logged.
Logs can be retrieved using the Logs service. For details on how the service works and its cost, see the About the Logs service instructions. To check the availability of the Logs service across locations, see the Logs availability by location instructions.
To collect cluster logs in the Logs service, enable logging. You can retrieve logs from the service only via the API. If you no longer need to collect logs, you can disable logging.
Slow query logs can be viewed in the Cloud Databases section of the control panel. You do not need to enable logging in the Logs service for this.
Logs are stored for 30 days.
For more information about logs, see the MySQL Server Logs section of the MySQL documentation.
Manage logs in the Logs service
Enable logging
You can enable logging via the API or in the Control Panel:
- when creating a cluster;
- or in an existing cluster.
Enable logging in an existing cluster
Logging uses part of the cluster's computing resources. To control the amount of resources consumed, monitor cluster node metrics. For details on how to view metrics, see the Monitoring a MySQL sync cluster, nodes, and databases instructions.
- In the control panel, in the top menu, click Products and select Managed Databases.
- Open the Active tab.
- Open the cluster page → Settings tab.
- In the Logging block, in the Log service field, click Connect.
- Select a log group or create a new group.
- If you selected a new group, enter its name.
- Click Save.
Get logs
Follow the Retrieve logs instructions in the Logs section.
Event streams mysql.log-<instance_id> and slow.log-<instance_id> will be created, where <instance_id> is the MySQL sync cluster node ID.
Logged events are defined by the log_error_verbosity = 1 parameter, so only events of the ERROR level are logged. See the description of log fields for the MySQL sync cluster.
Disable logging
- In the control panel, in the top menu, click Products and select Cloud Databases.
- Open the Active tab.
- Open the cluster page → Settings tab.
- In the Logging section, in the Log service field, click .
- Clear the Collect cluster technical logs into log service checkbox.
- Click Save.
View slow query logs in the control panel
By default, database queries that take longer than two seconds to execute are considered slow. To change this value, in the DBMS settings, change the long_query_time parameter.
In the logs, you can see what a slow query looked like, its duration, and when and by which user it was executed. Queries can be filtered by time range, cluster nodes, and databases.
- In the control panel, in the top menu, click Products and select Cloud Databases.
- Open the Active tab.
- Open the cluster page → the Logs tab.
- Enter the time range for which you want to display logs. Logs are stored for 30 days.
- Select the cluster nodes and databases for which you need to collect logs.
- The list displays the first 200 queries. To view all queries for the specified time period, click Download logs. See the description of log fields for the MySQL sync cluster.
Log fields
MySQL
Slow queries