Arthas helps developers diagnose issues in the production environment of Java applications. It adopts the bytecode enhancement technology and allows developers to troubleshoot applications without restarting running Java virtual machine (JVM) processes.

Prerequisites

Note Arthas is supported only in Application Monitoring Pro Edition.
  • New users of Application Real-Time Monitoring Service (ARMS) or users who have not used the old version of Arthas for 15 days can use only the new version of Arthas.

    If you have any questions when you use Arthas, search for the DingTalk group number 35396829 to join the ARMS application diagnostics Q&A group.

  • The version of the ARMS agent is V2.7.1.3 or later.
  • The data of your application is imported to ARMS Application Monitoring. For more information, see Overview.
  • The application on which you want to perform diagnostics is developed in Java.
  • Port 3658 is not occupied by another process.

Background information

Arthas in ARMS provides the following real-time diagnostics capabilities:
  • JVM overview: allows you to view the real-time memory usage, system information, system variables, and environment variables of a JVM process.
  • Thread analysis: allows you to view the time consumption of threads and the real-time method stack of a specified thread in a JVM process.
  • Method execution analysis: captures an execution record of any non-JDK method that meets specified conditions, and records the parameters, exceptions, return values, and execution duration of each internal method.
  • Object viewer: allows you to view the real-time property values of an instance of any class.
  • Real-time dashboard: allows you to view the real-time information about common components. For example, you can view the configurations, usage, and the time consumption of SQL queries in a Druid connection pool.
  • Performance analysis: collects samples of performance metrics within a specific period, such as the CPU time consumption and memory allocation, and generates flame graphs of these metrics.
  • Arthas Shell: allows you to perform Arthas diagnostics by running commands.

Enable Arthas

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Application Monitoring > Applications.
  3. In the top navigation bar, select a region.
  4. On the Applications page, click the name of your application.
  5. In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
  6. In the Arthas monitoring section of the Custom Configuration tab, turn on the Arthas switch. You can also specify the IP addresses on which you want to perform Arthas diagnostics. If you do not specify the IP addresses, Arthas diagnostics is performed on all IP addresses.
    Custom Configuration - Arthas monitoring
  7. On the Custom Configuration tab, click Save in the lower-left corner.

View diagnostics results provided by Arthas

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Application Monitoring > Applications.
  3. In the top navigation bar, select a region.
  4. On the Applications page, click the name of your application.
  5. In the left-side navigation pane, choose Application Diagnosis > Arthas Diagnosis.
  6. On the Arthas Diagnosis page, select the application instance on which you want to perform diagnostics from the drop-down list on the top.
    • If the instance agent runs a version earlier than 2.7.1.3, you are instructed to update the agent.
    • If the instance agent runs version 2.7.1.3 or later, the page displays the instance information provided by Arthas.

JVM overview

On the JVM overview tab, you can view the JVM information about the application, including the statistics on JVM memory and the information about the operating system and variables.

By default, when you enter the Arthas Diagnosis page, the JVM overview tab is displayed. The JVM overview tab contains the following sections:

  • JVM memory: displays information about JVM memory, such as the usage of heap memory and non-heap memory, and the information about garbage collection (GC).
  • Operating system information: displays information about the operating system, such as the average system load, the name and version of the operating system, and the Java version.
  • Variable information: displays information about system variables and environment variables.

Thread duration analysis

On the Thread time-consuming analysis tab, you can view all the threads of the application and the stack information about each thread. The information in this tab helps you easily identify time-consuming threads.

  1. On the Arthas Diagnosis page, click the Thread time-consuming analysis tab.
    You can view the real-time time consumption of threads in a JVM process on the Thread time-consuming analysis tab. Similar threads are displayed in one row as a category. New version of Arthas - Thread duration analysis
  2. Click the + icon on the left side of a thread category name to view the details of all threads under this category, including the thread ID, CPU usage, and status.
  3. To view the stack information about a thread, click View in the Actions column of the thread.
    堆栈详情

Method execution analysis

