Hystrix進階攻略之dashboard監控面板

一、介紹

The Hystrix Dashboard allows you to monitor Hystrix metrics in real time.

netflix開始用這個dashboard的時候,大幅度優化了工程運維的操作,幫助節約了恢復系統的時間。大多數生產系統的故障持續時間變得很短,而且影響幅度小了很多,主要是因為hystrix dashborad提供了可視化的監控。

The Hystrix Dashboard allows you to monitor a single server or a cluster of servers aggregated using Turbine, with low latency (typically around 1 or 2 seconds when aggregating a cluster, subsecond with a single server).

二、SpringBoot項目配置

基礎項目:基於上節課講的項目進行講解

代碼下載地址:https://gitee.com/jikeh/JiKeHCN-RELEASE.git

項目名:spring-boot-hystrix-dashboard

1、添加流監控依賴

<dependency>
<groupid>com.netflix.hystrix/<groupid>
<artifactid>hystrix-metrics-event-stream/<artifactid>
<version>1.4.10/<version>
/<dependency>

<dependency>
<groupid>com.fasterxml.jackson.core/<groupid>
<artifactid>jackson-core/<artifactid>
<version>2.9.6/<version>
/<dependency>

2、新增一個servlet註冊器

@Bean
public ServletRegistrationBean indexServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
//這個與turbine項目(後面會介紹)中的config.properties路徑配置是對應的
registration.addUrlMappings("/hystrix.stream");
return registration;

}

三、hystrix-dashboard項目安裝與配置

1、下載hystrix-dashboard的war包:

https://search.maven.org/remotecontent?filepath=com/netflix/hystrix/hystrix-dashboard/1.5.12/hystrix-dashboard-1.5.12.war

2、下載turbin:

https://github.com/downloads/Netflix/Turbine/turbine-web-1.0.0.war

3、重命名兩個war包

hystrix-dashboard-1.5.12.war——hystrix-dashboard.war

turbine-web-1.0.0.war——turbine.war

4、修改turbine.war增加一個配置文件

用360解壓軟件直接打開war包,新增配置文件,保存即可

在/WEB-INF/classes下,新增配置文件:config.properties

turbine.ConfigPropertyBasedDiscovery.default.instances=localhost

turbine.instanceUrlSuffix=:2222/hystrix.stream

註釋:這裡的端口號是你的項目名裡面的端口,這裡可不是隨意配置的哈

4、將兩個war包拷貝到Tomcat的D:\jikesoft\Tomcat 8.5\webapps目錄中

Hystrix進階攻略之dashboard監控面板

5、啟動Tomcat

啟動tomcat:hystrix dashboard和turbin

6、訪問測試

http://localhost:8080/hystrix-dashboard

前提:http://localhost:2222/hystrix.stream這個項目已經運行起來了

運行成功後的截面圖:

Hystrix進階攻略之dashboard監控面板

1)單節點監控

  • 配置
Hystrix進階攻略之dashboard監控面板

  • http://localhost:2222/hystrix.stream
  • 實時監控圖
Hystrix進階攻略之dashboard監控面板

2)集群監控

  • 配置
Hystrix進階攻略之dashboard監控面板

  • http://localhost:8080/turbine/turbine.stream
  • 實時監控圖

當然了,我們這裡只有1臺機器,我們看到的效果和上面是一樣的

Hystrix進階攻略之dashboard監控面板

3)界面參數含義說明

先來張圖:

Hystrix進階攻略之dashboard監控面板

  • 圓圈的顏色和大小代表了健康狀況以及流量
  • 折線代表了最近2分鐘的請求流量
  • 集群中的機器數量,請求延時的中位數以及平均值
  • 最近10秒內的異常請求比例,請求QPS,每臺機器的QPS,以及整個集群的QPS
  • 斷路器的狀態
  • When a “circuit” is failing it changes colors (on a gradient from green through yellow, orange, and red) like this:
Hystrix進階攻略之dashboard監控面板

  • 最近一分鐘的請求延時百分比,TP90,TP99,TP99.5
  • 幾個有顏色的數字,代表了最近10秒鐘的統計,以1秒鐘為粒度
  • 成功的請求數量,綠顏色的數字;
  • 短路的請求數量,藍色的數字;
  • timeout超時的請求數量,黃色的數字; 線程池reject的請求數量,紫色的數字;
  • 請求失敗,拋出異常的請求數量,紅色的數字

四、項目實戰應用hystrix-dashboard

依賴系統:spring-boot-hystrix-ad

本次系統:spring-boot-hystrix-dashboard

1、請求單個廣告

觀察hystrix-dashboard的變化

http://localhost:2222/get/ad?adId=1

2、批量請求廣告

觀察hystrix-dashboard的變化

http://localhost:2222/get/ads?adIds=1,2,3,4,5,6


分享到:


相關文章: