SpringCloud | Hystrix Dashboard(1)-熔断监控

252 阅读1分钟

熔断监控HystrixDashBoard

1. Ribbon+HystrixDashboard

  1. 使用Consumer9001改造,pom中增加依赖(actuator/hystrix/hystrixdashboard必备)
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
  1. 启动类上开启注解@EnableHystrixDashboard
@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableHystrixDashboard
public class Consumer9001 {

    public static void main(String[] args) {
        SpringApplication.run(Consumer9001.class, args);
    }
}
  1. application中暴露监控信息
#暴露hystrix dashboard的全部监控信息
management:
  endpoints:
    web:
      exposure:
        include: ["health","info","hystrix.stream"]

2. Feign + HystrixDashboard

  1. 使用ConsumerFeign9101项目改造,pom中引入支持文件
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
  1. 修改主配置类,增加@EnableCircuitBreaker和@EnableHystrixDashboard注解
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableCircuitBreaker
@EnableHystrixDashboard
public class ConsumerFeign9101 {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerFeign9101.class, args);
    }
}
  1. application.yml中暴露actuator全部监控信息
#暴露hystrix dashboard的全部监控信息
management:
  endpoints:
    web:
      exposure:
        include: "*"
  1. Hystrix DashBoard参数解释(来源于github-wiki)

实心圆:共有两种含义。它通过颜色的变化代表了实例的健康程度,如下图所示,它的健康度从绿色、黄色、橙色、红色递减。该实心圆除了颜色的变化之外,它的大小也会根据实例的请求流量发生变化,流量越大该实心圆就越大。所以通过该实心圆的展示,我们就可以在大量的实例中快速的发现故障实例和高压力实例。

代码示例-github

参考