hystrix-dashboard+turbine以及hystrix.stream資料問題
我的springcloudshe版本1.5.8.RELEASE如下:
hystrix-dashboard 是用於監控hystrix的呼叫情況,但是針對單個hystrix.stream監控
turbine 用於整合多個叢集的hystrix.stream,通過turbine.stream對外提供整合資料,這樣可以監控叢集的hystrix.stream呼叫
http://localhost:port/hystrix.stream
http://localhost:port/turbine.stream
可以將兩個hystrix-dashboard +turbine 合成一個專案節省下
1、配置監控平臺
首先配置hystrix-dashboard+turbine pom.xml
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.8.RELEASE</version> </parent> <groupId>com.nykj.bigdata</groupId> <artifactId>hystrix-dashboard</artifactId> <version>1.0.0</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</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-turbine</artifactId> </dependency> </dependencies>
啟動類
@SpringBootApplication
@EnableDiscoveryClient
@EnableTurbine
@EnableHystrixDashboard
public class HystrixDashboardApp {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApp.class, args);
}
}
配置檔案:appConfig 需要拉取hystrix.stream的application-name
clusterNameExpression 配置叢集name,我配置的是預設,這一塊應該和eureka配置放在一起(具體自己嘗試)
還有combineHostPort預設是true,用host和post來區分不同的服務
turbine:
appConfig: zuul-server,zuul-inner-server
clusterNameExpression: new String("default")
如此搭建完成。
2、如何讓應用產生hystrix.stream
需要actuator hystrix的相關jar包,需要@EnableCircuitBreaker相關注解
1、閘道器服務zuul本來就有,不用額外配置
2、使用feign呼叫的服務,需要開啟hystris feign:hystrix:enabled: true
3、非feign的springboot專案,使用resttemple呼叫服務時,需要以上相關包和相關注解,還需要 @HystrixCommand來使用hystrix來支援。
4、另外需要有呼叫任意hysrix介面,不然沒有hystrix呼叫,訪問hystrix.stream會一直ping,hystrix監控介面一直loading,檢視hystrix.stream是沒資料。
監控介面監控非閘道器服務時, Circuit顯示具體呼叫hystrix的類和對應方法,下面的thread pools顯示具體的application-name
盜圖一張,解釋監控介面引數
20180928 盜圖一張,說明圖片
3、參考文章
https://mp.weixin.qq.com/s/c4PwWUJiTKdeuxdGGAC8sw 系列文章可看
https://www.jianshu.com/p/b7b20fc09ca9 系列文章,內有程式碼示例,版本1.5.6可以參考