中華廚具網
    手機版    二維碼   標簽云  廚具企業大全

詳解斷路器監控和聚合監控

2024-05-14 11:42:06 來源:搜狐 作者/編輯: 瀏覽次數:3042 手機訪問 使用手機“掃一掃”以下二維碼,即可分享本文到“朋友圈”中。

詳解斷路器監控和聚合監控

2018-09-18 16:23來源:

原標題:詳解斷路器監控和聚合監控

今天我們深入學習斷路器監控hystrix dashboard,之前我們有過簡單的使用。在微服務架構中為例保證程序的可用性,防止程序出錯導致網絡阻塞,出現了斷路器模型。斷路器的狀況反應了一個程序的可用性和健壯性,它是一個重要指標。hystrix dashboard是作為斷路器狀態的一個組件,提供了數據監控和友好的圖形化界面。

一.準備工程

建議大家新建工程,因為這樣其他的單獨的服務只要進行了熔斷機制的,都可以在儀表盤上面去查看,此外,如果dashboard和被監控工程整合到了一起,即便配置feign.hystrix.enabled=true 也是檢測不到 feign 通道的數據的,在儀表盤界面一直是 loading。所以,如果使用feign ,建議dashboard成為獨立的項目。

1.創建hystrix-dashboard,引入依賴

!--客戶端負載均衡--

dependency

groupidorg.springframework.cloud/groupid

artifactidspring-cloud-starter-ribbon/artifactid

/dependency

!--eureka客戶端--

dependency

groupidorg.springframework.cloud/groupid

artifactidspring-cloud-starter-eureka/artifactid

/dependency

!--hystrix斷路器--

dependency

groupidorg.springframework.cloud/groupid

artifactidspring-cloud-starter-hystrix/artifactid

/dependency

dependency

groupidorg.springframework.boot/groupid

artifactidspring-boot-starter-actuator/artifactid

/dependency

!--hystrix斷路器儀表盤--

dependency

groupidorg.springframework.cloud/groupid

artifactidspring-cloud-starter-hystrix-dashboard/artifactid

/dependency

2.yml配置文件

eureka:

client:

serviceurl:

defaultzone:localhost:8761/eureka/

spring:

application:

name:hystrix-dashboard

server:

port:9000

3.創建一個consumercontroller控制器

@restcontroller

publicclassconsumercontroller{

@autowired

privateresttemplateresttemplate;

@hystrixcommand(fallbackmethod=defaultstores)

@getmapping(value=/hello)

publicstringhello(){

returnresttemplate.getforentity(eureka-client/,string.class).getbody();

}

publicstringdefaultstores(){

returnribbon+hystrixdashboard,提供者服務已失效;

}

}

4.啟動類上添加注解

@enablehystrix

@enablediscoveryclient

@enablehystrixdashboard

@springbootapplication

publicclassribbonconsumerapplication{

@loadbalanced

@bean

resttemplateresttemplate(){

returnnewresttemplate();

}

publicstaticvoidmain(string[]args){

springapplication.run(ribbonconsumerapplication.class,args);

}

}

5.啟動工程

拿出我們以前的小寶貝兒們,eureka-server,eureka-client,然后我們依次啟動他們,eureka-client記得至少要啟動兩個不同端口,最后啟動hystrix-dashboard。啟動好之后去localhost:8761看一下注冊有沒有成功。

訪問localhost:8766/hystrix.stream顯示

接下來我們就該訪問localhost:8766/hystrix.stream了,但是有的小伙伴會發生如下問題:

無限ping,這是為什么呢?是因為我們還沒有通過8766儀表盤訪問過兩個client,所以我們需要先訪問一下他們

接下來我們再去訪問localhost:8766/hystrix.stream

我們可以看到有大量數據了,這就說明我們剛剛已經成功調用了服務,并且監控已經記錄,現在我們需要去localhost:8766/hystrix輸入信息“localhost:8766/hystrix”,“2000”,“hi”。

點擊下面的monitor stream然后我們就能看到還算美觀的儀表盤界面:

說了這么多,他們都分別是什么意思呢,我們來看(嘔心力作之圖和一張實際生產的圖)。

以上便是hystrix dashboard的一個小詳解。

二.聚合監控 hystrix turbine

上邊我們講述了如何利用hystrix dashboard去監控斷路器的hystrix command。當我們有很多個服務的時候,看單個的hystrix dashboard的數據并沒有什么多大的價值,要聚合所以服務的hystrix dashboard的數據了。這就需要用到spring cloud的另一個組件了,即hystrix turbine。要想看這個系統的hystrix dashboard數據就需要用到hystrix turbine。hystrix turbine將每個服務hystrix dashboard數據進行了整合。

1.創建service-turbine,引入依賴

!--mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-turbine--

dependency

groupidorg.springframework.cloud/groupid

artifactidspring-cloud-starter-turbine/artifactid

version1.1.3.release/version

/dependency

dependency

groupidorg.springframework.boot/groupid

artifactidspring-boot-starter-actuator/artifactid

