SpringCloudHystrixDashboard服務(wù)監(jiān)控詳解_第1頁(yè)
SpringCloudHystrixDashboard服務(wù)監(jiān)控詳解_第2頁(yè)
SpringCloudHystrixDashboard服務(wù)監(jiān)控詳解_第3頁(yè)
SpringCloudHystrixDashboard服務(wù)監(jiān)控詳解_第4頁(yè)
SpringCloudHystrixDashboard服務(wù)監(jiān)控詳解_第5頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

第SpringCloudHystrixDashboard服務(wù)監(jiān)控詳解目錄hystrixDashboard服務(wù)監(jiān)控?cái)嗦菲餮菔颈O(jiān)控監(jiān)控8001注意事項(xiàng)監(jiān)控測(cè)試監(jiān)控狀態(tài)

hystrixDashboard服務(wù)監(jiān)控

除了隔離依賴服務(wù)的調(diào)用以外,Hystrix還提供了準(zhǔn)實(shí)時(shí)的調(diào)用監(jiān)控(HystrixDashboard),Hystrix會(huì)持續(xù)地記錄所有通過Hystrix發(fā)起的請(qǐng)求的執(zhí)行信息,并以統(tǒng)計(jì)報(bào)表和圖形的形式展示給用戶,包括每秒執(zhí)行多少請(qǐng)求多少成功,多少失敗等。Netflix通過hystrix-metrics-event-stream項(xiàng)目實(shí)現(xiàn)了對(duì)以上指標(biāo)的監(jiān)控。SpringCloud也提供了HystrixDashboard的整合,對(duì)監(jiān)控內(nèi)容轉(zhuǎn)化成可視化界面。

1、新建cloud-consumer-hystrix-dashboard9001儀表盤監(jiān)控模塊

2、修改pom.xml文件引入儀表盤依賴

核心依賴:spring-cloud-starter-netflix-hystrix-dashboard

注意:所有的圖形化展示,都需要引入spring-boot-starter-actuator依賴,在8001、8002上都需要引入

xmlversion="1.0"encoding="UTF-8"

projectxmlns="/POM/4.0.0"

xmlns:xsi="/2001/XMLSchema-instance"

xsi:schemaLocation="/POM/4.0.0/xsd/maven-4.0.0.xsd"

parent

artifactIdspringcloud2025/artifactId

groupIdcom.zcl.springcloud/groupId

version1.0-SNAPSHOT/version

/parent

modelVersion4.0.0/modelVersion

artifactIdcloud-consumer-hystrix-dashboard9001/artifactId

properties

piler.source8/piler.source

piler.target8/piler.target

/properties

dependencies

dependency

groupIdorg.springframework.cloud/groupId

artifactIdspring-cloud-starter-netflix-hystrix-dashboard/artifactId

/dependency

dependency

groupIdorg.springframework.boot/groupId

artifactIdspring-boot-starter-actuator/artifactId

/dependency

dependency

groupIdorg.springframework.boot/groupId

artifactIdspring-boot-devtools/artifactId

scoperuntime/scope

optionaltrue/optional

/dependency

dependency

groupIdjectlombok/groupId

artifactIdlombok/artifactId

optionaltrue/optional

/dependency

dependency

groupIdorg.springframework.boot/groupId

artifactIdspring-boot-starter-test/artifactId

scopetest/scope

/dependency

/dependencies

/project

3、添加YAML配置文件

server:

port:9001

4、建立啟動(dòng)類

必須要加上@EnableHystrixDashboard注解激活

packagecom.zcl.springcloud;

importorg.springframework.boot.SpringApplication;

importorg.springframework.boot.autoconfigure.SpringBootApplication;

importflix.hystrix.dashboard.EnableHystrixDashboard;

*描述:儀表盤啟動(dòng)類

@SpringBootApplication

@EnableHystrixDashboard

publicclassHystrixDashboardMain9001{

publicstaticvoidmain(String[]args){

SpringApplication.run(HystrixDashboardMain9001.class,args);

}

5、啟動(dòng)項(xiàng)目

啟動(dòng)項(xiàng)目測(cè)試:http://localhost:901/hystrix

使用方法:在下面頁(yè)面中輸入需要進(jìn)行監(jiān)控的地址即可

斷路器演示監(jiān)控

監(jiān)控8001注意事項(xiàng)

1、必須要有如下的兩個(gè)依賴

!--web--

dependency

groupIdorg.springframework.boot/groupId

artifactIdspring-boot-starter-web/artifactId

/dependency

dependency

groupIdorg.springframework.boot/groupId

artifactIdspring-boot-starter-actuator/artifactId

/dependency

2、對(duì)啟動(dòng)類的修改

注意:新版本Hystrix需要在主啟動(dòng)類MainAppHystrix8001中指定監(jiān)控路徑,否則會(huì)出現(xiàn)報(bào)錯(cuò)

packagecom.zcl.springcloud;

importflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

importorg.springframework.boot.SpringApplication;

importorg.springframework.boot.autoconfigure.SpringBootApplication;

importorg.springframework.boot.web.servlet.ServletRegistrationBean;

importorg.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;

importflix.eureka.EnableEurekaClient;

importorg.springframework.context.annotation.Bean;

*描述:熔斷限流啟動(dòng)類

@SpringBootApplication

@EnableEurekaClient

@EnableCircuitBreaker

publicclassPaymentHystrixMain8001{

publicstaticvoidmain(String[]args){

SpringApplication.run(PaymentHystrixMain8001.class,args);

*此配置是為了服務(wù)監(jiān)控而配置,與服務(wù)容錯(cuò)本身無(wú)關(guān),springcloud升級(jí)后的坑

*ServletRegistrationBean因?yàn)閟pringboot的默認(rèn)路徑不是"/hystrix.stream",

*只要在自己的項(xiàng)目里配置上下面的servlet就可以了

@Bean

publicServletRegistrationBeangetServlet(){

HystrixMetricsStreamServletstreamServlet=newHystrixMetricsStreamServlet();

ServletRegistrationBeanregistrationBean=newServletRegistrationBean(streamServlet);

registrationBean.setLoadOnStartup(1);

registrationBean.addUrlMappings("/hystrix.stream");

registrationBean.setName("HystrixMetricsStreamServlet");

returnregistrationBean;

}

監(jiān)控測(cè)試

啟動(dòng)7001Eurek

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論