Getting started with SLS DataAgent

Updated at:

Simple Log Service (SLS) DataAgent lets you query and analyze your log data in natural language. This quickstart shows you how to initialize a Source Model, a Context Model, and a DataAgent from an existing SLS Project, and then run your first query.

Background information

SLS DataAgent is built from three objects:

  • Source Model — Corresponds to the target Project and describes the LogStores in that Project.

  • Context Model — Is connected to the target LogStores and stores the business understanding, including the schema, metrics, terms, and query examples.

  • DataAgent — Is bound to a Context Model and answers your natural language questions based on that model.

    The console provides two entry points: a quick wizard that creates the three objects in sequence, and a management page for each object. Use the quick wizard for your first experience, as described in this topic. Use the management page of an object when you need to control the data scope, the business definitions, or the Resource Access Management (RAM) role.

Prerequisites

  • SLS is activated, and you have at least one Project and one LogStore in a supported region.

  • The target LogStore has an index configured and contains log data that you can query.

  • Your Alibaba Cloud account is granted access to the SLS DataAgent public preview.

  • The Alibaba Cloud account or RAM user that you use has the permissions to create models and DataAgents.

  • The system default role aliyunslsdataagentrole is authorized, or you have prepared a custom RAM role that SLS can assume.

Create and verify a DataAgent

Steps 1 and 2 are performed in the quick wizard. Steps 3 to 6 are performed on the management pages and the DataAgent session page, where you verify the generated objects and run your first query.

Step 1: Go to SLS DataAgent

  1. Log on to the SLS console.

  2. Go to SLS DataAgent.

    If your account does not have an available DataAgent, the page displays the quick wizard. If your account already has a DataAgent, you can verify and adjust the objects on the management pages that Steps 3 to 6 describe.

The quick wizard groups the configuration into three stages:

  • Connect a LogStore and generate a Source Model. This stage corresponds to Steps 2 and 3 in this topic.

  • Build the business understanding, and generate or create a Context Model. This stage corresponds to Step 4 in this topic.

  • Create a DataAgent and start to query data in natural language. This stage corresponds to Steps 5 and 6 in this topic.

    The three stages in the wizard interface are not the same as the step numbers in this topic.

Step 2: Select the region and the Project

In the quick wizard, select the target region, and then select the Project that contains your business logs. For your first attempt, select a Project that has a clear data scope, standardized field names, and existing dashboards or alert rules, so that the system can identify more field and metric meanings.

Click Create Agent. The system then generates the Source Model, builds the Context Model, and initializes the DataAgent in sequence. The page indicates that the generation takes approximately 3 minutes. This is a UI indication, not a fixed completion time. The actual duration depends on the LogStores, the query assets, and the data volume in the Project.

Wait until the generation is complete before you continue to Step 3.

Important

Only one generation task can run at a time for the same Project. Do not click Create Agent again while a task is running.

If the generation does not complete, see What do I do if the creation process does not complete?.

Step 3: Verify and correct the Source Model

Go to the Source Model page and open the Project that you just selected.

Verify the following items:

  • All LogStores that you want to query are listed.

  • The Schema tab identifies the main fields of those LogStores.

  • The metrics and terms match the actual business meanings.

  • No field, metric, or term that you need is marked as "Not adopted".

    Content that is not adopted is not used by the DataAgent. On the Source Model page, edit the content that is inaccurate, and manually adopt the content that you confirm is correct.

Step 4: Verify and complete the Context Model

Go to the Context Model page and confirm that the target Project and LogStores are connected. The Context Model details page contains the Schema, Metrics, Terms, and Examples tabs.

If your business contains expressions that are easy to confuse, such as successful order, valid request, and active user, add terms or query examples in the Terms or Examples tab before you start formal testing.

Step 5: Verify the DataAgent configuration

Go to the Agents page and open the newly created DataAgent. Confirm the following items:

  • The name and the description explain the business scope that the DataAgent is responsible for.

  • The correct Context Model is bound.

  • The RAM role can access the target Project and LogStores.

  • The System Prompt, a configuration item of the DataAgent, does not require the DataAgent to access data outside the model scope.

Step 6: Run your first query

Open the session page of the DataAgent that you created, and enter a question that has a clear time range and a clear analysis target. For example:

Count the error requests of each API in the last 1 hour, and list the 5 APIs with the highest error counts.

If the DataAgent asks which data source or metric definition to use, select the option that matches your current business. After the answer is returned, you can continue to ask a follow-up question in the same session:

Show only the API with the highest error count, and display the trend at a 5-minute granularity.

If the DataAgent cannot find data, or the answer uses an unexpected metric definition, see FAQ.

Result

After you complete the preceding steps, your account contains the following objects:

  • A Source Model that corresponds to the target Project.

  • At least one Context Model that is connected to the target LogStores.

  • At least one DataAgent that is bound to that Context Model.

  • One session in which you ran your first query and can continue to ask follow-up questions.

Next steps

  • Maintain and extend the three objects on the Source Model, Context Model, and Agents pages.

  • Add terms and query examples to the Context Model for business expressions that are easy to confuse.

FAQ

What do I do if the creation process does not complete?

Check the modeling status on the Source Model page. If a task fails or partially succeeds, view the failed objects first, and then regenerate the affected LogStores.

What do I do if the DataAgent cannot find data?

Confirm the following items in order:

  1. The Context Model is connected to the target LogStores.

  2. The Source Model content is adopted and synchronized.

  3. The DataAgent is bound to the correct model.

  4. The RAM role has read permissions on the data.

What do I do if the answer uses the wrong metric definition?

First check whether the Context Model contains metrics with the same name or ambiguous terms. Add clearer names, descriptions, and query examples, and then test again. Do not repeatedly explain long-term business definitions only in the System Prompt. Store the reusable definitions in the Context Model.