Skip to main content

MySQL sync cluster logs

Last update:

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

Logs can be obtained through the Logi service.For more details on the principle of operation and cost of the service, please refer to the instruction General information about the Logi service.To see the availability of the Logi service in the regions, please refer to the Logi availability matrix .

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

Logs of slow requests can be viewed in the Cloud Databases section of the Control Panel.You do not need to enable logging in the Logs service.

Logs are stored for 14 days.

Read 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 through the API or in the control panel:

Enable logging in an existing cluster

Logging uses a portion of the cluster's computational resources. To control the amount of resources consumed, monitor the cluster node metrics. Learn more about how to view metrics in the props.ArticleName instruction.

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

Get the logs

Use the Get Logs instructions in the Logs section.

Event streams will be created mysql.log-<instance_id> and slow.log-<instance_id>, where <instance_id> is the node ID of the MySQL sync cluster..

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

Disable logging

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

View slow request logs in the control panel

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

In the logs you can see what a slow query looked like, its duration, when and which user made it.Queries can be filtered by time interval, cluster nodes and databases.

  1. In the Dashboard, on the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Open the cluster page → Logs tab.
  4. Enter the time period for which you want to display the logs.Logs are stored for 14 days.
  5. Mark the cluster and database nodes for which you want to collect logs.
  6. The list displays the first 200 queries.To see all queries for a specified time period, click Download Logs.View the description of the log fields for the MySQL sync cluster.

Log fields

_HOSTNAMECluster node name in dbaas format-<instance_id>, where <instance_id> is the MySQL sync cluster node ID.
SYSLOG_IDENTIFIERLog source name
SYSLOG_TIMESTAMPEvent time in the log
MESSAGEDescription of the event that the log source transmitted