Skip to main content

MySQL sync cluster logs

For a MySQL semi-sync Managed Database cluster, MySQL service events and slow queries are logged.

Logs can be retrieved via the Logs service. Learn more about how the service works and its pricing in the General information about the Logs service article. You can check the availability of the Logs service in regions in the Logs availability matrix.

To collect cluster logs in the Logs service, enable logging. You can only get logs from the service via API. If you no longer need to collect logs, you can disable logging.

Slow query logs can be viewed in the Managed 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.

More about logs in 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:

Enable logging in an existing cluster

Logging uses a portion of the cluster's computing resources. To control the amount of consumed resources, monitor the cluster node metrics. For more information on how to view metrics, see the article Monitoring of the cluster, nodes and databases MySQL sync.

  1. In the Control Panel, in the top menu, click Products and select Managed Databases.
  2. Open the Active tab.
  3. Open the cluster page → Settings tab.
  4. In the Logging block, in the Log service field, click Connect.
  5. Select a log group or create a new group.
  6. If you selected a new group, enter its name.
  7. Click Save.

Get logs

Use the Get logs instruction 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 identifier.

Logged events are defined by the log_error_verbosity = 1 parameter, so only ERROR level events are logged. See the description of log fields for a MySQL sync cluster.

Disable logging

  1. In the Dashboard, on the top menu, click Products and select Managed Databases.
  2. Open the Active tab.
  3. Open the cluster page → Settings tab.
  4. In the Logging block, in the Log service field, click .
  5. Uncheck the Collect cluster technical logs to log service checkbox.
  6. Click Save.

View slow query logs in the control panel

By default, database queries that take longer than two seconds are considered slow. To change this value, change the long_query_time`` parameter in the DBMS settings.

In the logs, you can view the slow query, its duration, and when and by which user it was executed. Queries can be filtered by time range, cluster nodes, and databases.

  1. In the control panel, click Products in the top menu and select Managed Databases.
  2. Open the Active tab.
  3. Open the cluster page → Logs tab.
  4. Enter the time range for which you want to display logs. Logs are stored for 30 days.
  5. Select the cluster nodes and databases for which you need to collect logs.
  6. The list displays the first 200 queries. To view all queries for the specified time range, click Download logs. See the description of log fields for a MySQL sync cluster.

Log fields

_HOSTNAMECluster node name in the dbaas-<instance_id> format, where <instance_id> is the MySQL sync cluster node identifier
SYSLOG_IDENTIFIERLog source name
SYSLOG_TIMESTAMPEvent time in the log
MESSAGEDescription of the event submitted by the log source