Hystrix Dashboard: monitoring the implementation of the circuit breaker

SpringBoot actual electricity supplier item mall (20k + star) Address: github.com/macrozheng/...

Summary

Hystrix Dashboard is Spring Cloud view examples of the implementation of Hystrix a dashboard component that supports a single instance view and view the cluster instances, this will be a detailed description of its usage.

Brief introduction

Hystrix Hystrix Dashboard provides real-time performance monitoring HystrixCommand methods. Hystrix Dashboard can effectively reflect the operational circumstances of each Hystrix instance, helps us quickly identify problems in the system, in order to take countermeasures.

Hystrix single instance of surveillance

Let's use Hystrix Dashboard by monitoring its use under a single Hystrix examples to understand.

Create a hystrix-dashboard module

Used to monitor the implementation of hystrix instance.

  • Add its dependencies in pom.xml:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
  • Configured in application.yml:
server:
  port: 8501
spring:
  application:
    name: hystrix-dashboard
eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8001/eureka/
复制代码
  • Add @EnableHystrixDashboard on startup class to enable monitoring functions:
@EnableHystrixDashboard
@EnableDiscoveryClient
@SpringBootApplication
public class HystrixDashboardApplication {

    public static void main(String[] args) {
        SpringApplication.run(HystrixDashboardApplication.class, args);
    }

}
复制代码

Start related services

This time we need to start the following services: eureka-server, user-service, hystrix-service, hystrix-dashboard, after startup registry is shown below.

Hystrix examples demonstrate monitor

  • After the fill monitoring information click the button, we need to note here is that, because we do not support local https, so we need to fill in the address is http, otherwise they will be unable to obtain monitoring information;

  • It is also worth noting that monitored hystrix-service service needs to open hystrix.stream Actuator endpoints, configuration information is as follows:
management:
  endpoints:
    web:
      exposure:
        include: 'hystrix.stream' #暴露hystrix监控端点
复制代码

  • It can be found once we add in @HystrixCommand in commandKey and threadPoolKey properties are shown in the above, and there are seven calls are successful.

Hystrix Dashboard chart interpretation

Reading the following chart, note that small ball representing the instance of health status and traffic situation, the more conspicuous color, the more unhealthy instance, the greater the ball, the greater the flow instance. Curve shows real-time traffic change Hystrix instance.

Hystrix cluster instances monitor

Here we use Turbine to aggregate information hystrix-service monitoring services, then our hystrix-dashboard aggregation services you can get good monitoring information presented to us from Turbine.

Creating a turbine-service module

Used to polymerize hystrix-service monitoring of information.

  • Add its dependencies in pom.xml:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
  • Configured in application.yml, mostly adds Turbine configuration:
server:
  port: 8601
spring:
  application:
    name: turbine-service
eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8001/eureka/
turbine:
  app-config: hystrix-service #指定需要收集信息的服务名称
  cluster-name-expression: new String('default') #指定服务所属集群
  combine-host-port: true #以主机名和端口号来区分服务
复制代码
  • Add @EnableTurbine on startup class to enable Turbine related functions:
@EnableTurbine
@EnableDiscoveryClient
@SpringBootApplication
public class TurbineServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(TurbineServiceApplication.class, args);
    }

}
复制代码

Start related services

Configuration using application-replica1.yml hystrix-service then start a service, service start turbine-service, the registry at this time is shown below.

Hystrix cluster monitor demo

  • 访问Hystrix Dashboard:http://localhost:8501/hystrix

  • Add a cluster monitor address, it should be noted that we need to add is to monitor the turbine-service endpoint address:

  • We can see the number of instances of Hystrix into two.

To use the module

springcloud-learning
├── eureka-server -- eureka注册中心
├── user-service -- 提供User对象CRUD接口的服务
├── hystrix-service -- hystrix服务调用测试服务
├── turbine-service -- 聚合收集hystrix实例监控信息的服务
└── hystrix-dashboard -- 展示hystrix实例监控信息的仪表盘
复制代码

Project Source Address

github.com/macrozheng/…

No public

mall project a full tutorial serialized in public concern number the first time to obtain.

No public picture

Guess you like

Origin juejin.im/post/5d88cb58f265da03e4679eff
Recommended