SpringCloud学习(十五):Hystrix图形化Dashboard搭建与实战

SpringCloud学习(十五):Hystrix图形化Dashboard搭建与实战,第1张

SpringCloud学习(十五):Hystrix图形化Dashboard搭建与实战

目录

一、概述

二、 搭建

        1、新建模块

        2、修改pom文件

        3、编写yml文件

        4、编写主启动类(要加上@EnableHystrixDashboard注解)

        5、在所有微服务模块(8001、8002...)配置监控依赖

        6、运行

三、实战(监控8001模块) 

        1、在8001的主启动类中增加配置

        2、将8001的地址填写到豪猪哥中

        3、点击监控(Monitor Stream)

        4、监控界面如何看懂


 

一、概述

        除了隔离依赖服务的调用以外,Hystrix还提供了准实时的调用监控(Hystrix Dashboard),Hystrix会持续地记录所有通过Hystrix发起的请求的执行信息,并以统计报表和图形的形式展示给用户,包括每秒执行多少请求多少成功,多少失败等。Netflix通过hystrix-metrics-event-stream项目实现了对以上指标的监控。Spring Cloud也提供了Hystrix Dashboard的整合,对监控内容转化成可视化界面。

二、 搭建         1、新建模块

        新建普通maven模块 cloud-consumer-hystrix-dashboard9001

        2、修改pom文件


    
        cloud
        com.shang.cloud
        1.0-SNAPSHOT
    
    4.0.0

    cloud-consumer-hystrix-dashboard9001

    
        
            org.springframework.cloud
            spring-cloud-starter-netflix-hystrix-dashboard
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        

        
            org.springframework.boot
            spring-boot-devtools
            runtime
            true
        
        
            org.projectlombok
            lombok
            true
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    


    
        8
        8
    

        3、编写yml文件
server:
  port: 9001

        4、编写主启动类(要加上@EnableHystrixDashboard注解)
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardMain9001 {
    public static void main(String[] args) {
        SpringApplication.run(HystrixDashboardMain9001.class, args);
    }
}

        5、在所有微服务模块(8001、8002...)配置监控依赖

    org.springframework.boot
    spring-boot-starter-web

  

    org.springframework.boot
    spring-boot-starter-actuator

        6、运行

        浏览器地址栏输入        http://localhost:9001/hystrix

        显示出豪猪哥说明搭建成功

 

 

三、实战(监控8001模块)          1、在8001的主启动类中增加配置
    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadonStartup(1);
        registrationBean.addUrlMappings("/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }

        

        2、将8001的地址填写到豪猪哥中
http://localhost:8001/hystrix.stream

 

        3、点击监控(Monitor Stream)

        可以看到监控界面

        4、监控界面如何看懂

 

 

 

 

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5481735.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存