Log analysis
The log analysis feature of Managed Service for OpenTelemetry relies on Simple Log Service (SLS). The log center page is integrated into the Managed Service for OpenTelemetry console. If a business exception occurs in your application, you can use log analysis in the Managed Service for OpenTelemetry console to accurately locate the exception.
Prerequisites
Connect an application to Managed Service for OpenTelemetry. For more information, see Preparations.
Activate Simple Log Service (SLS). Log on to the Simple Log Service console and follow the on-screen instructions to activate the service.
A project has been created. For more information, see Manage a Project.
Create a Logstore. For more information, see Create a basic LogStore.
Report the business logs of the application to Simple Log Service. For more information, see Overview of data collection.
Step 1: Associate business logs
-
Log on to the Managed Service for OpenTelemetry console. In the left-side navigation pane, click Applications.
-
On the Applications page, select a region in the top navigation bar and click the name of the application.
In the navigation pane on the left, click Application Settings.
On the Custom Configuration tab, in the Business Log Association Settings section, bind the Project and Logstore, and set the Associated Index.
NoteThe Associated Index is used to retrieve the TraceID and view the logs that correspond to a trace.
If the index configured in Simple Log Service is a full-text index, set Associated Index to Full-text Index.
If the index configured in Simple Log Service is a field index for
traceId, set Associated Index to the correspondingtraceIdindex. To print the TraceID in logs, see the documentation for the TraceID printing feature of your tracing framework.
For more information about how to configure an index, see Create an index.
In the lower-left corner of the Custom Configuration tab, click Save.
Step 2: Query and analyze logs
In the navigation pane on the left, click Log Analysis.
On the page that appears, complete the following steps:
In the search box, enter a query and analysis statement.
A query and analysis statement consists of a query statement and an analytic statement. The format is Query Statement|Analytic Statement. For more information about the syntax, see Query syntax and functions and SQL analytic syntax.
Set the time range for the query and analysis.
You can set a relative time, a time frame, or a custom time.
NoteQuery results may have a margin of error of up to 1 minute.
Click Query/Analysis to view the results.