Access and Query TiDB Cloud Lake¶
After adding TiDB Cloud Lake in Integrations > External Data Sources, you can select this data source in query entry points that already support external data sources, such as Metrics Analysis and Dashboards, and execute native read-only SQL on TiDB Cloud Lake. This integration is carried out by the Guance server side via the TiDB Cloud Lake Driver and does not depend on DataFlux Func.
Prerequisites¶
- Already obtained the Lake DSN;
- The Lake DSN contains a valid Database and Warehouse;
- The SQL user has read-only query permissions on the target data;
- The current account has permission to configure external data sources.
Add a Data Source¶
- Go to Integrations > External Data Sources;
- Click Add Data Source;
- In Select Connection Method, choose TiDB Cloud Lake Direct Connection;
- Confirm the data source type is read-only TiDB Cloud Lake;
- Fill in the connection properties:
| Configuration Item | Required | Description |
|---|---|---|
| Name | Yes | Displayed in the external data source list and the query data source selector |
| Description | No | Used to describe the data scope, purpose, or responsible person |
| Lake DSN | Yes | Paste the full DSN copied from the TiDB Cloud Lake Connect page |
TiDB Cloud Lake Direct Connection does not require a data source ID. When connecting other external data sources via DataFlux Func, the existing ID field and configuration requirements remain unchanged.
After completing the above fields:
- Click Test Connection. The system will verify the DSN, Warehouse, network connectivity, and query permissions of the SQL user;
- In Set Permissions, enable custom operation permissions as needed:
- Disabled: Follows the default permissions of "External Data Sources";
- Enabled: Only the creator, administrators, and specified members can operate or use this data source;
- Save the data source.
Connection Security
The password in the Lake DSN is only transmitted encrypted when saving and is not displayed in the list, details, or queries. Queries are executed by the server side; the browser does not obtain the DSN.
Use in Queries¶
The following steps use Metrics > Metrics Analysis as an example; the operation is the same in other query entry points that support external data sources, such as Dashboards.
- Go to Metrics > Metrics Analysis;
- Add a Data Source Query;
- Open the data source selector and select the TiDB Cloud Lake data source you just created;
- Hover over the data source name to confirm the data source type, Database, and Warehouse;
- Enter a native read-only SQL statement;
- Click Run Query to view the results;
- Optionally, save the query results to a dashboard or other supported display scenarios.
For example:
SELECT
service,
COUNT(*) AS log_count
FROM observability.application
WHERE event_time BETWEEN #{startTime} AND #{endTime}
GROUP BY service
ORDER BY log_count DESC
LIMIT 100;
Adjust the example according to your actual table structure, field names, and TiDB Cloud Lake SQL syntax.
SQL Usage Scope¶
| Item | Description |
|---|---|
| Supported | Single SELECT, WITH ... SELECT, EXPLAIN |
| Not Supported | INSERT, UPDATE, DELETE, DDL, transactions, CALL, file access, and multiple statements |
| Default Timeout | 60 seconds |
| Maximum Return | 10,000 rows |
If the query times out or exceeds the return limit, narrow the query time range, add more filter conditions, or use LIMIT.
Manage Data Sources¶
On the Integrations > External Data Sources page, you can filter by data source type TiDB Cloud Lake or search by name.
- Edit: Modify the name, description, Lake DSN, or operation permissions;
- Delete: After deletion, existing queries that reference this data source will no longer be able to execute;
- Change Password: After changing the password in TiDB Cloud Lake, re-obtain the DSN and edit the data source.
Verification Results¶
After configuration, the following should all be true:
- The external data source is saved successfully;
- Authorized members can see the data source in the query data source selector;
- Executing a read-only SQL statement returns results;
- Unauthorized members cannot select or execute the data source.
If the connection test or query fails, refer to the FAQ.