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 to configure:
<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 to configure:
spring.application.name=admin-ui [email protected]@ server.port=8080 eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka/
java code:
@SpringBootApplication @EnableDiscoveryClient @EnableAdminServer // Project source code example www.b12.com , public class AdminApplication { public static void main(String[] args) { SpringApplication.run(AdminApplication.class, args); } }
logback-spring.xml to configure:
<?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
Services being monitored pom.xml Added in:
<!-- 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 Add:
# 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>