目录
Spring Cloud 服务监控
1. SpringBoot 服务健康检查
(1) 依赖引入
在父工程中引入actuator的依赖,它提供了很多监控所需的接⼝,可以对应⽤系统进⾏配置查看、相关功能统计等。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
(2) 服务配置
在被监控的服务的配置文件中配置以下内容
# 暴露健康检查等断点接口给SpringBoot
management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: "*"
(3) 浏览器访问
访问健康检查接⼝:http://127.0.0.1:10030/actuator/health,可以获取到被监控服务的健康状态。
2. Hystrix Dashboard监控仪表盘
(1) 新建工程dashboard-server-mic
导入Hystrix Dashboard的依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId