The previous article described how to use Hystrix Dashboard to monitor the Hystrix command of a circuit breaker. When we have a lot of services, this needs to be aggregated so that the service Hystrix dashboard data. This requires another component of Spring cloud, the Hystrix Turbine.
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-turbine</Artifactid></Dependency><Dependency><Groupid>org.springframework.cloud</Groupid><Artifactid>spring-cloud-netflix-turbine</Artifactid></Dependency><Dependency><Groupid>org.springframework.boot</Groupid><Artifactid>spring-boot-starter-actuator</artifactid> </ dependency> <dependency> <groupid>org.springframework.boot</< Span class= "Hljs-title" >groupid> <artifactid> Spring-boot-starter-test</artifactid> <scope>test</ scope> </dependency> </DEPENDENCIES>
In its entry class serviceturbineapplication add annotation @enableturbine, open turbine, @EnableTurbine annotations contain @enablediscoveryclient annotations, The registration service is turned on.
@SpringBootApplication@EnableTurbinepublic class ServiceTurbineApplication { public static void main(String[] args) { new SpringApplicationBuilder(ServiceTurbineApplication.class).web(true).run(args); }}
Configuration file Application.yml:
Spring:application.name:service-turbineserver:port:8769security.basic.enabled:Falseturbine:aggregator:clusterConfig:Default # Specifies which clusters are aggregated, multiple use"," split, default todefault. You can access appconfig:service-hi using one of the Http://.../turbine.stream?cluster={clusterconfig}, Service-lucy # # # configuration Eureka in the Serviceid list, indicating which services are monitored clusternameexpression: new string (" default ") # 1. CLUSTERNAMEEXPRESSION Specifies the cluster name, the default expression appname; At this point: turbine.aggregator.clusterConfig need to configure the name of the app you want to monitor # 2. When clusternameexpression: default, Turbine.aggregator.clusterConfig can not write, because the default is default # 3. When Clusternameexpression:metadata[//localhost:8761/eureka/
The configuration file annotations are written clearly.
Iv. Turbine Demo
Turn on Eureka-server, Service-hi, Service-lucy, Service-turbine Engineering.
Open Browser Input: Http://localhost:8769/turbine.stream, the interface is as follows:
Request in turn:
Http://localhost:8762/hi?name=forezp
Http://localhost:8763/hi?name=forezp
Open: Http://localhost:8763/hystrix, input monitor stream http://localhost:8769/turbine.stream
Click on the monitor stream to enter the page:
You can see that this page aggregates the Hystrix dashbord data for 2 service.
Springcloud Learning and Growth 13 circuit breaker aggregation monitoring