How to Seamlessly Integrate Arthas into Spring Boot for Real‑Time Monitoring
This guide explains how to embed the Arthas online monitoring tool into a Spring Boot application using the Arthas Spring Boot Starter, configure telnet and HTTP ports, access the console via terminal or web, and extend debugging across multiple services with Arthas Tunnel while addressing security considerations.
Introduction
Arthas is an online monitoring and diagnosis tool that provides real‑time visibility into application load, memory, GC, thread status, method arguments, execution time, class loading, and more, without modifying the application code.
1. Spring Boot Integration
Include the official arthas-spring-boot-starter dependency in your pom.xml:
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-spring-boot-starter</artifactId>
<version>4.1.3</version>
</dependency>Configure Arthas properties in application.yml (or application.properties) to expose a telnet port and an HTTP port for the web console:
arthas:
telnet-port: 3658 # telnet access
http-port: 8563 # web console accessWhen the Spring Boot application starts, the starter automatically launches the Arthas agent and attaches it to the same JVM process.
2. Using Arthas
2.1 Telnet Console
Connect to the Arthas terminal via telnet: telnet localhost 3658 After connecting, you can run any Arthas command, such as dashboard, to inspect runtime metrics.
2.2 Web Console
Open a browser and navigate to http://localhost:8563 (or the configured HTTP port) to access the Arthas Web Console.
The integrated approach eliminates the need to download the Arthas binary or copy it into the container.
3. Arthas Tunnel Enhancement
In micro‑service environments, each Spring Boot instance may run its own Arthas client, making management cumbersome. Arthas Tunnel acts as a registration center for multiple agents.
3.1 Tunnel Server
Download the server from the official GitHub releases and start it with detail pages enabled:
java -jar -Darthas.enable-detail-pages=true arthas-tunnel-server-4.1.3-fatjar.jarOptional parameters: -Dserver.port=8081 – web port of the server -Darthas.server.port=8888 – registration port for agents
Access the management UI at http://127.0.0.1:8080/actuator/arthas. **Warning:** the UI has no built‑in security; do not expose it publicly without additional safeguards.
3.2 Tunnel Client
Configure each Spring Boot application to register with the Tunnel Server. Disable direct telnet/HTTP ports by setting them to -1 and provide the server address:
spring:
application:
name: springboot-11-arthas
arthas:
telnet-port: -1
http-port: -1
ip: 0.0.0.0
app-name: ${spring.application.name}
agent-id: ${spring.application.name}_Don001
tunnel-server: ws://127.0.0.1:7777/wsAfter the agents register, the Tunnel Server UI lists all connected instances, allowing you to select and interact with any of them.
3.3 Authentication
Define credentials in the configuration:
arthas:
username: admin
password: adminIn the Arthas terminal, authenticate first: auth -username admin admin Only after successful authentication can you execute other commands, such as session to view connection details.
4. Summary
The article demonstrates three key steps: (1) integrating the Arthas Spring Boot Starter for effortless in‑process monitoring, (2) using Telnet or the Web Console to interact with Arthas, and (3) leveraging Arthas Tunnel Server/Client to centrally manage and debug multiple Java services across servers, while emphasizing the security risks of exposing the management UI.
For the full source code, see the repository:
https://gitee.com/Don212/learning/tree/master/springboot-11-arthas.
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.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
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.
