最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

springcloud 熔斷監(jiān)控Hystrix Dashboard和Turbine

 更新時(shí)間:2019年08月06日 14:41:56   作者:微笑很純潔  
這篇文章主要介紹了springcloud 熔斷監(jiān)控Hystrix Dashboard和Turbine,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

Hystrix-dashboard是一款針對(duì)Hystrix進(jìn)行實(shí)時(shí)監(jiān)控的工具,通過Hystrix Dashboard我們可以在直觀地看到各Hystrix Command的請(qǐng)求響應(yīng)時(shí)間, 請(qǐng)求成功率等數(shù)據(jù)。但是只使用Hystrix Dashboard的話, 你只能看到單個(gè)應(yīng)用內(nèi)的服務(wù)信息, 這明顯不夠. 我們需要一個(gè)工具能讓我們匯總系統(tǒng)內(nèi)多個(gè)服務(wù)的數(shù)據(jù)并顯示到Hystrix Dashboard上, 這個(gè)工具就是Turbine.

Hystrix Dashboard

我們?cè)谌蹟嗍纠?xiàng)目spring-cloud-consumer-hystrix的基礎(chǔ)上更改,重新命名為:spring-cloud-consumer-hystrix-dashboard。

1、添加依賴

<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.boot</groupId>
 <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

這三個(gè)包必須添加

2、啟動(dòng)類

啟動(dòng)類添加啟用Hystrix Dashboard和熔斷器

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrixDashboard
@EnableCircuitBreaker
public class ConsumerApplication {

 public static void main(String[] args) {
 SpringApplication.run(ConsumerApplication.class, args);
 }
}

3、測(cè)試

啟動(dòng)工程后訪問 http://localhost:9001/hystrix,將會(huì)看到如下界面:

圖中會(huì)有一些提示:

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream
Cluster via Turbine (custom cluster): http://turbine-hostname:port/turbine.stream?cluster=[clusterName]
Single Hystrix App: http://hystrix-app:port/hystrix.stream

大概意思就是如果查看默認(rèn)集群使用第一個(gè)url,查看指定集群使用第二個(gè)url,單個(gè)應(yīng)用的監(jiān)控使用最后一個(gè),我們暫時(shí)只演示單個(gè)應(yīng)用的所以在輸入框中輸入:
http://localhost:9001/hystrix.stream ,輸入之后點(diǎn)擊 monitor,進(jìn)入頁面。

如果沒有請(qǐng)求會(huì)先顯示Loading ...,訪問http://localhost:9001/hystrix.stream 也會(huì)不斷的顯示ping。

請(qǐng)求服務(wù)http://localhost:9001/hello/neo,就可以看到監(jiān)控的效果了,首先訪問http://localhost:9001/hystrix.stream,顯示如下:

ping:

