I. Introduction of HYSTRIX turbine
Looking at the individual Hystrix dashboard data does not have much value, want to see this system Hystrix dashboard data need to use Hystrix Turbine. Hystrix Turbine integrates each service Hystrix dashboard data. The use of Hystrix turbine is very simple, just to introduce the appropriate dependencies and add annotations and configuration.
Ii. preparatory work
The project used in this paper is a project of the previous article, which is reformed on this basis. Because we need multiple services dashboard, so need to build a service, named Service-lucy, its basic configuration with Service-hi, the specific source, here is not detailed description.
Iii. creation of Service-turbine
The corresponding dependencies are introduced:
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> < Dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot -starter-web</artifactid> </dependency> <dependency> <GROUPID>ORG.SPRINGF Ramework.boot</groupid> <artifactId>spring-boot-starter-actuator</artifactId> </DEP endency> <dependency> <groupId>org.springframework.cloud</groupId> <a Rtifactid>spring-cloud-starter-netflix-hystrix</artifactid> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <ARTIFACTID>SPRING-CLOUD-STARTER-NETF Lix-hystrix-dashboard</artifactid> </dependency> <dependency> <groupid>org.springframework.cloud& Lt;/groupid> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependenc Y> </dependencies>
In its entry class serviceturbineapplication add annotation @enableturbine, open turbine, @EnableTurbine annotations contain @enablediscoveryclient annotations, The registration service is turned on.
@SpringBootApplication@EnableEurekaClient@EnableDiscoveryClient@RestController@EnableHystrix@EnableHystrixDashboard@EnableCircuitBreaker@EnableTurbinepublic class ServiceTurbineApplication { /** * http://localhost:8764/turbine.stream */ public static void main(String[] args) { SpringApplication.run( ServiceTurbineApplication.class, args ); }}
Configuration file Application.yml:
spring: application.name: service-turbineserver: port: 8769security.basic.enabled: falseturbine: aggregator: clusterConfig: default # 指定聚合哪些集群,多个使用","分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问 appConfig: service-hi,service-la ### 配置Eureka中的serviceId列表,表明监控哪些服务 clusterNameExpression: new String("default") # 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称 # 2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default # 3. 当clusterNameExpression: metadata[‘cluster‘]时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABCeureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/
The configuration file annotations are written clearly. You are welcome to study the relevant technology to understand the source of friends directly seeking exchange and sharing technology: 2147775633
Turbine Demo
Turn on server, Service-hi, Service-la, Service-turbine Engineering.
Open Browser input: Http://localhost:8769/turbine.stream,
Request in turn:
http://localhost:8762/hi?name=whhttp://localhost:8763/hi?name=wh
Open: Http://localhost:8763/hystrix, input monitor stream http://localhost:8769/turbine.stream
You can see that this page aggregates the Hystrix dashbord data for 2 service.
Springcloud Circuit Breaker Aggregation monitoring (Hystrix Turbine)