hystrix-bashboard 的監控

1. 新建一個maven項目--導入依賴

<dependency>

    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
    <version>1.4.6.RELEASE</version>
</dependency>

 

2.設置端口號:

#配置項目端口號
server:
  port: 9001

3.在啓動類上開啓監控

@SpringBootApplication
@EnableHystrixDashboard //開啓監控
public class DeptComsumerDashboard_9001 {

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

以上基本完成監控,可以去 http://localhost:端口號/hystrix,如果出現以下畫面,說明成功一半了

2大類,去哪監控 如服務端監控

1.在服務端一定要添加監控的依賴
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

3.在服務端的啓動類上添加寫死的bean

@Bean
public ServletRegistrationBean hystrixMetricsStreamServlet(){
    ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
    servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");
    return servletRegistrationBean;

}

3.localhost:服務器的端口號/actuator/hystrix.stream ,將其複製到

 

4.添加delay時間,和title主題,然後點擊monitor stream 進入頁面

5.隨意的訪問服務端的各個接口,觀察其變化⚪,和對應的顏色

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章