data: {"type":"HystrixCommand","name":"HelloRemote#hello(String)","group":"spring-cloud-producer","currentTime":1494915453986,"isCircuitBreakerOpen":false,"errorPercentage":100,"errorCount":1,"requestCount":1,"rollingCountBadRequests":0,"rollingCountCollapsedRequests":0,"rollingCountEmit":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackEmit":0,"rollingCountFallbackFailure":0,"rollingCountFallbackMissing":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":1,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":1,"currentConcurrentExecutionCount":0,"rollingMaxConcurrentExecutionCount":0,"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":"spring-cloud-producer"}

data: {"type":"HystrixThreadPool","name":"spring-cloud-producer","currentTime":1494915453986,"currentActiveCount":0,"currentCompletedTaskCount":1,"currentCorePoolSize":10,"currentLargestPoolSize":1,"currentMaximumPoolSize":10,"currentPoolSize":1,"currentQueueSize":0,"currentTaskCount":1,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1}

說明已經(jīng)返回了監(jiān)控的各項(xiàng)結(jié)果

到監(jiān)控頁面就會(huì)顯示如下圖:

其實(shí)就是http://localhost:9001/hystrix.stream返回結(jié)果的圖形化顯示,Hystrix Dashboard Wiki上詳細(xì)說明了圖上每個(gè)指標(biāo)的含義,如下圖:

到此單個(gè)應(yīng)用的熔斷監(jiān)控已經(jīng)完成。

Turbine

在復(fù)雜的分布式系統(tǒng)中,相同服務(wù)的節(jié)點(diǎn)經(jīng)常需要部署上百甚至上千個(gè),很多時(shí)候,運(yùn)維人員希望能夠把相同服務(wù)的節(jié)點(diǎn)狀態(tài)以一個(gè)整體集群的形式展現(xiàn)出來,這樣可以更好的把握整個(gè)系統(tǒng)的狀態(tài)。 為此,Netflix提供了一個(gè)開源項(xiàng)目(Turbine)來提供把多個(gè)hystrix.stream的內(nèi)容聚合為一個(gè)數(shù)據(jù)源供Dashboard展示。

1、添加依賴

<dependencies>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-turbine</artifactId>
 </dependency>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-netflix-turbine</artifactId>
 </dependency>
 <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>
</dependencies>

2、配置文件

spring.application.name=hystrix-dashboard-turbine
server.port=8001
turbine.appConfig=node01,node02
turbine.aggregator.clusterConfig= default
turbine.clusterNameExpression= new String("default")

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
  • turbine.appConfig :配置Eureka中的serviceId列表,表明監(jiān)控哪些服務(wù)
  • turbine.aggregator.clusterConfig :指定聚合哪些集群,多個(gè)使用”,”分割,默認(rèn)為default??墒褂?code>http://.../turbine.stream?cluster={clusterConfig之一}訪問
  • turbine.clusterNameExpression : 1. clusterNameExpression指定集群名稱,默認(rèn)表達(dá)式appName;此時(shí):turbine.aggregator.clusterConfig需要配置想要監(jiān)控的應(yīng)用名稱;2. 當(dāng)clusterNameExpression: default時(shí),turbine.aggregator.clusterConfig可以不寫,因?yàn)槟J(rèn)就是default;3. 當(dāng)clusterNameExpression: metadata[‘cluster']時(shí),假設(shè)想要監(jiān)控的應(yīng)用配置了eureka.instance.metadata-map.cluster: ABC,則需要配置,同時(shí)turbine.aggregator.clusterConfig: ABC

3、啟動(dòng)類

啟動(dòng)類添加@EnableTurbine,激活對(duì)Turbine的支持

@SpringBootApplication
@EnableHystrixDashboard
@EnableTurbine
public class DashboardApplication {

 public static void main(String[] args) {
 SpringApplication.run(DashboardApplication.class, args);
 }

}

到此Turbine(hystrix-dashboard-turbine)配置完成

4、測(cè)試

在示例項(xiàng)目spring-cloud-consumer-hystrix基礎(chǔ)上修改為兩個(gè)服務(wù)的調(diào)用者spring-cloud-consumer-node1和spring-cloud-consumer-node2

spring-cloud-consumer-node1項(xiàng)目改動(dòng)如下:
application.properties文件內(nèi)容

spring.application.name=node01
server.port=9001
feign.hystrix.enabled=true

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/

spring-cloud-consumer-node2項(xiàng)目改動(dòng)如下:
application.properties文件內(nèi)容

spring.application.name=node02
server.port=9002
feign.hystrix.enabled=true

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/

HelloRemote類修改:

@FeignClient(name= "spring-cloud-producer2", fallback = HelloRemoteHystrix.class)
public interface HelloRemote {

 @RequestMapping(value = "/hello")
 public String hello2(@RequestParam(value = "name") String name);

}

對(duì)應(yīng)的HelloRemoteHystrixConsumerController類跟隨修改,具體查看代碼

修改完畢后,依次啟動(dòng)spring-cloud-eureka、spring-cloud-consumer-node1、spring-cloud-consumer-node1、hystrix-dashboard-turbine(Turbine)

打開eureka后臺(tái)可以看到注冊(cè)了三個(gè)服務(wù):

訪問 http://localhost:8001/turbine.stream

返回:

: ping
data: {"reportingHostsLast10Seconds":1,"name":"meta","type":"meta","timestamp":1494921985839}

并且會(huì)不斷刷新以獲取實(shí)時(shí)的監(jiān)控?cái)?shù)據(jù),說明和單個(gè)的監(jiān)控類似,返回監(jiān)控項(xiàng)目的信息。進(jìn)行圖形化監(jiān)控查看,輸入:http://localhost:8001/hystrix,返回酷酷的小熊界面,輸入: http://localhost:8001/turbine.stream,然后點(diǎn)擊 Monitor Stream ,可以看到出現(xiàn)了倆個(gè)監(jiān)控列表

