關(guān)于Spring?Cloud的熔斷器監(jiān)控問(wèn)題
Hystrix監(jiān)控
actuator的監(jiān)控節(jié)點(diǎn)
在actuator
下有用來(lái)監(jiān)控hystrix
的端點(diǎn)/actuator/hystrix.stream
。
訪問(wèn):
輸出:(注意監(jiān)控時(shí)需要請(qǐng)求@HystrixCommand
配置的微服務(wù))
ping:
data: {"type":"HystrixCommand","name":"feignCardRand","group":"TestController","currentTime":1641272819332,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":1000,"rollingCountBadRequests":0,"rollingCountCollapsedRequests":0,"rollingCountEmit":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackEmit":0,"rollingCountFallbackFailure":0,"rollingCountFallbackMissing":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":1000,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"rollingMaxConcurrentExecutionCount":10,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1,"threadPool":"TestController"}
集成hystrix dashboard
接口數(shù)據(jù)查看起來(lái)不直觀,可以運(yùn)行hystrix dashboard
通過(guò)界面來(lái)查看。
先引入依賴
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency>
創(chuàng)建啟動(dòng)類
@EnableHystrixDashboard @SpringBootApplication(scanBasePackages = "com.github.mg0324") public class StartupApplication { public static void main(String[] args) { SpringApplication.run(StartupApplication.class,args); } }
添加首頁(yè)跳轉(zhuǎn),支持端口直接到hystrix
資源路徑
@Controller public class HystrixIndexController { @GetMapping("") public String index() { return "forward:/hystrix"; } }
添加配置端口
server: port: 8030 hystrix: dashboard: # 設(shè)置允許連接的IP proxy-stream-allow-list: "192.168.3.29"
啟動(dòng)服務(wù),并訪問(wèn) http://127.0.0.0:8030
監(jiān)控詳情解讀
在 Hystrix Dashboard 界面里的url處填寫要監(jiān)控的hystrix數(shù)據(jù)流地址。
如:http://192.168.3.29:9202/actuator/hystrix.stream
如果連接后的界面里什么都沒(méi)有顯示,則需要手動(dòng)請(qǐng)求后,才能展現(xiàn)數(shù)據(jù)??梢杂?ab 命令做請(qǐng)求壓測(cè),加大壓力,讓熔斷器開啟,圖中會(huì)出現(xiàn)紅色。
ab命令如下:ab -n 10000 -c 160 http://127.0.0.1:9201/test/test/feign/cardRand
集成Turbine監(jiān)控
Turbine是一個(gè)聚合Hystrix監(jiān)控?cái)?shù)據(jù)的工具,它可將所有相關(guān)/hystrix.stream端點(diǎn)的數(shù)據(jù)聚合到一個(gè)組合的/turbine.stream中,從而讓集群的監(jiān)控更加方便。
添加依賴。
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency>
編寫啟動(dòng)類。
@EnableTurbine @SpringBootApplication(scanBasePackages = "com.github.mg0324") public class StartupApplication { public static void main(String[] args) { SpringApplication.run(StartupApplication.class,args); } }
添加配置。
server: port: 8031 spring: application: name: card-hystrix-turbine eureka: client: service-url: defaultZone: http://192.168.3.29:8761/eureka/ instance: prefer-ip-address: true turbine: # 要監(jiān)控的微服務(wù)列表,多個(gè)用,分隔 appConfig: mic-card,mic-test clusterNameExpression: "'default'"
啟動(dòng)服務(wù)后,得到 http://192.168.3.29:8031/turbine.stream 的聚合節(jié)點(diǎn)。填寫到hystrix dashboard的url中做監(jiān)控。
參考
https://www.itmuch.com/spring-cloud/finchley-15/
到此這篇關(guān)于Spring Cloud的熔斷器監(jiān)控的文章就介紹到這了,更多相關(guān)Spring Cloud 熔斷器內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Spring Boot如何使用Spring Security進(jìn)行安全控制
要實(shí)現(xiàn)訪問(wèn)控制的方法多種多樣,可以通過(guò)Aop、攔截器實(shí)現(xiàn),也可以通過(guò)框架實(shí)現(xiàn),本文將具體介紹在Spring Boot中如何使用Spring Security進(jìn)行安全控制。2017-04-04基于Log4j2阻塞業(yè)務(wù)線程引發(fā)的思考
這篇文章主要介紹了基于Log4j2阻塞業(yè)務(wù)線程引發(fā)的思考,基于很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-12-12Kafka Java Producer代碼實(shí)例詳解
這篇文章主要介紹了Kafka Java Producer代碼實(shí)例詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06SpringBoot項(xiàng)目啟動(dòng)時(shí)如何讀取配置以及初始化資源
這篇文章主要給大家介紹了關(guān)于SpringBoot項(xiàng)目啟動(dòng)時(shí)如何讀取配置以及初始化資源的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者使用SpringBoot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06java使用Filter實(shí)現(xiàn)自動(dòng)登錄的方法
這篇文章主要為大家詳細(xì)介紹了java使用Filter實(shí)現(xiàn)自動(dòng)登錄的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04