In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to use SpringBootAdmin monitoring tools", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn this article "how to use SpringBootAdmin monitoring tools".
Configure Admin Server
Since it is a hypervisor, there must be a server. It is easy to configure server. We can add this dependency:
De.codecentric spring-boot-admin-starter-server 2.2.2
At the same time, we need to add @ EnableAdminServer to the main program to start admin server.
@ EnableAdminServer@SpringBootApplicationpublic class SpringBootAdminServerApplication {public static void main (String [] args) {SpringApplication.run (SpringBootAdminServerApplication.class, args);}}
Configure admin client
With server, we next configure the client application to be monitored. In this article, we monitor ourselves and add client dependencies as follows:
De.codecentric spring-boot-admin-starter-client 2.2.2
We need to specify the admin server to register with for client:
Spring.boot.admin.client.url= http://localhost:8080
Since Spring Boot Admin depends on Spring Boot Actuator, we need to actively open the exposed primary key after Spring Boot2, as follows:
Management.endpoints.web.exposure.include=*management.endpoint.health.show-details=always
Configure the security primary key
Generally speaking, we need a login interface to prevent unauthorized access. Spring boot admin provides a UI for us to use, and we add Spring Security dependencies:
De.codecentric spring-boot-admin-server-ui-login 1.5.7 org.springframework.boot spring-boot-starter-security
With Spring Security added, we need to customize some configurations:
@ Configurationpublic class WebSecurityConfig extends WebSecurityConfigurerAdapter {private final AdminServerProperties adminServer; public WebSecurityConfig (AdminServerProperties adminServer) {this.adminServer = adminServer;} @ Override protected void configure (HttpSecurity http) throws Exception {SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler (); successHandler.setTargetUrlParameter ("redirectTo"); successHandler.setDefaultTargetUrl (this.adminServer.getContextPath () + "/") Http .authorizeRequests (this.adminServer.getContextPath () + "/ assets/**"). PermitAll () .antMatrices (this.adminServer.getContextPath () + "/ login"). PermitAll () .anyRequest (). Authenticated () .and () .formLogin () .loginPage (this.adminServer.getContextPath () + "/ login") .logoutUrl (this.adminServer.getContextPath () + "/ logout") .and () .httpBasic () .and () .csrf () .csrfTokenRepository (CookieCsrfTokenRepository.withHttpOnlyFalse ()) .originingRequestMatrices (new AntPathRequestMatcher (this.adminServer.getContextPath ()) + "/ instances") HttpMethod.POST.toString (), new AntPathRequestMatcher (this.adminServer.getContextPath () + "/ instances/*", HttpMethod.DELETE.toString ()), new AntPathRequestMatcher (this.adminServer.getContextPath () + "/ actuator/**") .and () .rememberMe () .key (UUID.randomUUID (). ToString ()) .tokenValiditySeconds (1209600) }}
Next, we specify the user name and password of the server in the configuration file:
Spring.boot.admin.client.username=adminspring.boot.admin.client.password=admin
As a client, when connecting to the server, we also need to provide the corresponding authentication information as follows:
Spring.boot.admin.client.instance.metadata.user.name=adminspring.boot.admin.client.instance.metadata.user.password=adminspring.boot.admin.client.username=adminspring.boot.admin.client.password=admin
All right, the login page and authority authentication are also complete.
Hazelcast cluster
Spring Boot Admin supports clusters with Hazelcast. Let's first add dependencies as follows:
Com.hazelcast hazelcast 3.12.2
Then add the configuration for Hazelcast:
@ Configurationpublic class HazelcastConfig {@ Bean public Config hazelcast () {MapConfig eventStoreMap = new MapConfig ("spring-boot-admin-event-store") .setInMemoryFormat (InMemoryFormat.OBJECT) .setBa ckupCount (1) .setEvictionPolicy (EvictionPolicy.NONE) .setMergePolicyConfig (new MergePolicyConfig (PutIfAbsentMapMergePolicy.class.getName (), 100)) MapConfig sentNotificationsMap = new MapConfig ("spring-boot-admin-application-store") .setInMemoryFormat (InMemoryFormat.OBJECT) .setBackupCount (1) .setEvictionPolicy (EvictionPolicy.LRU) .setMergePoli cyConfig (new MergePolicyConfig (PutIfAbsentMapMergePolicy.class.getName (), 100); Config config = new Config (); config.addMapConfig (eventStoreMap); config.addMapConfig (sentNotificationsMap); config.setProperty ("hazelcast.jmx", "true"); config.getNetworkConfig () .getJoin () .getMulticastConfig () .setEnabled (false) TcpIpConfig tcpIpConfig = config.getNetworkConfig () .getJoin () .getTcpIpConfig (); tcpIpConfig.setEnabled (true); tcpIpConfig.setMembers (Collections.singletonList ("127.0.0.1")); return config;}}
The above is all the contents of this article entitled "how to use SpringBootAdmin Monitoring tools". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.