栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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、监控界面如何看懂

 

 

 

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/489608.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号