Connect via DataFlux Func¶
DataFlux Func is a scripting development and execution platform. External data sources are accessed through a deployed Func instance and its connectors, and the results are then passed to TrueWatch for querying and display.
This approach is suitable for environments with an existing Func deployment, as well as scenarios that require script processing, third-party API calls, or custom data structures for charts. Unlike QueryHub, connection configurations and scripts for Func are managed in the Func platform; existing Func data sources continue to use their original IDs and query methods.
Prerequisites¶
- A DataFlux Func instance is deployed and connected to the target workspace. If it has not been deployed yet, see Func Quick Start.
- The environment where Func is located can access the target data source, and the account used has the required query permissions.
Add a Data Source in the Console¶
- Go to Integrations > External Data Sources, and click Add Data Source.
- Select Connect via DataFlux Func.
- Select the connected DataFlux Func from the list.
- Select the data source type, and then enter the connection information.
| Configuration Item | Description and Entry |
|---|---|
| DataFlux Func | The Func instance responsible for connecting to the target data source. Select an instance that is network-accessible and already associated with the current workspace |
| Data Source Type | The actual type of the target database or service. The available options depend on the connector capabilities of the selected Func |
| Data Source ID | Identifies this integration configuration. Set it as required on the page; when reusing an existing Func connector, keep it consistent with the connector ID. Do not use a database name or API Key instead |
| Title | The display name of the data source in lists and the query selector |
| Host Address, Port | The actual connection address of the data source, provided by the database or service administrator. Do not enter the management console URL |
| Database | The name of the database to access for a relational database connection, not a table name |
| Username, Password | Credentials for accessing the target database or service, not workspace login credentials |
Fields vary by connector. Enter the information required for the current type as shown on the page. After completing the configuration, test the connection and save it. When configuring operation permissions, follow the permission rules for workspaces and external data sources.
Use in Queries¶
- In Metrics Analysis or a chart, add a Data Source Query.
- Select a data source connected via Func.
- Enter a native query statement supported by the connector, and run the query or refresh the results.
- Choose how to display the results based on the returned structure.
For example, if the MySQL table orders contains id, total, and status, you can query paid orders:
This uses the syntax supported by the selected Func connector. You cannot switch to QueryHub by modifying the query text.
When Script Processing Is Required¶
If direct queries cannot meet your requirements, create a connector of the corresponding type in Func, obtain the object through the connector ID, and write a custom function to process the results:
Here, mysql is the ID of the MySQL connector in Func, not a data source type name, table name, or workspace ID.
- When querying an external MySQL database, create and use a MySQL connector.
- If the script also needs to call the TrueWatch API, create the corresponding connector as needed and configure the workspace API Key.
You can create an API Key in Manage > API Key Management. For details, see API Key Management. Do not enter a workspace API Key in the database password field.
For complete steps and the return format, see Custom Query Function.
Management and Maintenance¶
In Integrations > External Data Sources, view data source types, IDs, associated Func instances, and statuses, and edit or delete configurations according to permissions.
- Existing data source IDs and query references follow the original rules; they are not automatically migrated due to the addition of the QueryHub entry point.
- After the database password or network changes, update the Func connection configuration in use and revalidate queries.
- Before deleting a connection, confirm the reference relationships of related charts and scripts; after deletion, existing references may no longer be able to query.
For existing dedicated TiDB Cloud Lake integrations, continue to refer to the corresponding guide; there is no need to change to a Func connector.
