22、Hystrix:通过Actuator获取hystrix数据

1、引入坐标

 <!--引入hystrix的监控信息-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>

2、在启动类上配置

//激活hystrix
@EnableCircuitBreaker

3、暴露所有actuator监控的端点(circuitBreaker开始)


hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 3000 #默认的连接超时时间1秒,若1秒没有返回数据,自动的触发降级逻辑
      circuitBreaker:
        enabled: true
        requestVolumeThreshold: 5
        errorThresholdPercentage: 10
        sleepWindowInMilliseconds: 10000

4、在页面上访问(更改为自己的ip和端口)

http://localhost:9001/actuator/hystrix.stream

你可能感兴趣的:(22、Hystrix:通过Actuator获取hystrix数据)