Spring boot admin monitoring method, springadmin

Source: Internet
Author: User
Tags spring boot actuator

Spring boot admin monitoring method, springadmin

1. Introduction to Spring Boot Admin

Spring boot admin github Open Source Address: https://github.com/codecentric/spring-boot-admin

It provides simple web ui Display Based on Spring Boot Actuator.

Ii. project use:

1. Build a maven web Project

2. pom dependency Configuration

<dependency>   <groupId>org.springframework.boot</groupId>   <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency>   <groupId>org.springframework.boot</groupId>   <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency>   <groupId>de.codecentric</groupId>   <artifactId>spring-boot-admin-starter-client</artifactId> </dependency> <dependency>   <groupId>de.codecentric</groupId>   <artifactId>spring-boot-admin-server</artifactId> </dependency> <dependency>   <groupId>de.codecentric</groupId>   <artifactId>spring-boot-admin-server-ui</artifactId> </dependency> <dependency>   <groupId>de.codecentric</groupId>   <artifactId>spring-boot-admin-server-ui-login</artifactId> </dependency> 

Add the above configuration in pom. xml

Admin server: spring-boot-admin-server, spring-boot-admin-server-ui

Admin client: spring-boot-admin-starter-client (this item can monitor the running status of the server. You only need to introduce the client to other projects to introduce monitoring information)

Security: spring-boot-starter-security

Logon verification: spring-boot-admin-server-ui-login (you can also add a simple logon Interface)

3. application. yml

info:  app:   name: imard   version: v1.0.0 [html] view plain copylogging:  file: "d:/logs/imard/boot.log" management:  context-path: "/actuator" spring:  application:   name: "@pom.artifactId@"  boot:   admin:    url: http://www.test.com:8080  profiles:   active:    - secure --- spring:  profiles: insecure management:  security:   enabled: false security:  basic:   enabled: false --- spring:  profiles: secure  boot:   admin:    username: "${security.user.name}"    password: "${security.user.password}"    client:     metadata:      user.name: "${security.user.name}"      user.password: "${security.user.password}"  security:  user:   name: user   password: pass 

Among them: spring. boot. admin. url declares the admin server address (other projects will actively register to the admin monitoring through this url)
Info: configure the basic information of the app

Www.test.com ing in the host hosts

4. Application. java

@Configuration @EnableAutoConfiguration @EnableAdminServer public class Application extends SpringBootServletInitializer {   @Override   protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {     return application.sources(Application.class);   }    public static void main(String[] args) {     SpringApplication.run(Application.class, args);   } } 

@ EnableAdminServer Add the annotation to start monitoring

5. SecurityConfig

@Profile("secure") @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter {   @Override   protected void configure(HttpSecurity http) throws Exception {     http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();     http.logout().logoutUrl("/logout");     http.csrf().disable();     http.authorizeRequests()       .antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**").permitAll();     http.authorizeRequests().antMatchers("/api/**").permitAll().antMatchers("/**")       .authenticated();     // Enable so that the clients can authenticate via HTTP basic for registering     http.httpBasic();   } } 

Configure a basic Security policy using Spring Security

6. Supervision and Management

1 ~ After five steps, use the application to start the monitoring program.

After security verification through the http://www.test.com: 8080/login.html monitoring login interface, such:

Log on to details to view the project monitoring information (Details, Log, Metrics, Environment, Logging, JMX, Threads, Audit, Trace, Heapdump)

Summary

The above section describes how to add admin monitoring for spring boot. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.