/dependency

2.在入口類serviceturbineapplication加上注解@enableturbine,開啟turbine,@enableturbine注解包含了@enablediscoveryclient注解,即開啟了注冊服務。

@enableturbine

@springbootapplication

publicclassserviceturbineapplication{

publicstaticvoidmain(string[]args){

springapplication.run(serviceturbineapplication.class,args);

}

}

3.配置文件application.yml

spring:

application.name:service-turbine

server:

port:8769

security:

basic:

enabled:false

turbine:

aggregator:

clusterconfig:default#指定聚合哪些集群,多個使用,分割,默認為default。

可使用.../turbine.stream?cluster={clusterconfig之一}訪問

appconfig:service-hi,service-lucy###配置eureka中的serviceid列表,

表明監控哪些服務

clusternameexpression:newstring(default)

#1.clusternameexpression指定集群名稱,默認表達式appname;

此時:turbine.aggregator.clusterconfig需要配置想要監控的應用名稱

#2.當clusternameexpression:default時,turbine.aggregator.clusterconfig可以不寫,

因為默認就是default

#3.當clusternameexpression:metadata['cluster']時,假設想要監控的應用配置了

eureka.instance.metadata-map.cluster:abc,則需要配置,同時

turbine.aggregator.clusterconfig:abc

eureka:

client:

serviceurl:

defaultzone:localhost:8761/eureka/

4.啟動工程

依次開啟eureka-server、service-hi、service-lucy、service-turbine工程。

打開瀏覽器輸入:localhost:8769/turbine.stream,界面如下

依次請求:

localhost:8762/hi?name=imooc

localhost:8763/hi?name=imooc

打開:localhost:8763/hystrix,輸入監控流localhost:8769/turbine.stream

可以看到這個頁面聚合了2個service的hystrix dashbord數據。

以上便是所有spring cloud中我所想分享給大家的內容,以這些知識作為鋪墊,祝大家的技術更上一層樓~感謝大家閱讀!

責任編輯:

聲明:該文觀點僅代表作者本人,搜狐號系信息發布平臺,搜狐僅提供信息存儲空間服務。

閱讀 ()

來源:搜狐

以上是網絡信息轉載,信息真實性自行斟酌。

 
本條標題:詳解斷路器監控和聚合監控
本條信息網址:
文本助手 資訊搜索 分享好友 打印本文 關閉窗口
閱讀關鍵詞
  • 手機瀏覽本文

    手機應用中掃描本文二維碼,即可瀏覽本文或分享到您的社交網絡中。

  • 微信公眾號

    掃描二維碼,關注中華廚具網微信公眾號,實時了解行業最新動態。

版權/免責聲明:
一、本文圖片及內容來自網絡,不代表本站的觀點和立場,如涉及各類版權問題請聯系及時刪除。
二、凡注明稿件來源的內容均為轉載稿或由企業用戶注冊發布,本網轉載出于傳遞更多信息的目的;如轉載稿涉及版權問題,請作者聯系我們,同時對于用戶評論等信息,本網并不意味著贊同其觀點或證實其內容的真實性。
三、轉載本站原創文章請注明來源:中華廚具網

0相關評論
今日熱點文章更多
品牌聚焦更多
推薦品牌更多
熱門頻道
關閉廣告
合作伙伴:
中華廚具網 魯ICP備2021046805號         魯公網安備 37162502000363號 (c)2018-2025SYSTEM All Rights Reserved 投資有風險 加盟需謹慎
關閉廣告
關閉廣告
精品999久久久久久中文字幕 | 久久亚洲美女精品国产精品| 新狼窝色AV性久久久久久| 国产精品久久影院| 亚洲Av无码国产情品久久| 久久99精品久久久久久久不卡| 亚洲国产天堂久久综合网站| 欧美国产成人久久精品| 97久久香蕉国产线看观看| 久久综合色老色| 99久久精品国产一区二区三区| 亚洲精品美女久久久久99| 狠狠色综合网站久久久久久久| 日产精品久久久久久久| 久久激情亚洲精品无码?V| 成人资源影音先锋久久资源网| 免费精品国产日韩热久久| 久久久这里有精品中文字幕| www.久久热.com| 婷婷五月深深久久精品| 亚洲人AV永久一区二区三区久久 | 久久精品中文字幕无码绿巨人| 国产精品99久久99久久久| 一本一本久久A久久综合精品| 国内精品久久久久久久久电影网| 青青热久久国产久精品 | 99久久国产综合精品麻豆| 欧美国产成人久久精品| 无码人妻久久一区二区三区蜜桃| 久久精品国产只有精品2020| 久久影院综合精品| 国产成人综合久久精品红| 久久亚洲国产最新网站| 亚洲国产精品综合久久一线| 热RE99久久精品国产66热| 日本亚洲色大成网站WWW久久| 精品无码久久久久久久久久| 精品人妻伦九区久久AAA片69| 超级碰久久免费公开视频| 久久狠狠一本精品综合网| 久久久久久国产精品美女|