1. 程式人生 > >Spring Cloud:Hystrix監控

Spring Cloud:Hystrix監控

結合Hystrix Dashboard實現Hystrix指標資料的視覺化面板

一、監控資料

1.pom.xml中加入

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId
>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

2.應用主類加入:@EnableHystrixDashboard註解

3.訪問監控專案的ip:port/hystrix

輸入被監控專案的ip:port/hystrix.stream

點選Monitor Stream

這裡寫圖片描述

顯示如下:

這裡寫圖片描述

二、監控資料聚合

pom.xml檔案加入:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
    <groupId
>
org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

2.應用主類加入:@EnableTurbine註解

3.配置檔案中加入

turbine.app-config=eureka-consumer-ribbon-hystrix #監控資訊的服務名
turbine.cluster-name-expression="default"
turbine.combine-host-port=true

報錯如下,這是由於監控路徑和被監控路徑不一致的緣故

這裡寫圖片描述

解決方法:將配置檔案監控路徑一直

management.endpoints:
  enabled-by-default: true   #是否啟用或者關閉所有的端點
  web.exposure.include: '*'   #執行器端點都可以在無需驗證的情況下訪問