In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to add a Spring Boot Admin monitor. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
0. Preface
Here is another important project in the Spring Cloud microservice-Spring boot admin.
1. Spring Boot Admin introduction
Spring Boot Admin is used to monitor Spring Boot-based applications and provides a concise visual Web UI on the basis of Spring Boot Actuator. Spring Boot Admin provides the following features:
Displays the health status of the application
Display the details of the application: JVM and memory information, micrometer information, data source information, cache information, etc.
Show compiled version
View and download logs
View jvm parameters and environment variable values
View Spring Boot project configuration
Show thread dump
Show http-traces
……
Wait for a series of contents.
two。 Create a Spring Boot Admin project
So, let's create a Spring Boot Admin project.
2.1 create a Spring Boot Admin server
Under the manager directory, create a monitor directory, and create a pom.xml file under the monitor directory, adding the following:
4.0.0
Monitor
${revision}
Jar
Manager
Club.attachie
${revision}
Register our new project module at manager/pom.xml:
Gateway
Monitor
Create the following directory in monitor:
.
├── pom.xml
└── src
└── main
├── java
└── resources
Add Spring Boot Admin dependencies in the pom.xml of the root directory:
Add the spring-boot-admin version number variable first:
2.2.3
And under dependencyManagement > dependencies, add:
De.codecentric
Spring-boot-admin-starter-server
${spring-boot-admin.version}
Add to the monitor/pom.xml file:
Org.springframework.boot
Spring-boot-starter-web
De.codecentric
Spring-boot-admin-starter-server
Running
Mvn clean install
Check and brush the mvn reference cache.
Create the MonitorApplication class:
Package club.attachie.nature.monitor
Import de.codecentric.boot.admin.server.config.EnableAdminServer
Import org.springframework.boot.SpringApplication
Import org.springframework.boot.autoconfigure.SpringBootApplication
@ SpringBootApplication
@ EnableAdminServer
Public class MonitorApplication {
Public static void main (String [] args) {
SpringApplication.run (MonitorApplication.class, args)
}
}
After startup, you can see the following interface:
3 interworking with gateway service
In the previous article, we added the Spring Cloud Gateway project, and so far the two projects are completely fragmented and unrelated. In this section, we establish a connection between the two. That is, introduce the gateway project into Spring Admin Boot snooping.
Add the following reference to the pom.xml file of manager/gateway:
Org.springframework.boot
Spring-boot-starter-actuator
Then modify the startup port of the gateway project and add:
Server:
Port: 8070
Add a nacos reference to monitor:
Com.alibaba.cloud
Spring-cloud-starter-alibaba-nacos-discovery
Org.springframework.boot
Spring-boot-starter-actuator
Modify the MonitorApplication to:
Package club.attachie.nature.monitor
Import de.codecentric.boot.admin.server.config.EnableAdminServer
Import org.springframework.boot.SpringApplication
Import org.springframework.boot.autoconfigure.SpringBootApplication
Import org.springframework.cloud.context.config.annotation.RefreshScope
@ SpringBootApplication
@ EnableAdminServer
@ RefreshScope
Public class MonitorApplication {
Public static void main (String [] args) {
SpringApplication.run (MonitorApplication.class, args)
}
}
Create the bootsrap.yml for the monitor project:
Spring:
Application:
Name: monitor
Cloud:
Nacos:
Discovery:
Server-addr: 127.0.0.1:8848
There was an error about the configuration here in the previous article, which should be discovery > server-addr, not config > server-addr. There is a difference between the two. Discovery means to set nacos as the service discovery center and config to indicate that nacos is the configuration center.
Start the gateway project and the monitor project to view the results, and access port 8080:
You can see that two applications can be found. If you do not set up the monitor project to use nacos as a service discovery center, you will not be able to get specific online applications. Click gateway to go in and you can see:
We set up a Spring Boot Admin project as a monitoring system.
The above is the editor for you to share how to add a Spring Boot Admin monitoring, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.