Categories
Uncategorized

Spring Boot (ten): Spring Boot Admin application monitoring Spring Boot

1 Introduction

In the previous article, “Spring Boot (IX): Micro Application Monitoring Service Spring Boot Actuator explain” we introduced the Spring Boot Spring Boot Actuator based service monitoring, Spring Boot Actuator provides monitoring of single Spring Boot, the information includes: Application state, memory, threads, stacks and so on, more comprehensive monitoring of the entire life cycle of Spring Boot application. However, Spring Boot Actuator only provide us with monitoring data interface, and the amount of data returned is very large, it is impossible to analyze these data returned by the naked eye of an artificial way, certainly hope to have a graphical interface to help we have to analyze this information, and, in the micro-system services, the number of our services is very large, which is also inconvenient for our labor management, in this context, the birth of another open-source software, but also to this article introduced: Spring Boot Admin.

2. Spring Boot Admin Profile

Spring Boot Admin is a Web application for managing and monitoring the Spring Boot application running. Each Spring Boot application is considered registered with the client and the management server. Data acquisition behind is provided by Spring Boot Actuator endpoints. Distal Spring Boot Admin UI display using the data displayed in the front end VueJs.

This article describes how to use Spring Boot Admin on Spring Boot monitor.

3. combat engineering

3.1 Creating a parent project spring-boot-admin

Pom.xml dependencies as follows:

代码清单:spring-boot-admin/pom.xml
***


    UTF-8
    UTF-8
    1.8
    Greenwich.SR3
    2.1.5



    
        org.springframework.boot
        spring-boot-starter-web
    
    
        org.springframework.boot
        spring-boot-starter-actuator
    

    
        org.springframework.boot
        spring-boot-starter-test
        test
    



    
        
            org.springframework.cloud
            spring-cloud-dependencies
            ${spring-cloud.version}
            pom
            import
        
        
            de.codecentric
            spring-boot-admin-dependencies
            ${spring-boot-admin.version}
            pom
            import
        
    

    Increasing the spring-boot-admin-dependencies in the version configured as spring-boot-admin version information is not integrated in the spring-boot-dependencies in, I do not know why, we do not dare to ask.

3.2 create a sub-project spring-boot-admin-server

Spring Boot Admin can be used to monitor a single service can also be used to monitor the cluster, we first introduce a single monitoring service configuration.

pom.xml configuration file as follows:

代码清单:spring-boot-admin/spring-boot-admin-server/pom.xml
***


    de.codecentric
    spring-boot-admin-starter-server


    org.springframework.cloud
    spring-cloud-starter-netflix-eureka-client

Note: If only a single service, simply rely on the introduction of spring-boot-admin-starter-server’s can, spring-cloud-starter-netflix-eureka-client This dependency is based on the Eureka Spring Boot Admin service center will be used to dependence.

Profile application.yml as follows:

代码清单:spring-boot-admin/spring-boot-admin-server/src/main/resources/application.yml
***

server:
  port: 8888
spring:
  application:
    name: spring-boot-admin-server
eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

Note: Stand-alone version requires no configuration in which the eureka *** *** and other related content.

Start main class SpringBootAdminServerApplication.java follows:

代码清单:spring-boot-admin/spring-boot-admin-server/src/main/java/com/springboot/springbootadminserver/SpringBootAdminServerApplication.java
***

@SpringBootApplication
@EnableAdminServer
@EnableEurekaClient
public class SpringBootAdminServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminServerApplication.class, args);
    }

}

Note: Stand-alone version without adding @EnableEurekaClient comment.

3.3 create a sub-project spring-boot-admin-clienta

This project is a stand-alone version of the Spring Boot Admin demo use cases.

pom.xml follows: spring-boot-admin / spring-boot-admin-clienta / pom.xml

代码清单:
***


    de.codecentric
    spring-boot-admin-starter-client

    Spring Boot Admin client can be spring-boot-admin-starter-client for this project is only the introduction.

Profile application.yml as follows:

代码清单:spring-boot-admin/spring-boot-admin-clienta/src/main/resources/application.yml
***

server:
  port: 9090
spring:
  application:
    name: spring-boot-clienta
  boot:
    admin:
      client:
        url: http://localhost:8888
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

    Name spring.application.name configuration will be displayed in the Spring Boot Admin UI interface.

    spring.boot.admin.client.url configuration of our Spring Boot Admin server address.

    management.endpoints.web.exposure.include turn on all the monitors Spring Boot Actuator.

    management.endpoint.health.show-details open detailed application health monitoring information applications Actuator Spring Boot.

Start spring-boot-admin-server engineering and spring-boot-admin-clienta, wait a minute, spring-boot-admin-clienta will be automatically registered to the spring-boot-admin-server go above.

Open a browser to access http: // localhost: 8888 /, then we can see Spring Boot Admin monitoring chart, as follows:

When clicked, will enter the details of the application, we can see Spring Boot Admin use graphical interface shows the information of the application, as follows:

3.4 create a sub-project spring-boot-admin-client

This project is an example of a micro version of the Spring Boot Admin service using the example in which the service center Eureka registration services, Spring Boot Admin relevant information will be read from the service center Eureka, conduct service monitoring. So that we do not need to re-configure the client Spring Boot Admin service address, if the subsequent Spring Boot Admin service address migration occurs such things, there is no need to modify the client configuration file.

Eureka code examples here are no longer listed, if there is a need remedial students can visit the author of “Spring Cloud series.”

Project relies pom.xml as follows:

代码清单:spring-boot-admin/spring-boot-admin-client/pom.xml
***


    de.codecentric
    spring-boot-admin-starter-client


    org.springframework.cloud
    spring-cloud-starter-netflix-eureka-client

    Here only add Spring Boot Admin client and Spring Cloud Eureka clients rely on.

Profile application.yml as follows:

代码清单:spring-boot-admin/spring-boot-admin-client/src/main/resources/application.yml
***

server:
  port: 8080
spring:
  application:
    name: spring-boot-admin-client
eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

    Contrast front of the stand-alone configuration, this removes the configuration of Spring Boot Admin service address, Eureka configuration increases service center.

Start main class SpringBootAdminClientApplication.java follows:

代码清单:
***

@SpringBootApplication
@EnableEurekaClient
public class SpringBootAdminClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminClientApplication.class, args);
    }

}

    @EnableEurekaClient meaning Eureka enabled client, although no actual write here will enable the same, but it is best to write about it 🙂

test:

Modify the configuration editor idea, at two different ports promoters engineering spring-boot-admin-client, open Spring Boot Admin UI interface, shown below:

It can be seen here shows two applications (APPLICATIONS), one of our spring-boot-admin-server monitoring itself, and one of our spring-boot-admin-client application, and the application has two examples of (iNSTANCES), located in two separate ports 8080 and 8081. As you can see details of points into the corresponding instance.

4. Sample Code

Sample Code -Github

Sample Code -Gitee

5. Reference

Use spring-boot-admin service monitoring of Spring Boot

Leave a Reply