前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Hystrix:dashboard监控页面

Hystrix:dashboard监控页面

作者头像
暴躁的程序猿
发布2022-03-24 15:37:58
4360
发布2022-03-24 15:37:58
举报
文章被收录于专栏:阿飞的学习记录

第一步 创建一个监控页面的module

第二部 导入所需要的依赖

代码语言:javascript
复制
  <dependencies>
        <!--hystrix依赖-->
        <!--导入hystrix依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <!--hystrix监控页面依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.rpf</groupId>
            <artifactId>springcloud-api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--热部署-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <!--集成Ribbon-->
        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-ribbon -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-ribbon</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
        <!--需要Eureka发现服务-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>
    </dependencies>

第三步 配置yml文件

在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
server:
  port: 9000

启动类上开启监控页面注解

代码语言:javascript
复制
@SpringBootApplication
@EnableHystrixDashboard//开启监控页面
public class DeptConsumerDashboard_9000 {
    public static void main(String[] args) {
        SpringApplication.run(DeptConsumerDashboard_9000.class,args);
    }
}

第四步 确保服务提供方pom依赖加入了监控信息的依赖

在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
  <!--添加监控信息-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

开启启动类 访问地址http://localhost:9000/hystrix 即可得到以下界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

这个时候我们需要在服务提供方注册一些监控信息 服务提供方需要导入hystrix的依赖

代码语言:javascript
复制
 <!--hystrix-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
            <version>1.4.6.RELEASE</version>
        </dependency>

在服务提供者的启动类中注入一个bean

代码语言:javascript
复制
//启动类
@EnableEurekaClient//在服务启动后自动注册到Eureka服务端
@SpringBootApplication
@EnableDiscoveryClient//服务发现
public class DeptProvider_8001 {
    public static void main(String[] args) {
        SpringApplication.run(DeptProvider_8001.class,args);
    }

    //增加servlet
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean= new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");//添加一个访问的路径
       return registrationBean;
    }
}

启动 注册中心 , 服务提供方 , 监控moudle 访问下方路径 看是否有数据

在这里插入图片描述
在这里插入图片描述

有数据监控成功 访问这个监控页面路径

代码语言:javascript
复制
http://localhost:9000/hystrix

输入配置刚才访问的路径

在这里插入图片描述
在这里插入图片描述

即可看到监控数据

在这里插入图片描述
在这里插入图片描述

这个圆圈代表健康程度 绿色 黄色 橙色 红色 依次代表健康程度递减 流量越大 圆也越大

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/05/25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
微服务引擎 TSE
微服务引擎(Tencent Cloud Service Engine)提供开箱即用的云上全场景微服务解决方案。支持开源增强的云原生注册配置中心(Zookeeper、Nacos 和 Apollo),北极星网格(腾讯自研并开源的 PolarisMesh)、云原生 API 网关(Kong)以及微服务应用托管的弹性微服务平台。微服务引擎完全兼容开源版本的使用方式,在功能、可用性和可运维性等多个方面进行增强。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档