Spring cloud integrates spring boot admin monitoring center

Keywords: Programming Spring xml encoding Java

Admin monitoring application

The monitoring interfaces provided by Spring Boot, such as / health, / info and so on, actually need to be monitored by other information industries besides the information mentioned before: the number of currently active sessions, the number of concurrent applications, latency and other measurement information. Let's learn how to use Spring Boot admin to monitor our system.

admin-server-ui

pom.xml configuration:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.3.RELEASE</version>
    <relativePath/>
</parent>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server</artifactId>
        <version>1.4.5</version>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui</artifactId>
        <version>1.4.5</version>
    </dependency>
</dependencies>

application.properties configuration:


spring.application.name=admin-ui
info.version=@project.version@
server.port=8080
 
eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka/

java code:


@SpringBootApplication
@EnableDiscoveryClient
@EnableAdminServer
public class AdminApplication {
 
    public static void main(String[] args) {
        SpringApplication.run(AdminApplication.class, args);
    }
}

logback-spring.xml configuration:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <jmxConfigurator/>
</configuration>

Add other items to be monitored

Add the following in the monitored service pom.xml:

<!--
    spring-boot-admin-starter-client Included in spring-boot-starter-actuator Used to collect service information
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
-->
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>1.4.5</version>
</dependency>

application.properties added:


# Turn off security access
management.security.enabled=false
 
# If the monitored service is not registered in the service center, add the admin address
# spring.boot.admin.url=http://localhost:8888

Add logback-spring.xml:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <jmxConfigurator/>
</configuration>
  • Main control interface: project source code example go: www.b12.com,

 

  • Detail page of single service, others will not be described in detail

Posted by spikypunker on Thu, 14 Nov 2019 09:16:08 -0800