On the Method execution analysis tab, you can view the information such as time consumption, input parameters, and return values of a method execution, and even drill down to an internal method. You can use this information to locate the root causes of slow API calls and missing logs, as well as troubleshooting non-reproducible issues.

  1. On the Arthas Diagnosis page, click the Method execution analysis tab.
  2. On the Method execution analysis tab, enter a keyword of the class name in the search box, and then click the Search icon.
  3. Find the class on which you want to perform diagnostics from the displayed classes. Select a method of the class in the drop-down list on the right side and then click OK.
    ARMS captures a random execution record of the method. The execution information is displayed. New version of Arthas - Method execution analysis
    • The internal execution records of the method that you select are displayed in the Execution Stack section on the left side.
      • To drill down to an internal method, find the internal method and click Drill in in the Actions column.
      • To view the source code of the method, click View Source Code next to Execution Stack.

        The execution duration of each internal method is displayed in the annotations of the source code.

    • The Method Execution Result section on the right side shows the parameter values, return values, exceptions, member variables, and traceId of the method execution.
    • In the Set Execution Conditions section on the right side, perform the following steps to set conditions for capturing a method execution record.
      1. Select a reload method from the drop-down list.
      2. In the Select Initial Filter Key drop-down list, select a key type that you want to specify first and click the Left arrow icon.
        Key types:
        • params[n]: the nth parameter of the method.
        • returnObj: the return value of the method.
        • Method execution duration: the duration of the method execution.
        • Exception thrown or not: specifies whether an exception is thrown during the method execution.
        Note If a nested key is selected, you need to continue specifying the field of the nested key until a base field is selected.
      3. Select a condition.
      4. Enter a value.
      5. Click Add.

        The conditions for selecting the method execution records are displayed in the Current Filtering Conditions section.

        Set conditions for selecting the execution records.
      6. In the upper-right corner of the Execution Stack section, click the Refresh icon. The system then captures the method execution records based on the specified conditions.

Object viewer

On the objectViewer tab, you can view information of some singleton objects to troubleshoot application exceptions, such as configuration errors, improper items in blacklists or whitelists, and abnormal status of member variables.

  1. On the Arthas Diagnosis page, click the objectViewer tab.
  2. On the objectViewer tab, enter a keyword of the class name in the search box and click the Search icon.
  3. Select the class on which you want to perform diagnostics from the displayed classes, select an instance of the class in the right-side pane, and then click OK.
    The real-time field values of the instance are displayed. Arthas - Object viewer
    • The value of a simple field is displayed in the Details column in the Real-time Field Values of Object section on the left side.
    • To view the value of a complex field, click View Details in the Details column of the Real-time Field Values of Object section on the left side. The detailed field value is displayed in the Field Details section on the right side.

      Only part of the complex field value can be deserialized and displayed in the Field Details section. To view more data, click the click hyperlink in the parentheses next to Details.

Real-time dashboard

On the Real-time board tab, you can view the real-time information about key components in use, such as the usage of the database connection pool and the usage of the HTTP connection pool. The information helps you locate resource issues.

  1. On the Arthas Diagnosis page, click the Real-time board tab.
  2. On the Real-time board tab, select a dashboard from the drop-down list, select an instance of the dashboard, and click Add to Dashboard.
    The real-time information about a component is displayed. The following figure shows the real-time information about a Druid connection pool, including the basic configurations, connection pool status, and execution duration. Arthas - Real-time dashboard

Performance analysis

On the Performance analysis tab, you can create flame graphs based on the collected samples of performance metrics within a specific period, such as the CPU time consumption and memory allocation. The flame graphs help you identify the performance bottlenecks of the application.

  1. On the Arthas Diagnosis page, click the Performance analysis tab.
  2. On the Performance analysis tab, click New flame graph in the upper-right corner.
  3. In the New flame graph dialog box, select a flame graph type, specify a sampling duration, enter a description, and then click OK.
    Parameter Description Example
    Flame graph type The sampled object. Valid values:
    • cpu time consuming
    • Memory allocation
    • Lock time consumption
    • itimer
    cpu time consuming
    Input sampling time (unit: second) The sampling duration. Valid values: 10 to 1800. 30
    The Performance analysis tab shows the information about tasks of generating flame graphs, such as the start time, sampling duration, remarks, flame graph type, and task status. Arthas - Performance analysis
  4. On the Performance analysis tab, find the task whose flame graph you want to view, and then click View the flame graph in the Task status column. Download the flame graph in the SVG format as prompted, and open the SVG file in your browser to view the flame graph.
    Flame graph

Arthas Shell

You can perform Arthas diagnostics by running commands.

Arthas Shell