Data Agent User Guide

Updated at:
Copy as MD

Data Agent is a data processing and analytics agent provided by AnalyticDB for PostgreSQL. It is used through a desktop client and provides three types of capabilities: natural language querying, business semantic understanding (Ontology), and intelligent DBA diagnostics. You can use natural language to obtain query results and analysis suggestions, ensure business metric accuracy through the semantic layer, and locate O&M issues through diagnostic scenarios such as slow query analysis, SQL diagnostic optimization, and lock wait analysis. This topic describes how to install and configure Data Agent, perform intelligent querying and business analysis, and use intelligent DBA diagnostics.

Installation and Basic Configuration

Environment requirements: an AnalyticDB for PostgreSQL V7.0 instance with kernel version 7.2.1.4 or later. The client supports macOS (arm64/x64) and Windows (x64). To obtain the installation package, see Data Agent.

Perform the following three steps to get started: configure the model service, connect a data source, and select a workspace. There is also an optional configuration (RAM AccessKey) that is required only when you use instance monitoring or diagnostic scenarios that depend on monitoring metrics.

Configure the model service

  1. When you start the application for the first time, you are guided to enter the AI Gateway connection information (Base URL and API key). You can also click Set up later and add the information later in Settings → Model → Model Provider.

  2. Obtain the connection information in the AnalyticDB for PostgreSQL console: go to AgenticDB → Model Operator Management, click Create API Key, enter a description, and confirm. Then you can obtain the endpoint and API key. After creation, submit a ticket so that the Alibaba Cloud technical team can complete the backend configuration.

  3. Enter Base URL and API key in the form. The Base URL is the endpoint of the model service, and the API key is used for identity verification.

  4. Save the configuration. After you save the configuration, the provider appears in the model list and automatically becomes the default model. When you create a session, the model selector in the lower-right corner of the input box shows Default model.

Connect a data source

  1. In the left-side Data Sources panel, click Add Data Source and enter the name, host address, port, username, password, and default database.

  2. If the application and the instance are not in the same internal network environment, enable public access in the instance console and add the public IP address of the local machine to the instance whitelist. You can query the public IP address of the local machine through services such as ifconfig.me.

  3. Click Test Connection. If the connection is successful, the databases accessible to the account are listed. Confirm and save the settings.

Important

We recommend that you use a read-only account with SELECT permissions to connect to the instance to minimize the permission scope. Do not use privileged accounts.

Workspaces and data sources

Workspaces associate sessions with data sources. You can bind a default data source to a workspace. Then, sessions initiated from the workspace access the data source by default.

During a conversation, you can temporarily switch the data source used by the current session in the lower-right corner of the input box. The switch applies only to the current session and does not change the default binding of the workspace.

Optional: configure a RAM AccessKey pair (AK/SK)

A RAM AccessKey pair (AK/SK) is used to call Alibaba Cloud OpenAPI operations to obtain instance monitoring and O&M data such as CPU, memory, and I/O trends and slow SQL records. This is an optional global configuration. After you enter it once, it takes effect for all data sources. All OpenAPI operations called are read-only. The configuration is required for the instance monitoring page and some diagnostic scenarios that depend on these metrics, such as resource usage diagnostics. Features that depend only on database connections are not affected and work normally without the configuration.

  1. On the instance monitoring page, click Configure AK/SK to open the configuration box.

  2. Create the AccessKey pair in the RAM console. For more information, see Create an AccessKey pair. After creation, grant the AliyunGPDBReadOnlyAccess system policy to the associated RAM user.

  3. Enter the AccessKey pair in the configuration box to complete the configuration. This is a global configuration that takes effect for all data sources after you enter it once.

Interface overview

The main interface of the application contains the following areas:

  • Chat: the entry to natural language querying and business analysis.

  • DBA Diagnostics: built-in diagnostic scenario templates. You can initiate diagnostics scenario by scenario for the selected instance (see the Intelligent DBA Diagnostics section below).

  • Instance Monitoring: instance running status and resource monitoring curves (see the following description).

  • Ontology: presents the business semantic layer of a specified database as a knowledge graph, including business domains, concepts, metrics, and metric rules (see the Intelligent Querying and Business Analysis section below).

  • Skills: view the built-in skill packages of the application and their descriptions.

  • Data Sources / Workspaces / Settings: manage instance connections, session ownership, and application configurations.

