Create a DataAgent

Updated at:

A DataAgent is a digital employee that understands your business definitions and data sources based on the bound Context Models. It uses the specified Resource Access Management (RAM) role to query Simple Log Service (SLS) data. Create a DataAgent for a specific business scenario.

For your first experience, you can use the three-step quick wizard in the console instead of the procedure in this topic. For instructions, see the Getting started with SLS DataAgent topic.

Prerequisites

  • At least one Context Model that contains available data tables, metrics, or terms. The Context Model must be created in your Alibaba Cloud account and in an available central region.

  • The system default role aliyunslsdataagentrole, or a custom RAM role that trusts SLS (log.aliyuncs.com).

  • Your user has the permissions to create DataAgents.

  • If you use a custom role, your user has the ram:PassRole permission on that role.

Design the responsibilities of a DataAgent

Define a clear scope of responsibilities before you create a DataAgent. For example, an order system monitoring expert is easier to configure and validate than a general data assistant.

Write down the following items in advance:

  • Who the main users of the DataAgent are.

  • Which business objects and metrics the DataAgent is responsible for.

  • Which projects, LogStores, and time ranges the DataAgent is allowed to query.

  • How to clarify ambiguous questions. For example, clarify first when multiple data sources or metrics match.

  • Which evidence and limitations the answers must display, such as the time range, the metric definitions, or the query result.

A DataAgent does not need to cover all the data in your account. Splitting DataAgents by business line or scenario usually makes permissions and answer accuracy easier to control.

Procedure

  1. Log on to the SLS console and go to SLS DataAgent.

  2. In the top navigation bar, click Agents.

  3. On the DataAgent list page, click Create DataAgent.

  4. Configure the following parameters.

    ParameterRequiredDescription
    nameYesThe unique identifier of the DataAgent. The value must be 4 to 64 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). You cannot modify the value after creation.
    displayNameNoThe name displayed in the console. You can use Chinese characters. (Recommended) Reflect the responsibilities of the DataAgent in the name.
    descriptionNoDescribes the business scope, the main data, and the target users that the DataAgent is responsible for.
    Context ModelYesBind at least one Context Model. The bound models determine the business definitions and the data source scope that the DataAgent can understand.
    System PromptNoDefines the role, the behavior boundaries, and the output requirements. The value can be up to 16,000 characters in length. For details, see Write the System Prompt.
    RAM roleYesThe role that the DataAgent uses to access SLS data at runtime. For details, see Select a RAM role.
  5. Confirm the configuration and click OK.

Result

The DataAgent appears in the Agents list. On the details page of the DataAgent, you can start a new session, view historical sessions, or edit configurations such as the description, the Context Models, and the System Prompt.

Write the System Prompt

Use the System Prompt to describe behavior. Do not use the System Prompt to store business facts in place of the Context Model.

Write the System Prompt from the plan in Design the responsibilities of a DataAgent. The System Prompt can also contain the following items:

  • An explicit statement of uncertainty instead of guessed meanings of fields and metrics.

  • The output format, for example, the conclusion first and then the data evidence.

The following example shows a System Prompt for an order system DataAgent:

You are a data analytics assistant for the order system, and you serve R&D and operations staff.

Use only the data and the metrics in the bound Context Models when you answer. When an expression has multiple definitions, such as revenue or successful order, list the available definitions first and ask the user to confirm.

State the query time range, the metrics used, and the data sources when you return a result. State explicitly what cannot be confirmed from the existing data, and do not add cause analysis without evidence.

Maintain fields, metric formulas, term aliases, and query SQL statements in the Context Model. Repeating this content in the System Prompts of multiple DataAgents increases the cost of later modifications and easily causes inconsistent definitions.

Select a RAM role

You can use the system default role for your first experience. In a production environment, create a custom role based on the responsibilities of the DataAgent, and grant only the read permissions on the required projects and LogStores.

A data source in the Context Model does not mean that the RAM role automatically has access permissions on it. The model scope and the role permissions must both cover the target data before a query can succeed.

FAQ

What do I do if creation fails and the role is reported as invalid?

Check whether the role ARN is correct, whether the role trusts SLS, and whether your user has the ram:PassRole permission on that role.

What do I do if the Context Model that I want to bind cannot be found?

Confirm that the Context Model meets the requirements in Prerequisites, and check whether your user has the permissions to view it.

How many Context Models should a DataAgent bind?

Bind only the Context Models required to complete the responsibilities of the DataAgent. More models mean more data sources and more metrics with the same name that can match, which also increases the cost of clarification.