Arthas is a powerful tool for troubleshooting production issues in Java applications. It uses bytecode enhancement technology to inspect an application's runtime state without restarting the JVM process.
Application Real-Time Monitoring Service (ARMS) fully integrates all Arthas capabilities and provides the following advantages over a self-managed installation:
-
No JDK dependency. You can enable or disable Arthas diagnostics on demand for multiple applications with a single click, without needing to download or install Arthas.
-
A web-based UI for common features eliminates the need to memorize commands, look up commands, or write expressions.
-
Integration with the ARMS context. You can use the
tracecommand to view the ARMS trace ID.
Prerequisites
-
Only Application Monitoring Pro Edition supports the Arthas diagnostics feature.
-
We recommend that you enable Arthas diagnostics only for troubleshooting. Keep it disabled during normal operations.
-
The ARMS agent must be v2.7.1.3 or later.
-
Application Monitoring is enabled for your application. For more information, see Application Monitoring overview.
-
The application is written in Java.
Background
The Arthas diagnostics feature provided by ARMS is primarily used to complement the real-time diagnostic capabilities of ARMS. The Arthas diagnostics feature of ARMS includes the following types:
-
JVM overview: View real-time memory usage, system information, system variables, and environment variables for the current JVM process.
-
Thread time-consuming analysis: View thread execution times and the real-time method stack for any thread in the current JVM process.
-
Method execution analysis: Capture an execution record for any non-JDK method that meets specified conditions. This record includes parameters, exceptions, returned values, and the execution time of internal methods.
-
Object viewer: View the real-time property values of any class instance.
-
Real-time dashboard: View real-time data for common components. For example, you can view the configuration, usage, and SQL execution time of a Druid connection pool.
-
Arthas Shell: Use a command-line interface to perform Arthas diagnostics.
The Arthas performance analysis feature has been fully upgraded to the continuous profiling feature, which is more powerful, easier to use, and can be enabled at all times.
Continuous profiling helps you identify performance bottlenecks caused by CPU, memory, and I/O in Java applications. It provides detailed statistics broken down by method name, class name, and line number to help you optimize your application, reduce latency, increase throughput, and save costs. For more information, see Enable continuous profiling.
Enable Arthas diagnostics
-
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Application List page, select a region at the top of the page and click the name of the target application.
NoteThe icons in the Language column indicate the following:
: a Java application connected to Application Monitoring.
: a Go 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 Arthas Monitoring section, turn on the Arthas Switch. You can optionally specify the IP addresses of the application instances for which you want to enable Arthas diagnostics.
-
In the lower-left corner of the Custom Configurations tab, click Save.
View Arthas diagnostics
-
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Application List page, select a region at the top of the page and click the name of the target application.
NoteThe icons in the Language column indicate the following:
: a Java application connected to Application Monitoring.
: a Go 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 .
-
From the drop-down list at the top of the Arthas diagnostics page, select the application instance that you want to diagnose.
-
If the agent version of the instance is earlier than 2.7.1.3, you are prompted to upgrade the agent.
-
If the agent version of the instance is 2.7.1.3 or later, the diagnostic information of the instance is displayed.
-
JVM overview
The JVM overview feature allows you to view JVM-related information for your application, including JVM memory, operating system information, and variable information.
By default, the Arthas diagnostics page displays the JVM Overview tab. On the JVM Overview tab, you can view the following information:
-
JVM Memory: information about JVM memory, including heap memory usage, non-heap memory usage, and garbage collection (GC) status.
-
Operating System Information: information about the operating system, including the average system load, operating system name, operating system version, and Java version.
-
Variable information: information about variables, including system properties and environment variables.
Thread time-consuming analysis
This feature displays all threads in your application and their stack traces to help you quickly identify time-consuming threads.
-
On the Arthas diagnostics page, click the Threading Time Analysis tab.
The Threading Time Analysis tab displays real-time thread time consumption for the current JVM process and groups similar threads. A summary of thread counts by state is displayed at the top of the page.
-
Click the + icon next to a thread group to expand it and view details for individual threads, including thread ID, CPU usage, and state.
-
To view the stack trace for a specific thread, click View Live Stack in the Actions column for that thread.
The Thread Details dialog box appears, showing the thread name, running state, and the full stack trace.
Method execution analysis
This feature captures the execution time, input parameters, returned values, and other information for a single execution of a method. You can also drill down into its internal calls. This helps you quickly find the root cause of slow calls, especially for issues that cannot be reproduced offline or have missing logs.
-
On the Arthas diagnostics page, click the Method Execution Analysis tab.
-
On the Method Execution Analysis tab, enter a keyword for the class name in the search box and click the
Search icon. -
From the search results, select the class that you want to diagnose. Then, from the method selection box on the right, select a method of that class and click OK.
The page displays a randomly captured execution record for the selected method from ARMS or .
-
The Execution Stack section on the left shows the internal call records of the diagnosed method.
-
To drill down into an internal method, click Drill-down in the Actions column.
-
To view the source code, click View Source Code at the top of the Execution Stack section.
The execution time of each internal method is displayed as a comment in the source code.
-
-
The Method Execution Result section on the right shows the parameter values, returned value, exception, member variables, and the trace ID for this execution.
-
In the Set Execution Conditions section on the right, to capture a specific method execution record, set the conditions as follows:
-
Select an overloaded method of the current method.
-
From the Please select an initial filter key drop-down list, select a key type and click the
icon.Initial filter key types:
-
params[n]: The n-th parameter of the method.
-
returnObj: The returned value of the method.
-
Method execution time: The duration of method execution.
-
Throw exception: Specifies whether to throw an exception during method execution.
NoteIf the selected initial filter key is a nested type, you must continue to select its internal fields until you reach a basic type.
-
-
Select a filter condition.
-
Enter a filter value.
-
Click Add.
The added filter condition appears in the Current Filter Condition section.
-
In the upper-right corner of the Execution Stack section, click the
Refresh icon to capture a new method execution based on the set conditions.
-
-
Object viewer
Use the object viewer to inspect the current state of singleton objects. This is useful for troubleshooting issues related to application state, such as configurations, blacklists or whitelists, and member variables.
-
On the Arthas diagnostics page, click the Object Viewer tab.
-
On the Object Viewer tab, enter a keyword for the class name in the search box and click the Search icon.
-
From the search results, select the class you want to diagnose. Then, from the instance selection box on the right, select an instance of that class and click OK.
The page then displays the real-time values of the fields in that instance.
-
For simple-type fields, the value is displayed directly in the Details column of the Object field real-time value section.
-
For complex-type fields, click View Details in the Details column of the Object field real-time value section. The field details are displayed in the Field Details section on the right.
The Field Details section supports deserializing and displaying only one level of a complex field. To view more specific data, Click to view more detailed data for the field.
-
Real-time dashboard
Use the real-time dashboard to view the real-time status of key components in your system, such as database connection pools and HTTP connection pools. This helps troubleshoot resource-related issues.
-
On the Arthas diagnostics page, click the Live Kanban tab.
-
From the drop-down list on the Live Kanban tab, select a dashboard. Then, from the instance selection box on the right, select an instance for that dashboard and click Add to dashboard.
The page displays the real-time status for that dashboard. For example, for a Druid connection pool, the dashboard shows real-time status information, including basic configuration, connection pool status, and execution time distribution.
Arthas Shell
The Arthas Shell feature is currently available only in the China (Beijing), China (Shanghai), China (Hangzhou), China (Shenzhen), and China (Zhangjiakou) regions.
For details, see the official open-source documentation.
After you open the Arthas Shell page, select a Line at the top and click Connect. When the connection succeeds, a terminal window appears. You can enter Arthas commands at the command prompt to perform diagnostic operations.