---
title: "MySQL semi-sync cluster logs"
sidebar_label: "Cluster logs"
sidebar_position: 9
description: "How to enable MySQL semi-sync cluster logging, how to retrieve logs, and how to 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 semi-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](/logs/) service. For more information about how the service works and its pricing, see the [Logs Service Overview](/logs/about/about-logs.mdx) article. You can check the availability of the Logs service by location in the [Logs availability by location](/logs/about/logs-availability-by-location.mdx).

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

Slow request logs 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.

Learn 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 semi-sync" ArticleName="Monitoring of the cluster, nodes and databases MySQL semi-sync" slug="mysql-semi-sync" />

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

Use the [Get logs](/logs/manage/get-logs.mdx) guide in the Logs section.

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

Logged events are defined by the `log_error_verbosity = 2` parameter, so events of the `ERROR` and `WARNING` levels are logged. See the description of [log fields](#fields) for a MySQL semi-sync cluster.

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

<DisableLogs />

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

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

In the logs, you can see what the slow request looked like, its duration, and when and by which user it was executed. Requests can be filtered by time range, cluster nodes, and databases.

1. In the [control panel](https://my.selectel.ru/vpc/default/dbaas/), in the top menu, click **Products** 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 want to view logs.
6. The list displays the first 200 requests. To view all requests for the specified time range, click **Download logs**. See the description of [log fields](#fields) for a MySQL semi-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 format `dbaas-<instance_id>`, where `<instance_id>` is the identifier of the MySQL semi-sync cluster node</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 changed</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 />
