Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to integrate Arthas into Spring Boot Monitoring platform

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to integrate Arthas into the Spring Boot monitoring platform. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Preface

Arthas is Alibaba open source Java diagnostic tool, with real-time view of the system's health; view function call parameters, return values and exceptions; online hot update code; seconds to solve class conflict problems; locate the class loading path; generate hot spots; diagnose online applications through web pages. Today, it is widely used in major factories, but also extends a lot of products.

SpringBoot Admin

For convenience, SpringBoot Admin is abbreviated as SBA (version 1.5.x).

Version 1.5 of SBA if it is troublesome to develop plug-ins, you need to download the source code package of SBA, and then Copy it in the form of Spring-boot-admin-server-ui-hystrix. Because JS uses Angular, I have tried for a long time. Although I have mastered how to develop plug-ins, why not Angular?

Version: 2.x 2.x version of the SBA plug-in development, the official website describes how to develop, JS uses Vue, much more convenient, because our project is still using 1.5, so do not use this version, please try by yourself.

You can't use SBA plug-ins for integration, so what else can you do? ?

SBA integration

My solution is to Copy the files related to Arthas directly into the Admin service, all from the Arthas-all project Tunnel-server.

Admin directory structure

1. Arthas directory

Under this package are all the Java files of Arthas.

All the files under the Endpoint package can be commented out, which is not of much use.

ArthasController is a new file I created myself to get all the clients registered with Arthas, which is useful later.

Just Copy the other files directly.

@ RequestMapping ("/ api/arthas") @ RestControllerpublic class ArthasController {@ Autowired private TunnelServer tunnelServer; @ RequestMapping (value = "/ clients", method = RequestMethod.GET) public Set getClients () {Map agentInfoMap = tunnelServer.getAgentInfoMap (); return agentInfoMap.keySet ();}}

Spring-boot-admin-server-ui

The file is built under Resources.META-INF, and Admin will load the files in that directory at startup.

2. Resources directory

Index.html overrides the original home page of SBA, adding an Arthas navigation to it

Spring Boot Admin Arthas Reference Guide-Sources-Code licensed under Apache License 2.0 sbaModules = [] Angular.element (document) .ready (function () {angular.bootstrap (document, sbaModules.slice (0), {strictDi: true});})

Arthas.html

Create a new page to display the Arthas console page.

There are two hidden text fields in this file, which are used to connect to the Arthas server and automatically assign the Url of Admin to Ip when the page loads.

Spring Boot Admin window.addEventListener ('resize', function () {var terminalSize = getTerminalSize (); ws.send (JSON.stringify ({action:' resize', cols: terminalSize.cols, rows: terminalSize.rows})); xterm.resize (terminalSize.cols, terminalSize.rows);}) Arthas Applications Turbine Journal About Select Application: Disconnect

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report