---
title: "Cloud load balancer logs"
sidebar_label: "Load balancer logs"
description: "How to enable logging for a load balancer, what information is contained in the logs, and how to retrieve logs"
sidebar_position: 7
---

import Formbricks from '@theme/MDXComponents/Formbricks';
import { CustomTable } from '@selectel/docux/components';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { TabItemLabel } from '@selectel/docux/components';
import MoreVerticalIcon from '@selectel/docux/icons/more-vertical';
import EditIcon from '@selectel/docux/icons/edit';
import CopyIcon from '@selectel/docux/icons/copy';

# Cloud load balancer logs

The [Logs](/logs/) service is used to log the load balancer. 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 for load balancers in specific locations in the [Logs availability by location](/logs/about/logs-availability-by-location.mdx)[ article](/logs/about/logs-availability-by-location.mdx).

The following types of events are logged for a load balancer:

* HTTP request;
* TCP connection;
* administrative event — change of [server status](/cloud-servers/load-balancers/target-groups/target-group-statuses.mdx#server-statuses) in a [target group](/cloud-servers/load-balancers/about-load-balancers.mdx#target-groups).

Depending on the event type, a different set of [fields](#fields) is recorded.

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

## Enable logging for a load balancer \{#enable-logs-for-load-balancer}

You can enable logging via the API or in the control panel — when [creating a load balancer](/cloud-servers/load-balancers/create-load-balancer.mdx) or [for an existing load balancer](#enable-logs-for-existing-load-balancer).

### Enable logging for an existing load balancer \{#enable-logs-for-existing-load-balancer}

Logging consumes some of the load balancer's computing resources.

<Tabs queryString="enable-logs-for-existing-load-balancer">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [control panel](https://my.selectel.ru/vpc/default/lbaas/load-balancers/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Go to **Load Balancers** → tab **Load Balancers**.
    3. Open the load balancer page.
    4. In the **Settings** block, in the **Logging** field, click <EditIcon />.
    5. Select the **Collect technical load balancer logs** checkbox.
    6. Select a log group or create a new one. You can log events from one or several load balancers into the same group.
    7. If you selected a new group, enter its name.
    8. Click **Save**.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack API
    </TabItemLabel>

    1. [Obtain an IAM token for the project](/api/authorization/#iam-token-project-scoped) where the load balancer was created.

    2. In the response output, copy the `X-Subject-Token` value.

    3. Open the CLI.

    4. Enable logging for the load balancer:

       ```bash
       curl --location --request PUT 'https://<pool>.cloud.api.selcloud.ru/load-balancer/v2/lbaas/loadbalancers/<loadbalancer_uuid>/log_offloading' \
         --header 'X-Auth-Token: <x_auth_token>' \
         --header 'Content-Type: application/json;charset=utf-8' \
         --data '{
             "log_group": "<log_group_name>"
         }
       ```

       Specify:

       * `<pool>` — [pool](/infrastructure/locations.mdx#pool) where the load balancer is created, for example, `ru-8`. You can view the list of available pools in the [Selectel Infrastructure](/infrastructure/locations.mdx#selectel-infrastructure) subsection of the [Locations: countries, regions, availability zones, pools, and data center addresses](/infrastructure/locations.mdx)[ article](/infrastructure/locations.mdx);
       * `<loadbalancer_uuid>` — load balancer ID. You can find the ID in the [control panel](https://my.selectel.ru/vpc/default/lbaas/load-balancers/): in the top menu, click **Products** → **Cloud Servers** → **Load Balancers** → load balancer page → under the load balancer name, click <CopyIcon />;
       * `<x_auth_token>` — IAM token for the project, which you copied in step 2;
       * `<log_group_name>` — name of the log group where the load balancer logs will be recorded. For more information about log groups, see the [Principle of Operation](/logs/about/about-logs.mdx#principle-of-operation) subsection of the [Logs Service Overview](/logs/about/about-logs.mdx)[ article](/logs/about/about-logs.mdx).
  </TabItem>
</Tabs>

## Disable logging for a load balancer \{#disable-logs-for-load-balancer}

<Tabs queryString="disable-logs-for-load-balancer">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [control panel](https://my.selectel.ru/vpc/default/lbaas/load-balancers/), in the top menu, click **Products** and select **Cloud Servers**.
    2. Go to the **Load Balancers** section → **Load Balancers \*\*\*\* tab**.
    3. Open the load balancer page.
    4. In the **Settings** block, in the **Logging** field, click <EditIcon />.
    5. Deselect the **Collect technical load balancer logs** checkbox.
    6. Click **Save**.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack API
    </TabItemLabel>

    1. [Obtain an IAM token for the project (X-Auth-Token)](/api/authorization/#iam-token-project-scoped).

    2. In the response output, copy the `X-Subject-Token` value.

    3. Open the CLI.

    4. Disable logging for the load balancer:

       ```bash
       curl --location --request DELETE 'https://<pool>.cloud.api.selcloud.ru/load-balancer/v2/lbaas/loadbalancers/<loadbalancer_uuid>/log_offloading' \
         --header 'X-Auth-Token: <x_auth_token>' \
         --header 'Content-Type: application/json;charset=utf-8'
       ```

       Specify:

       * `<pool>` — [pool](/infrastructure/locations.mdx#pool) where the load balancer is located, for example, `ru-8`. You can view the list of available pools in the [Selectel Infrastructure](/infrastructure/locations.mdx#selectel-infrastructure) subsection of the [Locations: countries, regions, availability zones, pools, and data center addresses](/infrastructure/locations.mdx)[ article](/infrastructure/locations.mdx);
       * `<loadbalancer_uuid>` — load balancer ID. You can find the ID in the [control panel](https://my.selectel.ru/vpc/default/lbaas/load-balancers/): in the top menu, click **Products** → **Cloud Servers** → **Load Balancers** → load balancer page → under the load balancer name, click <CopyIcon />;
       * `<x_auth_token>` — IAM token for the project, which you copied in step 2.
  </TabItem>
</Tabs>

## Retrieve logs \{#get-logs}

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

View the description of [log fields](#fields) for the load balancer.

## Log fields \{#fields}

Depending on the event type, different sets of fields are displayed in the log.

<Tabs queryString="fields">
  <TabItem value="http-logs" default>
    <TabItemLabel>
      HTTP request
    </TabItemLabel>

    <CustomTable>
      <table data-sticky>
        <tbody>
          <tr>
            <th>loadbalancer\_id</th><td>Load balancer ID</td>
          </tr>

          <tr>
            <th>elapsed</th><td>Request processing duration</td>
          </tr>

          <tr>
            <th>url</th><td>Request URL</td>
          </tr>

          <tr>
            <th>version</th><td>HTTP protocol version</td>
          </tr>

          <tr>
            <th>method</th><td>HTTP method of the request to the load balancer</td>
          </tr>

          <tr>
            <th>status</th><td>HTTP response status</td>
          </tr>

          <tr>
            <th>bytest\_in</th><td>Number of bytes transmitted in the request</td>
          </tr>

          <tr>
            <th>bytes\_out</th><td>Number of bytes transmitted in the response</td>
          </tr>

          <tr>
            <th>backend</th><td>Load balancer target group ID</td>
          </tr>

          <tr>
            <th>client</th><td>IP address and port from which the request originated</td>
          </tr>

          <tr>
            <th>frontend</th><td>Load balancer rule ID</td>
          </tr>

          <tr>
            <th>server</th><td>Server ID in the load balancer target group</td>
          </tr>

          <tr>
            <th>termination\_state</th><td>Session state at disconnection, for more information see the [8.5. Session state at disconnection](https://docs.haproxy.org/2.4/configuration.html#8.5) section of the HAProxy documentation</td>
          </tr>

          <tr>
            <th>frontend\_connections</th><td>Number of open connections for the load balancer rule</td>
          </tr>

          <tr>
            <th>backend\_connections</th><td>Number of open connections for the load balancer target group</td>
          </tr>

          <tr>
            <th>server\_connections</th><td>Number of open connections on the server that received the request</td>
          </tr>

          <tr>
            <th>retries</th><td>Number of request retries to the server</td>
          </tr>

          <tr>
            <th>destination</th><td>IP address of the server that received the request</td>
          </tr>

          <tr>
            <th>backend\_queue</th><td>Number of requests in the load balancer target group waiting to be processed</td>
          </tr>

          <tr>
            <th>server\_queue</th><td>Number of requests on the server waiting to be processed</td>
          </tr>
        </tbody>
      </table>
    </CustomTable>
  </TabItem>

  <TabItem value="tcp-logs" default>
    <TabItemLabel>
      TCP connection
    </TabItemLabel>

    <CustomTable>
      <table data-sticky>
        <tbody>
          <tr>
            <th>loadbalancer\_id</th><td>Load balancer ID</td>
          </tr>

          <tr>
            <th>elapsed</th><td>Request processing duration</td>
          </tr>

          <tr>
            <th>bytest\_in</th><td>Number of bytes transmitted in the request</td>
          </tr>

          <tr>
            <th>bytes\_out</th><td>Number of bytes transmitted in the response</td>
          </tr>

          <tr>
            <th>backend</th><td>Load balancer target group ID</td>
          </tr>

          <tr>
            <th>client</th><td>Client IP address and port</td>
          </tr>

          <tr>
            <th>frontend</th><td>Load balancer rule ID</td>
          </tr>

          <tr>
            <th>server</th><td>Server ID in the load balancer target group</td>
          </tr>

          <tr>
            <th>termination\_state</th><td>Session state at disconnection, for more information see the [8.5. Session state at disconnection](https://docs.haproxy.org/2.4/configuration.html#8.5) section of the HAProxy documentation</td>
          </tr>

          <tr>
            <th>frontend\_connections</th><td>Number of open connections for the load balancer rule</td>
          </tr>

          <tr>
            <th>backend\_connections</th><td>Number of open connections for the load balancer target group</td>
          </tr>

          <tr>
            <th>server\_connections</th><td>Number of open connections on the server that received the request</td>
          </tr>

          <tr>
            <th>destination</th><td>IP address of the server that received the request</td>
          </tr>

          <tr>
            <th>backend\_queue</th><td>Number of requests in the target group waiting to be processed</td>
          </tr>

          <tr>
            <th>server\_queue</th><td>Number of requests on the server waiting to be processed</td>
          </tr>
        </tbody>
      </table>
    </CustomTable>
  </TabItem>

  <TabItem value="administrative-logs" default>
    <TabItemLabel>
      Administrative event
    </TabItemLabel>

    Administrative event — change of [server status](/cloud-servers/load-balancers/target-groups/target-group-statuses.mdx#server-statuses) in a [target group](/cloud-servers/load-balancers/about-load-balancers.mdx#target-groups).

    <CustomTable>
      <table data-sticky>
        <tbody>
          <tr>
            <th>listener\_id</th><td>Load balancer rule ID</td>
          </tr>

          <tr>
            <th>loadbalancer\_id</th><td>Load balancer ID</td>
          </tr>

          <tr>
            <th>status</th><td>New status of the server in the target group</td>
          </tr>

          <tr>
            <th>pool\_id</th><td>Target group ID</td>
          </tr>

          <tr>
            <th>member\_id</th><td>Server ID in the target group</td>
          </tr>
        </tbody>
      </table>
    </CustomTable>
  </TabItem>
</Tabs>

<Formbricks />
