You can use the log analysis feature to accurately identify business exceptions on your application based on business logs. This topic describes how to enable and use the log analysis feature.

Prerequisites

  • The ARMS agent is v2.7.1.3 or later. Log on to the ARMS console. In the left-side navigation pane, choose Application Monitoring > Agent List. Click the Java Release Notes tab to obtain the agent installation package of v2.7.1.3.
  • The log analysis feature only can analyze the logs of applications in Container Service for Kubernetes (ACK) clusters. In addition, applications in ACK clusters must be connected to the application monitoring feature in annotation mode. For more information about how to use annotations to connect an application to the application monitoring feature, see Install the ARMS agent for Java applications deployed in ACK.

How log collection works

Log collection
  1. After you enable the log collection feature, the collected business logs are saved to your computer.
  2. After the log collection agent is installed, the log collection agent reads local business logs and sends them to the ARMS console.
    Note You can install the log collection agent only once for an ACK cluster.
  3. On the Log Analysis page of the ARMS console, you can query, filter, and analyze business logs by keyword. For example, you can filter exception log by keywords such as order ID, trace ID, and application name.

Step 1: Enable the log collection feature

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, Select Application monitoring > Applications .
  3. In the top navigation bar of the MNS console, select the region where your cluster is deployed.
  4. Log on to the Applications Page, click the application name.
  5. In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
  6. In the Log Analysis Settings section of the Custom Configuration tab, turn on the Automatic Log Collection switch, select the log severity, and set the maximum size of a single log.
  7. On the Custom Configuration tab, click Save in the lower-left corner.

(Optional) Step 2: Install the log collection agent

You can install the log collection agent only once for an ACK cluster. Perform the following steps to check whether the log collection agent is installed in the ACK cluster where the current application resides.

  1. In the left-side navigation pane, choose Application Diagnosis > Log Analysis.
    • If logs are displayed on the Log Analysis page, the log collection agent is installed in the current ACK cluster. You do not need to install the log collection agent again.
    • If the following page appears, the log collection agent is not installed in the current ACK cluster. Continue the following steps to install the log collection agent.
  2. Click Install Log Collection Agent.
    After the log collection agent is installed, you can view business logs of the current application.

Query logs

Basic query

Log Analysis page

The base query supports the following filter operations:

  • In the upper-right corner of the Basic Query page (①), set the time range for logs.
  • Click the arms_app drop-down list (②) to select other applications that have the log collection feature enabled.
  • Enter a keyword in the search box (③). Press Enter or click search to search for logs that contain the keyword. For example, if you enter WARN, you can view all Warn-level logs.
    Note Keywords are case-sensitive.

Advanced query

Click Advanced Query in the upper-right corner of the Log Analysis page. On the Advanced Query page, you can query logs by LogQL statements.

Advanced query

The advanced query supports the following filter operations:

  • In the upper-right corner of the Advanced Query page (①), set the time range for logs.
  • Enter a LogQL statement in the field (②) and click Run Query in the upper-right corner to filter business logs.
    LogQL statements allow you to filter logs by log labels and keywords. LogQL statements must contain log labels.
    • Log labels are in the following format: {Label key-value pair}. You can also click the Log labels drop-down list and select a key-value pair.

      The following operators are supported for label key-value pairs:

      • =: equal to
      • !=: not equal to
      • =~: regular expression match
      • !~: regular expression mismatch
      For example, you can use the {arms_app="productservice"} key-value pair to query the business logs of the application named productservice.
    • Keywords: You can add a keyword after the log label to further filter business logs.
      The following operators are supported for keywords:
      • |=: contain
      • !=: not contain
      • |~: regular expression match
      • !~: regular expression mismatch
      Note Keywords are case-sensitive.
      For example, you can use {arms_app="productservice"}|="WARN" to query business logs at the Warn level of the application named productservice.

View logs

In the business log list section, you can perform the following operations:

View log details

Click the row for a log entry to view the labels and keywords contained in the log entry.

Log Labels section

In the Log Labels section, you can perform the following operations:

  • Click the Plus icon icon before a label to filter the logs that contain the current label key-value pair.
  • Click the Minus icon icon before a label to filter the logs that do not contain the current label key-value pair.
  • Click the console link next to Trace ID to view the trace information and business information.

View log context

To view the context of a log entry, move the pointer over the row for the log entry and click Show context.

By default, five log entries are displayed before and after each selected log entry. To view more, click Load 10 more in the upper and lower sections.

View log context