使用簡略總結(jié):
一涛酗、Turbine & Hystrix-Dashboard (熔斷器可視化)
1.Hystrix-Dashboard?熔斷器可視化界面
能夠?qū)崟r獲取Hystrix熔斷器配置的hystrix.command對應(yīng)的fallback方法的調(diào)用情況
所需依賴
<dependency>
????<groupId>org.springframework.cloud</groupId>
????<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
啟動類注解
@EnableHystrixDashboard
2.Turbine
匯集各個微服務(wù)Hystrix熔斷器fallback方法信息監(jiān)控信息预明,并將聚合后的信息提供給Hystrix?Dashboard來集中展示和監(jiān)控
所需依賴
<dependency>
????<groupId>org.springframework.cloud</groupId>
????<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
????<groupId>org.springframework.cloud</groupId>
????<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
所需注解
啟動類注解?@EnableTurbine
所需配置信息(yml)
turbine:
? ????app-config:? xxx? ? ?#Eureka Server注冊serviceId,聚合微服務(wù)的監(jiān)控數(shù)據(jù) 大小寫均可
? ????cluster-name-expression: new String("default") # 設(shè)置監(jiān)控的表達(dá)式浙值,通過此表達(dá)式表示要獲取監(jiān)控信息名稱 不可缺少
二、Sleuth & Zipkin(服務(wù)鏈跟蹤)
通過各個Zipkin-Client向Zipkin-Server發(fā)送請求數(shù)據(jù)做到服務(wù)鏈跟蹤,同一請求入口可構(gòu)成一條服務(wù)鏈(同一traceid)
1.Zipkin-Server服務(wù)端直接下載對應(yīng)的官方j(luò)ar包直接運(yùn)行(端口9411)
2.Zipkin-Client
所需依賴
<dependency>
????<groupId>org.springframework.cloud</groupId>
????<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
不需要注解
所需配置信息(yml)? ? 注意空格距離!
spring
? ??????#服務(wù)鏈跟蹤
? ? zipkin:
? ? ? ? base-url: http://localhost:9411? ? #Zipkin-Server地址
? ? sleuth:
? ? ? ? sampler:
? ? ? ? ? ? probability: 1.0? #? 0.0 - 1.0? 根據(jù)客戶端性能與信息綜合設(shè)置? 測試使用1.0
3.Zipkin-Server界面的依賴鏈路形成一條鏈煤率,需要微服務(wù)之間通過FeignClient進(jìn)行調(diào)用或者通過RestTemplate(使用Spring容器中注入的RestTemplate才可以)