天天看點

斷路器監控(Hystrix Dashboard)

首先,我是基于上一個例子ZooKeeper實作的服務注冊與發現 ​

然後不知道是不是ZK的問題,而不是使用Eureka的問題,導緻通路/hystrix.stream時一緻報錯:Unable to connect to Command Metric Stream,此方法在網上沒能找到解決方案。

如果是以Eureka來搭建的,內建很簡單,隻要在服務消費者上引入依賴即可

POM:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>      

然後在main方法入口的Class上加入以下注解:

@EnableCircuitBreaker
@EnableHystrix
@EnableHystrixDashboard      

最後通路/hystrix

輸入位址和Title

斷路器監控(Hystrix Dashboard)

即可看見監控的資料:

斷路器監控(Hystrix Dashboard)

 ​