随着开发周期的推移,项目会不断变大,切分出的服务也会越来越多,这时一个个的微服务构成了错综复杂的系统。
对于各个微服务系统的健康状态、会话数量、并发数、服务资源、延迟等度量信息的收集就成为了一个挑战。 Spring Boot Admin 就是基于这些需求开发出的一套功能强大的监控管理系统。
同样, Spring Boot Admin 也是由两个角色组成,一个是服务端 Spring Boot Admin Server ,一个是客户端 Spring Boot Admin Client 。
在 pom.xml 中主要添加 spring-cloud-starter-netflix-eureka-server 、 spring-boot-admin-starter-server 和 jolokia-core 依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
在 application.yml 中主要添加 Spring Boot Admin 相关配置
management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: health,info
在所需要被监控的项目中添加以下配置
在 pom.xml 中添加 spring-boot-admin-starter-client 和 jolokia-core 依赖
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
在 application.yml 中添加 spring boot admin 地址即可
spring:
boot:
admin:
client:
url: http://localhost:8084
打开浏览器访问: http://localhost:8084 ,出现以下界面
服务监控详情页面