[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for PostgreSQL](../index.md) > [Step-by-step guides](index.md) > Logs and monitoring > Connecting to DataLens

# Connecting to a PostgreSQL cluster from DataLens

[Yandex DataLens](../../datalens/concepts/index.md) is a business intelligence service, that lets you upload, process and visualize data for analysing and testing hypotheses. It can help you make marketing decisions for your product.

To use an existing cluster as a data source for Yandex DataLens:
1. [Activate DataLens](#activate-datalens).
1. [Allow access to the cluster from DataLens](#allow-access).
1. [Create a cluster connection in DataLens](#create-connector).

## Activating DataLens {#activate-datalens}

{% note alert "Limit" %}

You can only create one DataLens instance in the cloud.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), navigate to the folder page.
    1. Navigate to **DataLens**.
    1. Click **Activate DataLens**.

{% endlist %}

The DataLens instance will be activated in the selected folder.

## Allowing access to a cluster from DataLens {#allow-access}

To allow DataLens to connect to your cluster and work with its data, enable **DataLens access** when [creating](cluster-create.md) or [reconfiguring](update.md#change-additional-settings) the cluster.

![screen01](../../_assets/managed-postgresql/operations/datalens-connect/screen01.png)

## Creating a cluster connection {#create-connector}

{% list tabs group=instructions %}

- Management console {#console}

  1. Make sure DataLens is [activated](#activate-datalens) in the relevant folder and has [permission](#allow-access) to access the cluster.
  1. Navigate to **Managed Service for&nbsp;PostgreSQL**.

     ![screen02](../../_assets/managed-postgresql/operations/datalens-connect/screen02.png)

  1. Click the name of your cluster and open the **DataLens** tab.
  1. Click **Create connection**.

     ![screen03](../../_assets/managed-postgresql/operations/datalens-connect/screen03.png)

     {% cut "I have no **Create connection** button" %}

     If you see the _DataLens not activated_ message instead of the **Create connection** button, you have either not yet activated DataLens or activated it in a different folder. To connect your cluster to a DataLens instance from another folder, follow [this DataLens guide](../../datalens/operations/connection/create-postgresql.md).

     {% endcut %}

  1. [Set up your connection](#connector-settings).
  1. Check that the settings are correct by clicking **Check connection**.
  1. After a successful connection test, click **Create connection**.

     ![screen04](../../_assets/managed-postgresql/operations/datalens-connect/screen04.png)

  1. In the window that opens, specify the connection name and click **Create**.

     ![screen05](../../_assets/managed-postgresql/operations/datalens-connect/screen05.png)

{% endlist %}

After creating the connection, you can:
* [Update](#update-connector) or [delete](#delete-connector) this connection.
* Use this connection to [create datasets](../../datalens/dataset/index.md) from the cluster data.
* Visualize the datasets using [charts](../../datalens/concepts/chart/index.md) and [dashboards](../../datalens/concepts/dashboard.md).

## Viewing a list of cluster connections {#connectors-list}

{% list tabs group=instructions %}

- Management console {#console}

  1. Navigate to **Managed Service for&nbsp;PostgreSQL**.
  1. Click the name of your cluster and select the **DataLens** tab.

     ![screen11](../../_assets/managed-postgresql/operations/datalens-connect/screen11.png)

{% endlist %}

## Updating a cluster connection {#update-connector}

{% list tabs group=instructions %}

- Management console {#console}

  1. Navigate to **Managed Service for&nbsp;PostgreSQL**.
  1. Click the name of your cluster and select the **DataLens** tab.
  1. Select the connection from the list.

     ![screen12](../../_assets/managed-postgresql/operations/datalens-connect/screen12.png)

  1. Change the [settings](#connector-settings).
  1. Check that the settings are correct by clicking **Check connection**.
  1. After a successful connection test, click **Save changes**.

     ![screen06](../../_assets/managed-postgresql/operations/datalens-connect/screen06.png)

{% endlist %}

## Deleting a cluster connection {#delete-connector}

{% list tabs group=instructions %}

- Management console {#console}

  1. Navigate to **Managed Service for&nbsp;PostgreSQL**.
  1. Click the name of your cluster and select the **DataLens** tab.
  1. Select the connection from the list.
  1. Click ![image](../../_assets/console-icons/ellipsis.svg) at the top of the page and select **Delete**.

     ![screen07](../../_assets/managed-postgresql/operations/datalens-connect/screen07.png)

  1. In the window that opens, click **Delete**.

     ![screen08](../../_assets/managed-postgresql/operations/datalens-connect/screen08.png)

{% endlist %}

## Connection settings {#connector-settings}

{% list tabs group=instructions %}

- Management console {#console}

  1. If your cluster and DataLens are in the same organization:
     1. Navigate to the **Select within organization** tab.
     1. Select the cloud and folder where your cluster is located.
     1. Select the cluster and its host from the drop-down lists or [create a new cluster](cluster-create.md) in the folder with DataLens by clicking **Create new**.
     1. Leave the **Port** setting unchanged.
     1. Select **Path to database** from the drop-down list.
     1. Select the user from the drop-down list.
     1. Enter this user's password.
     1. Specify the cache TTL or leave the default value. The recommended value is 300 seconds (5 minutes).
     1. Configure the **Raw SQL level**.

        ![screen09](../../_assets/managed-postgresql/operations/datalens-connect/screen09.png)

     1. To explicitly specify collation for your database queries, navigate to **Advanced connection settings**. Select a **Query-level collation** mode:
        * **Auto**: Applies the default setting. DataLens decides whether to enable the `en_US` locale.
        * **On**: Applies the DataLens setting. The `en_US` locale is specified for individual expressions within a query. As a result, the server uses the appropriate sorting logic, regardless of the server settings and specific tables. Use the DataLens setting if your database locale is incompatible with DataLens. For more information about the locale and the `LC_COLLATE` setting, see [Creating a cluster](cluster-create.md#create-cluster).
        * **Off**: Applies the default setting. DataLens only uses database-level locale settings.

        ![screen10](../../_assets/managed-postgresql/operations/datalens-connect/screen10.png)

   1. If the cluster and DataLens belong to different organizations, apply the configuration from this DataLens [tutorial](../../datalens/operations/connection/create-postgresql.md).

{% endlist %}