一、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