Create and manage Context Models
A Context Model (semantic model) brings together one or more Source Models by business scenario and centrally manages data tables, metrics, terms, and query examples. Connect data sources, review the synchronization results, and add the business semantics that your scenario requires.
Prerequisites
You have generated at least one Source Model.
You have adopted the content that you need from the Source Model.
You have the permissions to create and manage Context Models.
You have determined the business scenario, the data scope, and the definitions of the main metrics for the model.
Create a Context Model
Log on to the Simple Log Service (SLS) console and go to SLS DataAgent.
In the top navigation bar, click Context Model.
Click Create Context Model. If the model that you open is empty, you can also click Connect Data.
Configure the model information and the associated data sources.
Parameter Required Description name Yes The unique identifier of the model. The identifier can be up to 64 characters in length and can contain only letters, digits, underscores (_), and hyphens (-). It cannot be modified after the model is created. displayName No The name displayed in the console. Chinese characters are supported. We recommend that you use a name that reflects the business scenario. description No A description of the data and the questions that the model covers. Source Model Yes Select one or more generated Source Models. LogStore scope Yes Select all or some of the LogStores from the Source Model. After you confirm the configuration, wait for the first synchronization to complete.
View the model content
The Context Model details page contains the following tabs:
| Tab | Content |
| Schema | The data tables and field descriptions that are synchronized or manually maintained |
| Metrics | The business metrics, calculation expressions, and descriptions |
| Terms | The business terms, aliases, explanations, and associated data |
| Examples | The query examples for common questions |
After the first synchronization, check whether the Schema tab covers the LogStores that you plan to use, and then check the core metrics and terms. If you connect many data sources, limit the scope to one clear scenario. This keeps fields and metrics with the same name from different business lines out of the same model.
Connect more data sources
On the Context Model details page, click Connect.
Select the Source Model and the LogStores that you want to connect.
Confirm the connection and wait for the synchronization.
You can associate a Context Model with multiple Source Models. Elements from different sources are distinguished by their data source coordinates. When you create metrics and query examples, bind them to the correct data table.
Manage semantic elements
Synchronized elements
The data tables, metrics, and terms that are synchronized from a Source Model are managed by that Source Model. In the current public preview, you cannot modify synchronized elements directly in the Context Model.
To adjust synchronized elements:
Open the Source Model that the elements are synchronized from.
Modify and adopt the target elements.
Wait for the automatic synchronization or trigger a manual synchronization in the Context Model.
After you delete a synchronized element, it may be restored in the next synchronization cycle. To remove an element permanently, delete it from the data source association or from the Source Model.
Manually added elements
In the Context Model, you can add metrics, terms, and query examples that are specific to a business scenario. Manually added elements are not overwritten or cleared by Source Model synchronization.
When you add a metric, specify the aggregation method, the filter conditions, the time window, and the unit. If you write only "transaction amount" without stating whether refunds, canceled orders, and currencies are included, the definition remains ambiguous to the DataAgent.
When you add a term, include the following information:
The standard name and the common aliases
A clear business definition
The associated data table or metric
The counterexamples that are easy to confuse
Add query examples
A query example contains the following information:
A question or a use case description
A validated SLS SQL query statement
The binding to the corresponding data table
An optional default time range
Select queries that are frequent and stable and that reflect the business definitions. Do not store one-time troubleshooting statements, or queries that contain temporary IDs, as general examples.
Synchronization rules
In the current public preview, synchronization follows these rules:
Elements that are added, edited, or adopted in a Source Model are automatically synchronized to the Context Model, with a maximum delay of 60 seconds.
A Context Model can aggregate multiple Source Models.
Manually added elements are not affected by the automatic synchronization.
After you remove a data source, the related synchronized elements are cleaned up in subsequent synchronization cycles.
The synchronization scope and the cleanup behavior may be adjusted during the public preview. After the feature is officially released, the description in the console prevails.
Result
After the model is created, the Context Model details page shows the connected data sources and displays the available content on the Schema, Metrics, Terms, and Examples tabs. You can bind the Context Model when you create or edit a DataAgent.
FAQ
What do I do if the Schema tab is still empty after I connect the data?
Confirm that the Source Model generation is complete and that the target content is adopted, and then wait for one synchronization cycle. If the Source Model itself has no fields, go back to the Source Model and troubleshoot the indexes and the modeling task.
Should metrics with the same name be placed in one model?
Merge them only when their business meanings and calculation definitions are consistent. Rename the metrics that share a name but have different meanings, or split them into different Context Models. This prevents the DataAgent from frequently asking for clarification or selecting the wrong definition.
Can I define metrics only through the System Prompt?
Defining metrics only through the System Prompt is not recommended. In the Context Model, store the fields, metrics, and terms that are reused over the long term. The System Prompt defines only the responsibilities, the behavior boundaries, and the output preferences of the DataAgent.