Integrating Arthas with Spring Boot Admin: Live Debugging, JMX Management, and Hot Code Updates
This guide explains how to embed the Arthas Java diagnostic console into Spring Boot Admin, covering project setup, Maven resource configuration, external view linking, custom Spring MVC controllers, Arthas Spring Boot plugin adjustments, and JMX exposure via Spring Actuator, along with practical usage notes and known limitations.
The article describes a practical integration of the Arthas Java diagnostic tool with Spring Boot Admin (SBA) to provide a unified performance analysis and hot‑code‑update capability across test, performance‑test, and production environments.
Project Goals
Use Arthas as a unified tool for performance issue analysis in various environments.
Leverage Arthas’s jad, mc, and redefine functions to achieve hot‑update of code on selected production nodes.
Technical Selection
The company’s micro‑service ecosystem uses Spring Cloud and Eureka. SBA (Spring Boot Admin) was chosen because it already provides service discovery, log‑level configuration, and a rich set of Actuator‑based management plugins. Arthas version 3.4.5, running in Tunnel Server mode, was integrated with SBA 2.0.
Web console is embedded behind SBA’s unified authentication, so users must log into SBA before accessing Arthas.
Jolokia‑core is used to expose the target JVM’s JMX interface through SBA, reducing the need for separate front‑end development.
Overall Architecture
The integration relies on the JVM‑built‑in Arthas Spring Boot plugin, a custom UI package, and JMX exposure via Spring Actuator.
Implementation Steps
1. Project Structure
The base project is the spring-boot-admin-sample-custom-ui example from the SBA open‑source repository. Static files of the Arthas web console are placed under a Maven resource directory and copied into
${project.build.directory}/classes/META-INF/spring-boot-admin-server-ui/extensions/arthasduring the build.
<resource>
<directory>static</directory>
<targetPath>${project.build.directory}/classes/META-INF/spring-boot-admin-server-ui/extensions/arthas</targetPath>
<filtering>false</filtering>
</resource>After packaging, the JAR contains these resources, and SBA’s embedded Tomcat serves them at the configured external URL.
2. External View Configuration
In SBA 2.0, external pages can be linked via the external-views section of application.yml:
# tag::customization-external-views[]
spring:
boot:
admin:
ui:
external-views:
- label: "Arthas Console"
url: http://21.129.49.153:8080/
order: 1900
# end::customization-external-views[]The URL points to the Arthas console served from the same JVM after SBA startup.
3. Spring MVC Controller Adjustments
Refresh the Tunnel Server instance list and display selectable Agent IDs in the UI.
Provide a custom IP‑address refresh to handle mismatched production and operation network segments.
4. Arthas Spring Boot Plugin Modifications
The original plugin auto‑loads via @ConditionalOnMissingBean. The modification disables automatic startup in application.yml and allows remote activation of the agent through JMX operations.
5. JMX Exposure via Spring Actuator
SBA client pulls in jolokia-core.jar, enabling HTTP‑based JMX operations. Management endpoints are exposed as follows:
# Enable all management endpoints (for demonstration only)
management:
endpoints:
web:
exposure:
include: "*"
exclude: env
endpoint:
health:
show-details: ALWAYS
health:
status:
http-mapping:
FATAL: 503A custom MBean ArthasMbeanImpl provides operations to get/set the Tunnel Server URL, retrieve Agent ID, start/stop the Arthas agent, and query configuration maps. Example of a managed operation:
@ManagedOperation(description = "启动Arthas agent")
public Boolean startArthasAgent() {
DefaultListableBeanFactory bf = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
String bean = "arthasAgent";
if (bf.containsBean(bean)) {
((ArthasAgent) bf.getBean(bean)).init();
return true;
}
bf.registerSingleton(bean, arthasAgentInit());
return true;
}Actual Usage
After deployment, the integrated console has been used repeatedly for production‑environment debugging and hot‑code fixes, especially for performance‑related flow‑control components and gray‑release configuration validation.
Initial hot‑updates were performed with jad + mc. Due to inconsistencies in decompiled code on some JVMs, the team later switched to deploying source‑code zip packages that match the running JAR version, achieving more reliable hot‑patches.
Known Limitations
The official ArthasAgent class creates temporary class loaders, making it impossible to obtain a handle for programmatic shutdown; the current workaround is to stop the agent via a JMX stop command after use.
Byte‑code manipulation tools (e.g., SkyWalk8.x) conflict with JaCoCo coverage agents in some test environments, requiring the JaCoCo agent to be disabled before using Arthas.
Overall, the integration provides a low‑overhead, secure way to embed Arthas into SBA, enabling unified monitoring, JMX management, and hot‑code updates directly from the SBA UI.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
