Hystrix Dashboard用于監控Hystrix對請求的熔斷和斷路進行實時監控
一、在實作Hystrix降級和熔斷的微服務項目中暴露Hystrix監控端點:
1.添加actuator依賴:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2.在application.yml檔案中配置暴露Hystrix監控端點:
management:
endpoints:
web:
exposure:
include: hystrix.stream
3. 測試Hystrix監控端點是否暴露成功:
- http://localhost:3001/actuator
二、建立hystrix-dashboard 項目:
1. 建立項目,添加依賴:
2. 配置application.yml檔案:
3. 主啟動類添加 @EnableHystrixDashboard
和 @EnableDiscoveryClient
注解:
@EnableHystrixDashboard
@EnableDiscoveryClient
測試:
- 打開監控台: http://localhost:4001/hystrix
- 填入 hystrix 的監控端點,開啟監控: http://localhost:3001/actuator/hystrix.stream
- 通路Hystrix服務多次檢視監控結果: