In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of Java SpringBoot rapid integration of SpringBootAdmin console monitoring services, which has a certain reference value. Interested friends can refer to it. I hope you will learn a lot after reading this article.
SpringBootAdmin is a monitoring tool for UI beautification and encapsulation of SpringBoot's Actuator interface. It can browse the basic information, detailed Health information, memory information, JVM information, garbage collection information, various configuration information (such as data source, cache list and hit rate) of all monitored spring-boot projects in the list. It can be divided into server (spring-boot-admin-server) and client (spring-boot-admin-client). Http communication is used to realize data exchange between server and client. Server-side server needs to start a separate service, while client-side client only needs to be integrated into each micro-service.
1. Know SpringBootAdmin for the first time
First of all, we need to understand that the Spring Boot Admin application can provide the following functions for us to use:
Show your health.
Show details
JVM and memory metrics
Micrometer.io index
Data source index
Cache index
Show internal number
Follow and download log files
View JVM system and environment properties
View Spring Boot configuration properties
Publishable / env-&/ refresh-endpoint that supports Spring Cloud
Easy log-level management
Interact with JMX-beans
View thread dump
View http-traces
View audit events
View http endpoints
View scheduled tasks
View and delete active sessions (using spring-session)
View Flyway / Liquibase database migration
Download heapdump
Status change notification (via email, Slack,Hipchat, etc.)
Event log for state changes (non-persistent)
2. Set up the server-add the related dependency org.springframework.boot spring-boot-starter-security org.springframework.boot spring-boot-starter-web de.codecentric spring-boot-admin-starter-server 2.5.13 in the POM file, and modify the server application startup class
Add @ EnableAdminServer annotation to our startup class to enable the SpringBootAdminServer server
@ SpringBootApplication@EnableAdminServerpublic class BootAdminServerApplication {public static void main (String [] args) {SpringApplication.run (BootAdminServerApplication.class, args);}} 4. Configure security security information
Add the following configuration information to the application.properties file.
# Application port server.port=8085# configure an account and password spring.security.user.name=adminspring.security.user.password=admin
Initialize the SecuritySecureConfig configuration (if you do not initialize, you will not see the login page with SpringBootAdmin Logo)
@ Configuration public static class SecuritySecureConfig extends WebSecurityConfigurerAdapter {private final String adminContextPath; public SecuritySecureConfig (AdminServerProperties adminServerProperties) {this.adminContextPath = adminServerProperties.getContextPath ();} @ Override protected void configure (HttpSecurity http) throws Exception {SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler (); successHandler.setTargetUrlParameter ("redirectTo") Http.authorizeRequests () .antMatrices (adminContextPath + "/ assets/**"). PermitAll () .antMatrices (adminContextPath + "/ login"). PermitAll () .anyRequest (). Authenticated () .and () .formLogin (). LoginPage (adminContextPath + "/ login"). SuccessHandler (successHandler) .and () .logout () .logoutUrl (adminContextPath + "/ logout") .and () .httpBasic () .and () .csrf () .disable () }} 5. Start server server
After the service starts, enter the following address in the browser. We can see the corresponding login page, and the corresponding account password is configured in the properties file.
Http://127.0.0.1:8085/login
After logging in, you can see that the number of applications is empty, so we need to start building our Client client.
6. Set up client client
Add the following dependency information to the pom file. (note that the version should be consistent with the server side)
De.codecentric spring-boot-admin-starter-client 2.5.1
Modify the properties file
Spring.boot.admin.client.url= http://127.0.0.1:8085spring.boot.admin.client.username=adminspring.boot.admin.client.password=adminspring.application.name=spring-boot-applicationmanagement.endpoints.web.exposure.include=*
Spring.boot.admin.client.url points to the project interface path of the server above us. Management.endpoints.web.exposure.include says all ports are exposed and can be monitored. Spring.application.name means to change the display name of the project on the spring-boot-admin.
Spring.boot.admin.client.username and password are the usernames and passwords set. It should be noted here that if security is not integrated in admin-server, you can register it without configuring a username and password, which can be monitored on the server. But if admin-server integrates security, you need to ensure that the username and password configured in client are the same as those configured in server.
After starting the client client, it will automatically register with our server server, and we can find the corresponding service through the server server application wall to view the detailed metric information. (aside from the topic: during this period, the blogger encountered that after the client started, the server could not collect the corresponding metric information. The reason is that the corresponding probe interface is not released because the client client is configured with security. If the client is useful to security, you need to release the following two API information in the security configuration. )
/ / Anonymous + authorized access .antMatch ("/ actuator/**", "/ instances"). PermitAll () Thank you for reading this article carefully. I hope the article "sample Analysis of Java SpringBoot Rapid Integration of SpringBootAdmin console Monitoring Services" shared by the editor will be helpful to you. At the same time, I hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!
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.