The middle of the DBA Diagnostics page is the data source list, and the right side is the scenario template list. You can select different data sources to diagnose different instances.

The left side of the instance monitoring page lists all instances under the account, and the right side shows the running status and monitoring curves of the selected instance, including the health of coordinator nodes and compute nodes, engine version, instance mode, region, and metrics such as the number of connections, QPS, TPS, and average query response time. Monitoring is provided in two dimensions: Instance Monitoring and Node Monitoring. The supported time ranges are 30 minutes, 1 hour, 6 hours, and a custom range. Instance monitoring data is obtained through the OpenAPI operations described in the RAM AccessKey configuration. Complete the configuration before the first use.

Intelligent Querying and Business Analysis

Overview

Natural language querying generates only read-only statements (SELECT/WITH) and executes them in read-only transactions without modifying data. In addition to query results, Data Agent provides analysis conclusions and suggestions based on business metrics. The following example uses a coffee chain retail database to describe the process from asking a question to outputting an analysis report.

Ontology semantic layer

Querying and business analysis depend on the accurate understanding of business metrics, while table names, column names, and comments do not contain all business knowledge. The semantic layer is not automatically generated by the LLM. Instead, it is a co-construction process in which business personnel provide definitions and the LLM assists business modeling. This is the source of all Ontology metrics. Business personnel provide:

  • Effective revenue must deduct canceled orders, internal employee orders, near-free promotional orders, and tax adjustments for specific periods from the order amount. These rules are not reflected in column comments.

  • Store performance index is calculated by weighting revenue growth, customer satisfaction, operational efficiency, and new customer ratio with fixed weights. The weights are defined by the operations department and are not in the data.

  • Revenue has different metrics in financial monthly reports and operational daily reports. Mixing them leads to inaccurate results.

The Ontology semantic layer consolidates the preceding business knowledge in the form of a knowledge graph, including business domain division, metric calculation formulas, metric application scenarios, table relationships, and sensitive data identification. The Agent uses the definitions in the semantic layer as the standard for answering questions.

The semantic layer provides the following benefits:

  • Consistent metrics: metrics are calculated based on business definitions to avoid using wrong columns or formulas.

  • Ambiguity clarification: when a question is ambiguous (for example, "query revenue" without specifying the report type), the Agent asks for confirmation first.

  • Sensitive data isolation: sensitive data (such as employee salaries) is identified and skipped, and does not enter the analysis.

In the coffee chain example, the semantic layer covers 6 business domains, 16 tables, 190 concepts, and 77 metrics. On the Ontology page, you can view the mapping tables, associated metrics, and business rules of each concept layer by layer. Metrics with metric warnings (for example, Product revenue cannot be mixed with store-dimension transaction amounts) are explicitly marked.

Build the semantic layer

  1. Administrators complete environment preparation and authorization in the target database: enable the age extension, create the semantic and graph-related schemas, and grant permissions to the build account. For authorization scripts and FAQ, see Ontology Usage Guide. We recommend that you distinguish the build account (ontology_builder) from the query account (ontology_reader). They can also be the same account.

  2. Connect with the build account on the Ontology page of the client.

  3. Perform the following operations in sequence: Initialize → Generate Semantics → Sync YAML → Build.

  4. After the build is complete, the query account can use the semantic layer, and no re-authorization is required for routine incremental updates.

Example: generate a business analysis report

Enter the following text in the dialog box:

"View the business tables in the coffee database, analyze the corresponding business based on the content of these tables, and provide analysis results and business suggestions."

