繼上一篇http://www.cnblogs.com/EasonJim/p/7613595.html介紹了斷路器之后,其實它還提供了一個管理頁面來監控這些應用的調用數據。
首先,我是基於上一個例子ZooKeeper實現的服務注冊與發現:http://www.cnblogs.com/EasonJim/p/7613734.html
然后不知道是不是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
即可看見監控的數據:
參考: