SpringCloud學習筆記(15)----Spring Cloud Netflix之Hystrix Dashboard的使用


 1. 引入依賴

  在前面幾節中的消費者中添加pom依賴。  

 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency>

2. 在啟動類上添加注解

  添加@EnableHystrixDashboard 開啟Dashboard。

3. 注冊HystrixMetricsStreamServlet

  在2.x之前的版本中,會自動注入該Servlet的,但是在2.x之后的版本,沒有自動注冊該Servlet。看源碼的解釋。

  

  所以這里需要我們手動的注冊該Servlet到容器中,代碼如下:

  

 
  /** * 配置Hystrix.stream的servlet * @return */ @Bean public ServletRegistrationBean registrationBean() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
 

  訪問http://localhost:9999/hystrix 這里是你部署dashboard服務的地址和端口,會出現如下所示界面:

  

  這里是在你需要監控的路徑后面跟上/hystrix.stream,就可以自動ping目標服務器的信息。

  點擊Monitor Stream 按鈕,出現如下面板:

  由於這里的斷路器采用的策略是信號量的,所以沒有線程池的信息,如果使用的是線程池策略,這里將會出現線程池的相關信息。

  面板每個指標所代表的意義:

   

 

原文 SpringCloud學習筆記(15)----Spring Cloud Netflix之Hystrix Dashboard的使用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM