Data connection

Key principle: network accessibility

Before creating a connection in the DataLens UI, always ask yourself: Can the DataLens server access the database server over the network?

Network restrictions account for 90% of connection issues:

  • Firewall: Blocks the port at the database server or network equipment.
  • Security groups: In cloud environments, security group rules deny incoming traffic from DataLens VMs.
  • Incorrect host or port: There is a typo in the connection credentials.

How to troubleshoot issues

Use the control-api pod to check accessibility with curl or telnet. You can also use the ./init.sh --kubectl get pods command.

# Connect to the `control_api` pod
./init.sh --kubectl exec -it <control-api-pod-name> -- /bin/bash

# Check access to your host and port
curl -v telnet://my-postgres-db.internal:5432

Check pod logs for information on the Connection timeout. To do this, run the following command:

 ./init.sh --stern --tail 100 --no-follow pod/<control-api-pod-name>

Creating a basic connection

This is a basic use case. To create a connection, the user needs the Editor or Admin role.

  1. In the DataLens UI, navigate to Connections and click Create connection.
  2. Select a source type, e.g., PostgreSQL.
  3. Fill in these fields: host name, port, database name, username, and password.
  4. Click Check connection. If successful, save the configuration.

Sensitive data in connection fields, e.g., passwords or tokens, is encrypted using CONTROL_API_CRYPTO_KEY, one of the two key types in DataLens. It is generated and saved automatically.

Connecting to a database with TLS encryption

Note

This is a task for the administrator, not users.

Corporate environments often rely on TLS for secure data transfer. If a database uses a certificate signed by an internal certificate authority (CA), DataLens will not trust it by default.

To fix this, select the TLS option in the connection and specify the required parameters: Advanced connection settings → TLS = On and attach the certificate under CA Certificate.

Configuring and using file connections

To work with files, first enable the files feature in values.yaml. Workflow for users:

  1. Create a File-type connection.
  2. Upload a CSV or XLS file.
  3. This file is saved to the internal S3 storage (MinIO), with its contents then pushed to ClickHouse®.
  4. DataLens automatically creates a dataset over the resulting ClickHouse® table.

Tip

The admin's responsibility is to make sure all components (S3, ClickHouse®, and Valkey™) are running correctly and have enough available storage.

Connector features

JSON API

Enables you to connect to sources that return JSON data over HTTP. The connector is used together with Editor to rapidly build charts from software sources.

To learn more about using the API Connector, see this article.

Trino (formerly PrestoSQL)

It is not a database but a federated query engine. Trino enables you to run a single SQL query to data residing in different systems, e.g., join PostgreSQL and S3 data in one query. DataLens connects to Trino, and Trino, to the end sources.

For more on connecting to Trino, see this guide.

Hands-on task: Creating a file-based connection

  1. Ensure the files feature is enabled in your values.yaml:

    features:
    files:
        enabled: true
    

    If not, enable it and apply this configuration: ./init.sh --values <your_file>.yaml.

  2. Create a simple sales.csv file on your local computer:

    City,Sales
    Moscow,1500
    Paris,1200
    London,1800
    
  3. In the DataLens UI, create a new File connection.

  4. Upload sales.csv and wait for it to get processed.

  5. Upon successful upload, you see a data preview window. Click Create in the top right corner.

Use case

A user reports their connection to Greenplum® fails with a Connection timed out error. What is your first troubleshooting step?

  • Restart the data-api pod.
  • Check the user's password.
  • Check network access from the data-api pod to the Greenplum® host and port.
  • Ask the user to check their SQL query.
Find out the answer
  • Restart the data-api pod.

    Incorrect. Restarting will help if the pod is not responding, but this is not your first step. You need to find out the cause of the issue first.

  • Check the user's password.

    Incorrect. An incorrect password usually results in the Authentication failed error, not Connection timed out.

  • Check network access from the data-api pod to the Greenplum® host and port.

    Correct. Connection timed out is a telltale sign of a network issue caused by firewall or security group settings.

  • Ask the user to check their SQL query.

    Incorrect. Creating a connection does not yet involve running SQL queries. This is a lower-level issue.

Results

You have reviewed one of the most common administrator tasks: ensuring data connectivity. Now you can create basic and file-based connections and configure TLS properly.