All Products
Search
Document Center

Comprehensive troubleshooting

Last Updated: Mar 25, 2019

Comprehensive troubleshooting is used to quickly locate the faulty link through the business primary key. This function must be used with the custom monitoring function. This topic describes how to use comprehensive troubleshooting.

Prerequisites

  1. An application monitoring job has been created in the ARMS console, and ARMS Java Agent for application monitoring has been mounted and started in the Java program. For details, see the procedures for ARMS Java Agent installation in Create an application monitoring job.

  2. arms-sdk-1.7.0.jar has been introduced to the program.

    1. <dependency>
    2. <groupId>com.alibaba.arms.apm</groupId>
    3. <artifactId>arms-sdk</artifactId>
    4. <version>1.7.0</version>
    5. </dependency>

    Note: If you cannot obtain the pom.xml file, download arms-sdk-1.7.0-SNAPSHOT.jar.

Retrieve TraceId and RpcId

After the preceding prerequisites have been met, execute the following codes to retrieve TraceId and RpcId:

  1. Span span = Tracer.builder().getSpan();
  2. String traceId = span.getTraceId();
  3. String rpcId = span.getRpcId();

Print logs

After retrieving TraceId and RpcId, print and output business logs as needed. The following shows sample business logs containing TraceId and RpcId. The logs are output to /home/admin/logs/example/example.log. You can also output the logs to Log Service (Log, former SLS), MQ, or other channels.

  1. 2018-07-12 11:37:40|1e057c4015313666599651005d1201|0|username=xiao,age=22,action=login
  2. 2018-07-12 11:37:40|1e057c4015313666599651005d1201|0|username=xiao,age=22,action=search
  3. 2018-07-12 11:37:40|1e057c4015313666599651005d1201|0|username=xiao,age=22,action=cart

Each of the preceding business logs represents a trajectory of the user.

Configure the comprehensive troubleshooting event set

Create a custom monitoring job by following the instructions provided in the topic “Custom monitoring”, use the preceding sample business logs as data sources, and split logs in custom mode as shown in the following figure.

Then Create a comprehensive troubleshooting event set and configure the event set as shown in the following figure.

  • Business Primary Key: indicates the field used to search for business events. In this example, the business primary keys are action and username.

  • Select a time field: Select business time rather than system time.

  • TraceID: Set this as required.

  • RpcID: Set this as required.

After configuring the event set, start the custom monitoring job.

Comprehensive troubleshooting case

In this case, the business log represents the trajectory of the user, and the corresponding application is a shopping website. Assume that user kevin.yang complained that he failed to place an order after 14:20 on July 12, 2018. You can identify the cause using either of the following methods:

  • Method 1: Query traces.

    1. In the left-side navigation pane, click Multi-dimensional Query. On the Instances page, click the Trace Query tab.

    2. Enter the date range in Parameter Value for Date, and select Business Primary Keyfrom the Parameter Name drop-down list below. In the right-side Parameter Value text box, enter the business primary key value, for example, username:kevin.yang. Then click Search. All traces within the specified time range are displayed in the search results.

    3. Click the TraceId of an abnormal trace in the search results, and then click the Business Trajectory tab. All business events corresponding to the TraceId are displayed. Identify the causes based on the business events.

  • Method 2: Query comprehensive troubleshooting events.

  1. In the left-side navigation pane, click Multi-dimensional Query. On the page that is displayed, click the Event Query tab.

  2. Enter the date range in Parameter Value for Date, and select the event set previously configured from the Comprehensive Troubleshooting Event Set drop-down list . Then click Search. All traces within the specified time range are displayed in the search results.

  3. Click Trace Query in the search results, and then click the Business Trajectory tab. All business events corresponding to the TraceId are displayed. Identify the causes according to the business events.