JAVA course notes series: Spring Boot Admin

Spring Boot Admin

1. What is Spring Boot Admin?

Spring Boot Admin is an open source software for managing and monitoring Spring Boot applications. Each application is considered as a client. It is displayed in the admin server through HTTP or Eureka registration. The Spring Boot Admin UI uses AngularJs to display the data in the front end.

Spring Boot Admin is a monitoring tool for UI beautification encapsulation of spring boot's actor interface. He can: browse the basic information of all monitored spring boot projects in the list, detailed Health information, memory information, JVM information, garbage collection information, various configuration information (such as data source, cache list and hit rate), and directly modify the level of the logger.

2 monitoring single application

To use springboot admin, you need a server for display monitoring, so first configure a server

2.1 configure SpringBoot Server

2.1.1 pom file

   <dependencies>

            <!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server -->
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server</artifactId>
                <version>1.5.7</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui -->
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server-ui</artifactId>
                <version>1.5.7</version>
            </dependency>
        </dependencies>

2.1.2 application.yml

server:
  port: 30010 #Mainly used to access display

2.1.3 main program

@SpringBootApplication
@EnableAdminServer //Open admin server
public class AdminStarter {
    public static void main (String[] args){
        SpringApplication.run(AdminStarter.class,args);
    }
}

2.1.4 boot

Visit http://localhost:30010 after startup/

2.2 configure springboot client

We just need to add the springboot admin client to our normal springboot program, and then we can view it through the server. The following content is only added on the basis of the original project

2.2.1 pom.xml

Add dependency in pom file of project

  <dependency>
      <groupId>de.codecentric</groupId>
      <artifactId>spring-boot-admin-starter-client</artifactId>
      <version>1.5.7</version>
   </dependency>

2.2.2 application.yml

Add the admin server address to it

server:
  port: 30010 #Project port
spring:
  boot:
    admin:
      url: http://localhost:30010 #Add server address

2.2.3 main program

//The main program written for demonstration can be started directly in actual development
@SpringBootApplication
public class AdminClientApplication {
  public static void main(String[] args) {
    SpringApplication.run(AdminClientApplication.class, args);
  }
}

2.2.4 start access

After starting the client, access the server again. You can see the program we just started in it. You can see the detail s

##3 monitoring microservices (pull in eureka)

In development, our microservices are all spring boot projects. If we want to view these programs, we can pull all our programs from eureka by asking the server to go to eureka. We need to configure eureka server instead of eureka configuration

3.1 configure server

We just need to register the server with eureka

3.1.1 pom.xml

 <dependencies>

            <!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server -->
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server</artifactId>
                <version>1.5.7</version>
            </dependency>


            <!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui -->
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server-ui</artifactId>
                <version>1.5.7</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>

        </dependencies>

3.1.2 application.yml

server:
  port: 30010
eureka:
  client:
    service-url:
      defaultZone: http://user:123@localhost:10000/eureka #Configure eureka
spring:
  application:
    name: springbootadminserver

3.1.3 main program

@SpringBootApplication
@EnableAdminServer
@EnableEurekaClient #Register to eureka,Used from eureka Middle pull program list
public class AdminStarter {
    public static void main (String[] args){
        SpringApplication.run(AdminStarter.class,args);
    }
}

3.1.4 start server

After startup, configure the client

3.2 configure client

We can register all the programs we need to view by springboot admin to eureka

3.2.1 pom file

Add eureka to pom

 <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>

3.2.2 configure application.yml

In this case, you need to configure the eureka address. You do not need to configure the address of the admin server in a single application

server:
  port: 30011
eureka:
  client:
    service-url:
      defaultZone: http://user:123@localhost:10000/eureka #To configure the eureka address, you need to set it up in advance
spring:
  application:
    name: springbootadminclient

3.2.3 main program

@SpringBootApplication
@EnableEurekaClient //Register to eureka, which can be found by admin server
public class AdminClientStarter {
    public static void main (String[] args){
        SpringApplication.run(AdminClientStarter.class,args);
    }
}

3.2.4 boot

After startup, access the server ui, and you can see all the services in eureka, including the admin server program

213 original articles published, praised 201, 390000 visitors+
His message board follow

Tags: Spring SpringBoot xml AngularJS

Posted on Mon, 13 Jan 2020 23:20:18 -0500 by kangaroo232002