1. 新建项目 turbineDashboard, pom.xml依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
</dependency>
<!--turbine集群监控-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
2.application.properties
server.port=8080
spring.application.type=turbine
spring.application.group=group
spring.application.name=${spring.application.group}-${spring.application.type}
dashboard.register.host=http://
eureka.client.service-url.defaultZone=${dashboard.register.host}/eureka
eureka.instance.lease-renewal-interval-in-seconds=10
eureka.instance.lease-expiration-duration-in-seconds=30
eureka.instance.prefer-ip-address=true
eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${server.port}
eureka.client.eureka-server-read-timeout-seconds=60
#GROUP-ORDER和TEST-TURBINE 为其它服务的spring.application.name, 部署多个相同name的服务形成一个集群
turbine.aggregator.clusterConfig=GROUP-ORDER,TEST-TURBINE
#服务名,此处与集群名相同
turbine.appConfig=GROUP-ORDER,TEST-TURBINE
#new String("default"): 将多个集群在同一个stream中展示
#metadata['cluster'] : 将多个集群在各自的stream中展示,
turbine.clusterNameExpression=metadata['cluster']
3.在要监控的服务[GROUP-ORDER,TEST-TURBINE]增加以下配置
eureka.instance.metadata-map.cluster=TEST-TURBINE
4. 启动入口配置
@EnableEurekaClient
@SpringBootApplication
@EnableHystrix
@EnableHystrixDashboard
@EnableTurbine
public class TurbineApplication {
public static void main(String[] args) {
SpringApplication.run(TurbineApplication.class, args);
}
}
4. 启动后访问http://localhost:8080/hystrix, 监控cluster为TEST-TURBINE的集群
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsISN0gTOzgTN2EjNxUDM4EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)