开启turbine收集hystrix指标功能

使用turbine收集hystrix指标

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

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

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收集指标的准备工作。

原文地址:https://www.cnblogs.com/liangzs/p/8550175.html