SpringCloud学习笔记(十一)_Hystrix仪表盘

我们来看一下如何使用它吧

1.引入依赖
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  

|

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

—|—

hystrix依赖主要是hystrix核心功能依赖,dashboard是为我们提供仪表盘面板的页面功能的,actuator是用来暴露dashboard所需要的端口的。

2.启用hystrix仪表盘

在启动类增加注解@EnableHystrixDashboard。

1  
2  
3  
4  
5  

|

@SpringBootApplication  
@EnableEurekaClient  
@EnableHystrixDashboard  
@EnableFeignClients  
@EnableHystrix  

—|—

3.修改actuator配置

默认的时候actuator是没有开启hystrix的端口的,所以我们需要在配置文件中增加一些配置来开启这个端口。

1  
2  
3  
4  
5  
6  
7  
8  

|

management:  
  endpoints:  
    web:  
      exposure:  
        include: '*'  
feign:  
  hystrix:  
    enabled: true  

—|—

上方的配置如果不明白的话可以参考:SpringCloud监控

4.使用

访问ip:端口/hystrix,我们可以看到如下界面
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZjI3lb90-1693123362901)(http://zhixiang.org.cn/2018/11/17/%E6%AF%8F%E5%A4%A9%E5%AD%A6%E7%82%B9SpringCloud%EF%BC%88%E5%8D%81%E4%B8%80%EF%BC%89%EF%BC%9AHystrix%E4%BB%AA%E8%A1%A8%E7%9B%98/1.png)]
这个是Dashboard的欢迎页面,第一个文本框是hystrix监控页面的地址。此地址默认是/hystrix.stream,然后还会被actuator的路径所影响,比如说,我的actuator默认路径/actuator,所以我输入访问地址为: ip:端口/actuator/hystrix.stream。
第二个文本框为间隔更新数据时间,第三个是此次监控起的一个名字。

上方信息输入完成后点击monitor后我们就可以看到文章开头图片描述的页面了。

GitHub地址:https://github.com/shiyujun/spring-cloud-demo。代码所在模块:cloud-demo-consumer-feign-hystrix

如果对您有所帮助,请记得帮忙点一个star哦

本文出自http://zhixiang.org.cn,转载请保留。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值