The simplest SpringCloud tutorial in history | Part 13: Circuit Breaker Aggregation Monitoring (Hystrix Turbine)

forward from:

http://blog.csdn.net/forezp/article/details/70233227 This article comes from Fang Zhipeng's blog 

 

The previous article described how to use the Hystrix Dashboard to monitor the Hystrix command of the circuit breaker. When we have many services, it is necessary to aggregate the data of Hystrix Dashboard of all services. This requires  another component of spring Cloud, Hystrix Turbine.

1. Introduction to Hystrix Turbine

There is not much value in looking at the data of a single Hystrix Dashboard. To see the Hystrix Dashboard data of this system, you need to use Hystrix Turbine. Hystrix Turbine integrates Hystrix Dashboard data for each service. The use of Hystrix Turbine is very simple, you only need to introduce the corresponding dependencies and add annotations and configurations.

2. Preparations

The project used in this article is the project of the previous article, and is modified on this basis. Because we need Dashboards for multiple services, we need to build another service, named service-lucy, whose basic configuration is the same as service-hi, see the source code for details, and will not be described in detail here.

3. Create service-turbine

Introduce the corresponding dependencies:

<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</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

 Add the annotation @EnableTurbine to its entry class ServiceTurbineApplication to enable turbo, and the @EnableTurbine annotation contains the @EnableDiscoveryClient annotation, which enables the registration service.

@SpringBootApplication
@EnableTurbine
public class ServiceTurbineApplication {

    public static void main(String[] args) {

            new SpringApplicationBuilder(ServiceTurbineApplication.class).web(true).run(args);
    }
}

 Configuration file application.yml:

spring:
  application.name: service-turbine
server:
  port: 8769
security.basic.enabled: false
turbine:
  aggregator:
    clusterConfig: default # Specify which clusters to aggregate, multiple use "," to split, the default is default. Accessible using http://.../turbine.stream?cluster={one of clusterConfig}
  appConfig: service-hi,service-lucy ### Configure the serviceId list in Eureka, indicating which services to monitor
  clusterNameExpression: new String("default")
  # 1. clusterNameExpression specifies the cluster name, the default expression appName; at this time: turbine.aggregator.clusterConfig needs to configure the name of the application you want to monitor
  # 2. When clusterNameExpression: default, turbine.aggregator.clusterConfig can not be written, because the default is default
  # 3. When clusterNameExpression: metadata['cluster'], assuming that the application you want to monitor is configured with eureka.instance.metadata-map.cluster: ABC, you need to configure it, and turbine.aggregator.clusterConfig: ABC
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

 The configuration file annotations are very clearly written.

4. Turbine demo

Start the eureka-server, service-hi, service-lucy, and service-turbine projects in sequence.

Open the browser and enter: 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 , enter monitoring stream http://localhost:8769/turbine.stream



 Click monitor stream to enter the page:

 

You can see that this page aggregates the hystrix dashbord data of two services.

Source code download: 
https://github.com/forezp/SpringCloudLearning/tree/master/chapter13

5. References

hystrix_dashboard

turbine

Excellent article recommendation:

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944180&siteId=291194637