All Products
Search
Document Center

Application Real-Time Monitoring Service:Log analysis (old)

Last Updated:Mar 12, 2024

If an exception occurs in your application, you can use logs to accurately identify the exception. This topic describes how to enable and use the log analysis feature.

Prerequisites

  • The version of the Application Real-time Monitoring Service (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 Management. Click the Agent Release Notes tab to obtain the installation package of V2.7.1.3.

  • The log analysis feature can be used to analyze only the logs of applications that are deployed in Container Service for Kubernetes (ACK) clusters. In addition, the applications in ACK clusters must be connected to Application Monitoring by using annotations. For more information about how to use annotations to connect an application to Application Monitoring, see Automatically install an ARMS agent in ACK.

Version description

The log analysis feature of the current version can no longer be enabled. If you have already enabled the current version, you can still use it.

You can enable the new log analysis feature based on your business requirements.

Important

After you enable the new log analysis feature, you can no longer use the old version.

The new log analysis feature supports logs that are collected by Simple Log Service or ARMS.

  • Analyze logs collected by ARMS: You can use the ARMS agent to collect the output of the log framework and push the collected logs to the log analysis center of ARMS. After you enable the log analysis feature, you can query and analyze the logs of your application in the ARMS console without the need to perform other operations. For more information, see Analyze logs collected by Log Service.

    Note

    If you analyze logs collected by ARMS, you must upgrade the ARMS agent to V2.7.1.4 or later.

  • Analyze logs collected by Simple Log Service:

    You must make sure that the logs of your application are collected to Simple Log Service. Then, you must specify the project and Logstore that store the logs on the Application Settings page of the ARMS console. To help you analyze logs, the console pages of Simple Log Service are embedded in ARMS. For more information, see Analyze logs collected by Log Service.

How log collection works

image
  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 and analyze business logs by keyword. For example, you can query exception logs by order ID, trace ID, or application name.

Query logs

Basic query

日志分析页面

The base query supports the following query 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 using LogQL statements.

高级查询

The advanced query supports the following query 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 query business logs.

    LogQL statements allow you to query 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 query 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.

日志展开信息

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

  • Click the 添加包含 icon before a label to query the logs that contain the current label key-value pair.

  • Click the 筛选不包含 icon before a label to query the logs that do not contain the current label key-value pair.

  • Click the console link next to the 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.

查看日志上下文