一、pom中引入對turbin的依賴,並增長dashboard圖形界面的展現spring
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine</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-test</artifactId> <scope>test</scope> </dependency> </dependencies>
二、配置配置文件,設置須要收集指標的服務express
# 配置Eureka中的serviceId列表, 代表監控哪些服務 turbine.app-config=ms-provider # 指定聚合哪些集羣, 多個使用","分割, 默認爲default. # 可以使用http://.../turbine.stream?cluster={clusterConfig之一}訪問 turbine.aggregator.cluster-config=default turbine.cluster-name-expression=new String("default") turbine.instanceUrlSuffix=manage/hystrix.stream
三、設置啓動類app
@SpringBootApplication @EnableHystrixDashboard @EnableTurbine public class MsDashboardApplication { // 直接監控某服務的hystrix: http://localhost:10000/hystrix.stream // DashBoard: http://localhost:10000/hystrix // 單臺監控:在界面輸入 http://localhost:10000/hystrix // 多臺監控(經過turbine):http://localhost:10000/turbine.stream public static void main(String[] args) { SpringApplication.run(MsDashboardApplication.class, args); } }
說明: @EnableTurbine
開啓turbine的支持、@EnableHystrixDashboard
容許使用圖形化的界面展現。ide
至此,就就完成了turbine收集指標的準備工做。spring-boot