turbine
是聚合服务器发送事件流数据的一个工具,hystrix
的监控中,只能监控单个节点,实际生产中都为集群,因此可以通过turbine
来监控集群下hystrix
的metrics
情况,通过eureka
来发现hystrix
服务。
下面把turbine整合到spring-cloud项目中
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
application.yaml
server:
port: 9003
spring:
application:
name: hystrix-turbine
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
prefer-ip-address: true
turbine:
aggregator:
clusterConfig: SPRING-CLOUD-CONSUMER
appConfig: spring-cloud-consumer
SpringCloudHystrixTurbineApplication.java
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
@SpringBootApplication
@EnableTurbine
public class SpringCloudHystrixTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudHystrixTurbineApplication.class, args);
}
}
验证
在hystrix dashboard中图形化监控