1. 概述
Demo地址:http://git.oschina.net/zhou666/spring-cloud-7simple/tree/master/cloud-hystrix-turbine
hystrix-turbine集成了hystrix看板和 turbine,用來監控實現了hystrix的工程項目:
每一個監控項目的具體解釋:
原本的hystrix看板只能監控一台服務器上的服務調用情況,使用了turbine后就可以監控多台服務器的情況。Turbine原理如下:
2. 主要配置文件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<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.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
配置文件:
eureka:
instance:
leaseRenewalIntervalInSeconds: 10 #心跳間隔
client:
registerWithEureka: true #注冊本工程為服務
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka/ #注冊服務器地址
turbine:
aggregator:
clusterConfig: CLOUD-SIMPLE-SERVICE #turbine監控的服務名稱,可以多個
appConfig: cloud-simple-service #turbine監控的服務,可以有多個
clusterNameExpression: metadata['cluster']
3. 啟動與調試
啟動應用輸入http://localhost:8989/hystrix會看到hystrix面板,在這個面板里的監控url輸入,http://localhost:8989/turbine.stream??cluster=CLOUD-SIMPLE-SERVICE,其中cluster對應配置文件中clusterConfig中的名稱。