文章目录

  • 概述
  • Hystrix Dashboard
    • Step 1 新建项目
    • Step2 增加maven依赖
    • Step3 启动类增加注解@EnableHystrixDashboard
    • Step4 配置文件application.yml
    • Step5 启动微服务
    • Step6 测试
  • 代码

概述

Spring Cloud【Finchley】-11Feign项目整合Hystrix监控中,我们通过 http://ip:port/actuator/hystrix.stream 的形式来查看到的Hystrix的数据都是文本形式,可读性非常差。 好在Spring Cloud为我们提供了Hystrix Dashboard,来看下如何使用吧。

官方文档: https://cloud.spring.io/spring-cloud-static/Finchley.SR2/single/spring-cloud.html#_circuit_breaker_hystrix_dashboard


Hystrix Dashboard

为了方便统一管理,这里的例子我们也将Hystrix Dashboard这个微服务注册到Eureka上,当然了也可以不注册。


Step 1 新建项目

我们在父工程的maven上右键新建module , 起名为 micorservice-hystrix-dashboard

如下


Step2 增加maven依赖

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

我们打算注册到Eureka上,所以也需要添加spring-cloud-starter-netflix-eureka-client


Step3 启动类增加注解@EnableHystrixDashboard

同时我们也打算注册到Eureka上,所以也需要添加@EnableDiscoveryClient注解

package com.artisan.micorservice;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;@SpringBootApplication
@EnableDiscoveryClient
@EnableHystrixDashboard
public class MicorserviceMovieRibbonHystrixDashboard {public static void main(String[] args) {SpringApplication.run(MicorserviceMovieRibbonHystrixDashboard.class, args);}
}

Step4 配置文件application.yml

server:port: 8888spring:application:name: micorservice-hystrix-dashboard#eureka
eureka:client:service-url:defaultZone: http://artisan:artisan123@localhost:8761/eurekainstance:prefer-ip-address: true  # 起码点击后 会看到ip信息instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}

Step5 启动微服务

因为我们注册到了Eureka上,所以需要先启动microservice-discovery-eureka,然后再启动该服务,启动成功后,访问 http://localhost:8888/hystrix

Step6 测试

  • 继续启动服务提供者微服务 micorservice-provider-user,
  • 然后启动整合了Hystrix的消费者微服务 micorservice-consumer-movie-ribbon-hystrix 和 micorservice-consumer-movie-fegin-hystrix

到Eureka上看下注册的服务列表

micorservice-consumer-movie-fegin-hystrix 对应的hystrix url为:http://localhost:7901/actuator/hystrix.stream

micorservice-consumer-movie-ribbon-hystrix 对应的hystrix url为:
http://localhost:7902/actuator/hystrix.stream

分别输入url和自定义的title

点击Monitor Stream 进入, 一直处于loading状态

是因为还没有触发hystrix,我们来调用这俩微服务提供的对外接口

访问下 http://localhost:7901/movie/1 触发hystrix收集信息,多访问几次,信息如下

访问下 http://localhost:7902/movie/2 触发hystrix收集信息 ,多访问几次

以上就实现了通过Dashboard 对单个节点的微服务进行近乎实时的可视化监控。

上图中的参数说明参考官网 https://github.com/Netflix-Skunkworks/hystrix-dashboard/wiki:


代码

https://github.com/yangshangwei/SpringCloudMaster/tree/master/micorservice-hystrix-dashboard

