---
title: "MySQL sync cluster logs"
sidebar_label: "Cluster logs"
sidebar_position: 10
description: "How to enable MySQL sync cluster logging, get logs, and disable cluster logging"
---

import Formbricks from '@theme/MDXComponents/Formbricks';
import EnableLogs from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/managed-databases/common/enable-logs.mdx';
import DisableLogs from '@site/i18n/en/docusaurus-plugin-content-docs/current/_partials/managed-databases/common/disable-logs.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { TabItemLabel } from '@selectel/docux/components';
import { CustomTable } from '@selectel/docux/components';

# MySQL sync cluster logs

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

Logs can be accessed via the [Logs](/logs/) service. Read more about how the service works and its pricing in the [General information about the Logs service](/logs/about-logs.mdx) guide. You can check the availability of the Logs service in different regions in the [Availability Matrix](/infrastructure/availability-matrix.mdx#logs).

To collect cluster logs in the Logs service, [enable logging](#enable-logs). [Logs](#get-logs) can be retrieved from the service only via API. If you no longer need to collect logs, you can [disable logging](#disable-logs).

Logs of slow queries can be [viewed](#view-long-query-logs-via-panel) 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](https://dev.mysql.com/doc/refman/8.4/en/server-logs.html) section of the MySQL documentation.

## Manage logs in the Logs service \{#manage-logs-in-logs-service}

### Enable logging \{#enable-logs}

<EnableLogs DatabaseName="MySQL sync" ArticleName="Monitoring of the cluster, nodes and databases MySQL sync" slug="mysql-sync" />

### Get logs \{#get-logs}

Use the [Get logs](/logs/manage/get-logs.mdx) 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 events of the `ERROR` level are logged. See the description of [log fields](#fields) for a MySQL sync cluster.

### Disable logging \{#disable-logs}

<DisableLogs DatabaseName="MySQL sync" slug="mysql-sync" />

## View slow query logs in the control panel \{#view-long-query-logs-via-panel}

By default, database queries that take longer than two seconds are considered slow. To change this value, [change the](/managed-databases/mysql-semi-sync/settings.mdx#change-settings) DBMS setting for the `long_query_time` parameter.

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

1. In the [control panel](https://my.selectel.ru/vpc/default/dbaas/), 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**. View the description of [log fields](#fields) for a MySQL sync cluster.

## Log fields \{#fields}

<Tabs queryString="log-fields">
  <TabItem value="mysql" default>
    <TabItemLabel>
      MySQL
    </TabItemLabel>

    <CustomTable>
      <table>
        <tbody>
          <tr>
            <th>\_HOSTNAME</th><td>Cluster node name in the `dbaas-<instance_id>` format, where `<instance_id>` is the MySQL sync cluster node identifier</td>
          </tr>

          <tr>
            <th>SYSLOG\_IDENTIFIER</th><td>Log source name</td>
          </tr>

          <tr>
            <th>SYSLOG\_TIMESTAMP</th><td>Event time in the log</td>
          </tr>

          <tr>
            <th>MESSAGE</th><td>Description of the event submitted by the log source</td>
          </tr>
        </tbody>
      </table>
    </CustomTable>
  </TabItem>

  <TabItem value="slow-logs">
    <TabItemLabel>
      Slow queries
    </TabItemLabel>

    <CustomTable>
      <table>
        <tbody>
          <tr>
            <th>user</th><td>Name of the database user who executed the query</td>
          </tr>

          <tr>
            <th>query\_time</th><td>Total query execution time</td>
          </tr>

          <tr>
            <th>lock\_time</th><td>Time the query waited for locks before actual execution</td>
          </tr>

          <tr>
            <th>rows\_sent</th><td>Number of rows returned by the query</td>
          </tr>

          <tr>
            <th>rows\_examined</th><td>Number of rows examined by the node during query execution</td>
          </tr>

          <tr>
            <th>rows\_affected</th><td>Number of rows that were modified</td>
          </tr>

          <tr>
            <th>bytes\_sent</th><td>Number of bytes transmitted as a result of query execution</td>
          </tr>

          <tr>
            <th>sql</th><td>Slow SQL query</td>
          </tr>
        </tbody>
      </table>
    </CustomTable>
  </TabItem>
</Tabs>

<Formbricks />
