When a business exception occurs, you can analyze business logs to pinpoint the root cause. The Log Analysis feature helps you analyze logs from Simple Log Service (SLS) or logs collected directly. This topic describes how to enable Log Analysis and analyze logs from SLS.
Prerequisites
-
You have connected your application to Application Monitoring. For more information, see Application Monitoring overview.
-
You have activated Simple Log Service (SLS). When you log on to the Simple Log Service console, follow the on-screen instructions to activate the service if prompted.
-
You have created an SLS project. For more information, see Manage project.
-
You have created a logstore. For more information, see Create a basic logstore.
-
You have configured data collection for SLS. For more information, see Data collection overview.
Step 1: Associate business logs
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Application List page, select the region in the top navigation bar and then click the name of the application.
NoteIcons in the Language column have the following meanings:
: a Java application connected to Application Monitoring.
: a Golang application connected to Application Monitoring.
: a Python application connected to Application Monitoring.-: an application connected to Managed Service for OpenTelemetry.
-
In the left-side navigation pane, click Application Settings, and then click the Custom Configurations tab.
-
On the Custom Configurations tab, in the Log Collect Configuration section, turn on the Link Business Logs with TraceId switch, select the region where your Simple Log Service project is located, and then bind the project and logstore.
-
In the lower-left corner of the Custom Configurations tab, click Save.
Step 2: Query and analyze logs
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Application List page, select the region in the top navigation bar and then click the name of the application.
NoteIcons in the Language column have the following meanings:
: a Java application connected to Application Monitoring.
: a Golang application connected to Application Monitoring.
: a Python application connected to Application Monitoring.-: an application connected to Managed Service for OpenTelemetry.
-
In the left-side navigation pane, choose .
-
On this page, perform the following steps:
-
In the search box, enter a query and analysis statement.
A query and analysis statement consists of a search query and an analysis statement, separated by a vertical bar (|): Search Query | Analysis Statement. For more information about the syntax, see Query syntax and functions and SQL analysis syntax.
-
Set a time range for the query and analysis.
You can specify a relative time range, a whole-hour time range, or a custom time range.
NoteQuery results may have a latency of up to 1 minute.
-
Click Search & Analyze to view the results.
The query and analysis results show log entries corresponding to the trace ID. For example, the fourth entry, an INFO-level log recorded at 09-09 14:10:07, indicates that the registration of
RegisterPromClusterServletfailed. It reports ajava.lang.RuntimeExceptionwith the error message Failed to create grafana folder, and its stack trace points to calls involvingGrafanaConfigService. -
Related documents
You can associate trace IDs from your traces with business logs. When an issue occurs, this correlation lets you use a trace ID to quickly find the relevant logs, which speeds up troubleshooting and root cause analysis. For more information, see Associate trace IDs with business logs for Java applications.