Spring Cloud【Finchley】-12使用Hystrix Dashboard实现Hystrix数据的可视化监控相关推荐

  1. Spring Cloud Finchley OpenFeign的重试配置相关的坑

    如题,本文基于Spring Cloud Finchley.SR2 OpenFeign的重试 OpenFeign配置重试后,逻辑分析 对比Daltson和Finchley的基本组件,发现Ribbon还有 ...

  2. Spring Cloud学习笔记【十二】Hystrix的使用和了解

    Spring Cloud学习笔记[十二]Hystrix的使用和了解 Hystrix [hɪst'rɪks],中文含义是豪猪,因其背上长满棘刺,从而拥有了自我保护的能力.本文所说的Hystrix是Net ...

  3. SpringCloud (六) --------- Hystrix Dashboard 与 Hystrix Turbine

    目录 一. Hystrix Dashboard 搭建 Hystrix Dashboard 服务步骤 改造消费者项目 二.Spring Cloud Hystrix Turbine 搭建步骤 一. Hys ...

  4. Spring Boot+Spring Cloud基础入门(五)断路器——Hystrix

    Hystrix Hystrix翻译成中文是"豪猪",豪猪周身长满了刺,能保护自己不受天敌的伤害,代表了一种防御机制,这与Hystrix本身的功能不谋而合,因此Netflix团队将该 ...

  5. Spring Cloud Finchley版中Consul多实例注册的问题处理

    由于Spring Cloud对Etcd的支持一直没能从孵化器中出来,所以目前来说大多用户还在使用Eureka和Consul,之前又因为Eureka 2.0不在开源的消息,外加一些博眼球的标题党媒体使得 ...

  6. spring Cloud中,解决Feign/Ribbon整合Hystrix第一次请求失败的问题?

    Spring Cloud中,Feign和Ribbon在整合了Hystrix后,可能会出现首次调用失败的问题,要如何解决该问题呢? 造成该问题的原因 Hystrix默认的超时时间是1秒,如果超过这个时间 ...

  7. Spring Cloud Alibaba - 12 使用Nacos的元数据实现金丝雀发布功能

    文章目录 需求 改造 自定义规则 全局规则配置 配置文件 验证 源码 需求 新功能要上线了 , order-center 存在二个版本 V1(老版本) V2(新版本),product-center也存 ...

  8. Spring Cloud Finchley.SR1 的学习与应用 2 - Consul

    为什么80%的码农都做不了架构师?>>>    Spring Cloud Consul 简介 consul是google开源的一个使用go语言开发的服务发现.配置管理中心服务.内置了 ...

  9. Spring Cloud Alibaba - 20 Nacos StandAlone模式下的数据存储(Derby)及新增登录用户

    文章目录 StandAlone模式下的数据查看 (Derby) 新增登录用户 源码 StandAlone模式下的数据查看 (Derby) 这里我们以windos为例 温馨提示: 连接的时候,需要关闭n ...

最新文章

  1. pandas使用tabulate函数将pandas dataframe以类似于plsql表格的方式打印出来(printing dataframe in tabular format)
  2. Kubernetes 稳定性保障手册 -- 可观测性专题
  3. python——数据类型
  4. jsch 移动服务器上文件,jsch上传文件到服务器
  5. Struts2自定义标签——示例
  6. css 高度塌陷_web前端入门到实战:CSS 负边距的行为表现
  7. Java必备常用操作API
  8. 对话Google全球VP Jay Yagnik:TensorFlow2.0会强化可控性
  9. 南阳理工acm 15括号匹配(二)
  10. 微信怎么不支持华为鸿蒙,微信迟迟不加入鸿蒙,华为为何不着急呢?
  11. 两个方法告诉你如何将qlv格式的腾讯视频转换为mp4格式
  12. c语言abcd=(ab cd),汇编语言编程求具有abcd=(ab+cd)^2 性质的4 位数并输出。例如3025=(30+25)2。(不是C语言)...
  13. 苹果手机用计算机打不开,苹果手机更新ios11后,照片在电脑上打不开怎么办?...
  14. 清理了一毒窝,基本上能中的全中了
  15. 计算机局域网的组网,计算机局域网组网方案设计(精选).doc
  16. 顶尖量化私募“分家产”!学霸基金经理离职,代码产权归属成看点
  17. 离散数学——哈斯图,最大最小值,极大极小值,上界和下界
  18. 开放封闭原则_开放/封闭原则
  19. 解决,微信网页开发,网页授权域名数量不足问题
  20. 团队分工及团队贡献分的讨论

热门文章

  1. spark 提交任务到集群
  2. 成语json_cocos creator实战(2)成语小秀才ts版
  3. flask html 得到文本框 input的内容_【笔记7】HTML及其常见标签
  4. 不重复打印排序数组中相加和为给定值的所有二元组和三元组
  5. pytorch笔记——简易回归问题
  6. 【数学建模】线性代数知识汇总,参加建模大赛的小伙伴看过来,它会是你的最优选
  7. R语言实战应用精讲50篇(十九)-R语言gganimate函数应用案例:静态图变成动态,让你的图表更酷炫
  8. 深度学习核心技术精讲100篇(二十七)-如何利用NLP技术对ASR的query文本进行预处理纠错?
  9. MATLAB实战系列(四)-导入txt文件技巧大全
  10. 图像处理特征不变算子系列之KLT算子