开启turbine收集hystrix指标功能

使用turbine收集hystrix指标

1、pom中引入对turbin的依赖,并增加dashboard图形界面的展示



org.springframework.boot
spring-boot-starter-actuator


org.springframework.cloud
spring-cloud-starter-turbine


org.springframework.cloud
spring-cloud-starter-hystrix-dashboard


org.springframework.boot
spring-boot-starter-test
test


2、配置配置文件,设置需要收集指标的服务

配置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


3、设置启动类

@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允许使用图形化的界面展示。

至此,就就完成了turbine收集指标的准备工作。

posted @ 2018-03-12 16:48  神风炼  Views(256)  Comments(0)    收藏  举报