The Agent processes the request as follows:

  1. Read the semantic layer: load the Ontology, understand the data layering and business domain structure, and check data permissions. After identifying that employee salaries belong to a sensitive domain, the Agent automatically skips them.

  2. Align metric definitions: read the definitions and deduction rules of metrics such as the performance index, effective revenue, and loyalty to ensure consistent calculation metrics.

  3. Identify anomalies: during analysis, the Agent detects anomalies such as the number of new customers dropping from 113 to 0 and the operational efficiency of stores approaching zero, and confirms them by reviewing the factor decomposition and truncation rules of the performance index.

  4. Output the analysis report: the report first describes the overall business situation, then expands on three issues (new customers dropping to zero, invalid performance index, and inflated revenue metrics), and includes store matrix comparison, revenue deduction structure breakdown, category and channel analysis, and customer segmentation (customers with 4 to 6 orders are the main force, and only 5 Diamond-level customers exist).

  5. Provide graded suggestions: output 20 suggestions graded by priority: P0 metric correction, P1 growth, P2 store management, and P3 data quality governance.

The final report contains conclusions, evidence, and action suggestions.

Intelligent DBA Diagnostics

Overview

Intelligent DBA Diagnostics encapsulates the locating process of common O&M issues into diagnostic scenario templates, with each scenario corresponding to a type of issue. After selecting a data source and a target database, click the corresponding template to initiate a diagnosis. The Agent automatically invokes diagnostic capabilities, performs correlation analysis, outputs conclusions and handling suggestions, and generates a structured report.

Note
  • Read-only operations: diagnostics perform only read-only queries and do not modify any data.

  • Independent sessions: each diagnosis generates an independent session. You can review historical reports in the session list on the left.

  • Continued interaction: in addition to clicking scenario templates, you can describe the issue in natural language in the dialog box, and the Agent selects the diagnostic method. Sessions generated by diagnostics also support follow-up questions and additional requirements.

  • Operation path: click DBA Diagnostics on the left → select a data source → click a scenario template → select the target database (some scenarios require an SQL statement or time range) → click Start Diagnosis.

Diagnostic scenarios

Each scenario corresponds to a type of O&M issue. The following table describes the purpose and applicable timing of each scenario.

Slow query analysis

Summarizes the SQL statements that consume the most resources within a specified time range and checks whether slow queries are running, to locate the statements that slow down the instance. Use this scenario first when the instance slows down overall or a resource alert is received.

SQL diagnostic optimization

Analyzes the execution plan of a single SQL statement, locates time-consuming operations (scans, joins, aggregations, etc.), determines whether the plan is reasonable, and provides rewriting or index suggestions. Applicable when a single query slows down or before new queries go online.

Resource usage diagnostics

Analyzes the causes of high CPU, memory, and I/O usage, distinguishes between business growth and slow SQL impact, and determines whether scaling is required. Applicable to attribution after resource alerts and evaluation before scaling decisions.

Lock wait analysis

Analyzes the current lock wait relationships: the blocking and blocked parties, the lock type held by the blocking source, and the blocked statements. Use this scenario to locate the blocking source when queries get stuck or other accesses hang after DDL operations.

Long transaction diagnostics

Finds transactions that remain uncommitted for a long time, determines whether they are zombie connections and whether they affect VACUUM reclamation. Use this scenario to locate the cause when bloat occurs repeatedly or connections are occupied for a long time.

Data skew diagnostics

Checks whether data is evenly distributed among compute nodes and whether the distribution key is appropriate. Prioritize data skew troubleshooting when individual nodes remain busy or aggregation queries are significantly slow.

Table bloat check

Locates bloated tables, estimates reclaimable space, and provides cleanup suggestions. Bloat is usually signaled when table size grows but the number of rows does not increase accordingly.

Index usage diagnostics

Checks index usage: which indexes have not been used for a long time and occupy reclaimable space, and which tables are frequently fully scanned and lack appropriate indexes. Applicable when writes slow down, storage grows continuously, or you need to confirm index health.

Diagnostic report structure

Reports of all scenarios have the same structure, which contains the following parts:

  • Conclusion summary: states at the beginning whether an issue exists, the object of the issue, and the handling direction.

  • Details and charts: numeric results are presented in tables and charts.

  • Handling suggestions: SQL suggestions are generated based on actual table structures. Confirm the suggestions based on the actual instance situation before execution. For risky operations (such as terminating sessions and VACUUM FULL), the impact and precautions are also described.

Important

Diagnostic reports and querying conclusions are generated by the model and may be inaccurate. Before performing change operations (such as terminating sessions, cleaning up space, or rewriting SQL), manually check the objects and statements in the report and confirm the impact before execution.

Reference documentation