示例代碼

參考:

使用Spring Cloud與Docker實(shí)戰(zhàn)微服務(wù)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • SpringBoot整合Hbase的實(shí)現(xiàn)示例

    SpringBoot整合Hbase的實(shí)現(xiàn)示例

    這篇文章主要介紹了SpringBoot整合Hbase的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • IDEA中Services欄不顯示的解決方案小結(jié)

    IDEA中Services欄不顯示的解決方案小結(jié)

    正常編譯完一個(gè)SpringBoot或者SringCloud項(xiàng)目之后,Services都會(huì)顯示出你有哪些服務(wù),如果沒有services欄怎么解決呢?下面小編給大家分享IDEA中Services欄不顯示的解決方案小結(jié),感興趣的朋友一起看看吧
    2021-08-08
  • spring boot整合CAS配置詳解

    spring boot整合CAS配置詳解

    這篇文章主要介紹了spring boot整合CAS配置詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-05-05
  • 詳解spring cloud ouath2中的資源服務(wù)器

    詳解spring cloud ouath2中的資源服務(wù)器

    這篇文章主要介紹了spring cloud ouath2中的資源服務(wù)器的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-02-02
  • SpringCloud的Hystrix簡(jiǎn)單介紹

    SpringCloud的Hystrix簡(jiǎn)單介紹

    這篇文章主要介紹了SpringCloud的Hystrix簡(jiǎn)單介紹,SpringCloud Hystrix是Netflix開源的一款容錯(cuò)框架,具備服務(wù)降級(jí),服務(wù)熔斷,依賴隔離,監(jiān)控(Hystrix Dashboard)等功能,同樣具有自我保護(hù)能力,需要的朋友可以參考下
    2023-07-07
  • SpringBoot使用AOP實(shí)現(xiàn)日志記錄功能詳解

    SpringBoot使用AOP實(shí)現(xiàn)日志記錄功能詳解

    這篇文章主要為大家介紹了SpringBoot使用AOP實(shí)現(xiàn)日志記錄功能詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • springboot中使用rabbitt的詳細(xì)方法

    springboot中使用rabbitt的詳細(xì)方法

    這篇文章主要介紹了springboot中使用rabbitt,通過本文學(xué)習(xí)讓我們了解如何在Spring Boot中使用RabbitMQ,并使用不同的交換機(jī)和隊(duì)列類型以及消息確認(rèn)模式,需要的朋友可以參考下
    2023-05-05
  • Spring Boot2.0中SpringWebContext找不到無法使用的解決方法

    Spring Boot2.0中SpringWebContext找不到無法使用的解決方法

    這篇文章主要給大家介紹了關(guān)于Spring Boot2.0中SpringWebContext找不到無法使用的解決方法,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • springcloud?nacos動(dòng)態(tài)線程池Dynamic?tp配置接入實(shí)戰(zhàn)詳解

    springcloud?nacos動(dòng)態(tài)線程池Dynamic?tp配置接入實(shí)戰(zhàn)詳解

    這篇文章主要為大家介紹了springcloud?nacos動(dòng)態(tài)線程池Dynamic?tp配置接入實(shí)戰(zhàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12
  • SpringBoot調(diào)用WebService接口的實(shí)現(xiàn)示例

    SpringBoot調(diào)用WebService接口的實(shí)現(xiàn)示例

    本文主要介紹了SpringBoot調(diào)用WebService接口的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2025-03-03

最新評(píng)論

临潭县| 石泉县| 长子县| 墨竹工卡县| 兰考县| 舟山市| 临江市| 九龙县| 固阳县| 济南市| 郸城县| 乌拉特中旗| 灵武市| 平度市| 内乡县| 西安市| 宕昌县| 启东市| 洪泽县| 灵寿县| 八宿县| 凭祥市| 会泽县| 岗巴县| 边坝县| 淅川县| 双城市| 西昌市| 阳东县| 怀集县| 广水市| 九江市| 太仓市| 城口县| 启东市| 天峨县| 承德市| 周宁县| 镇雄县| 兰州市| 佛教|