Spring Cloud【Finchley】-10Hystrix监控
文章目录
- 概述
- 监控Hystrix
- 步骤
- Step1 添加spring-cloud-starter-netflix-hystrix依赖
- Step2 添加spring-boot-starter-actuator依赖
- Step3 application.yml开启监控端点
- Step4 测试
- 代码
概述
Hystrix除了提供容错外,还提供了功能近乎实时的监控。HystrixCommand和HystrixObservableCommand在执行时,会生成执行结果和运行指标。
监控Hystrix
Hystrix的hystrix-metrics-event-stream模块 将监控信息以text/event-stream的格式暴露给外部系统。添加 spring-cloud-starter-netflix-hystrix依赖后,我们看下pom的依赖关系,如下图,可以知道 spring-cloud-starter-netflix-hystrix已经包含了该模块。
这样的话,只需要添加spring-boot-starter-actuator即可,就可以使用 /actuator/hystrix.stream端点来获取Hystrix的监控信息了。
步骤
我们用 上一篇 Spring Cloud【Finchley】-08使用Hystrix实现容错中的示例来演示下如何监控Hystrix. 该工程已经能够满足我们上面说的监控Hystrix的条件
Step1 添加spring-cloud-starter-netflix-hystrix依赖
- spring-cloud-starter-netflix-hystrix(包含了hystrix-metrics-event-stream)
Step2 添加spring-boot-starter-actuator依赖
- spring-boot-starter-actuator
Step3 application.yml开启监控端点
- application.yml 中 配置信息开启了所有的监控端点
#actuator 启用所有的监控端点 “*”号代表启用所有的监控端点,可以单独启用,例如,health,info,metrics
# spring boot 升为 2.0 后,为了安全,默认 Actuator 只暴露了2个端点,heath 和 info,继续
# 访问 http://192.168.1.103:7902/actuator/metrics
management:endpoints:web:exposure:include: "*" endpoint:health:show-details: ALWAYS
Step4 测试
- 启动microservice-discovery-eureka,注册中心
- 启动micorservice-provider-user,服务提供者
- 启动micorservice-consumer-movie-ribbon-hystrix,服务消费者,整合了Hystrix , 端口 7902
- 访问 http://localhost:7902/actuator/hystrix.stream ,如下
一直处于ping 请求状态,是因为micorservice-consumer-movie-ribbon-hystrix中注解了@HystrixCommand的方法还未被执行,没有产生监控数据,
- 访问@HystrixCommand注解标注的方法 ,请求 http://localhost:7902/movie/4 ,重新去 http://localhost:7902/actuator/hystrix.stream 观察下,如下
重复出现类似的内容,是因为系统会不断的刷新以便可以获取实时的监控数据,包括HystrixCommand的名称、group名称、断路器名称、错误率、错误数等
代码
https://github.com/yangshangwei/SpringCloudMaster/tree/master/micorservice-consumer-movie-ribbon-hystrix
Spring Cloud【Finchley】-10Hystrix监控相关推荐
- Spring Cloud Sleuth + Zipkin 监控微服务(一)
在之前搭建的服务注册中心的基础上,结合Spring Cloud Sleuth + Zipkin 监控微服务. 1.Zipkin server 从https://dl.bintray.com/openz ...
- Spring Cloud Finchley OpenFeign的重试配置相关的坑
如题,本文基于Spring Cloud Finchley.SR2 OpenFeign的重试 OpenFeign配置重试后,逻辑分析 对比Daltson和Finchley的基本组件,发现Ribbon还有 ...
- Spring Cloud Finchley版中Consul多实例注册的问题处理
由于Spring Cloud对Etcd的支持一直没能从孵化器中出来,所以目前来说大多用户还在使用Eureka和Consul,之前又因为Eureka 2.0不在开源的消息,外加一些博眼球的标题党媒体使得 ...
- Spring Cloud Finchley.SR1 的学习与应用 2 - Consul
为什么80%的码农都做不了架构师?>>> Spring Cloud Consul 简介 consul是google开源的一个使用go语言开发的服务发现.配置管理中心服务.内置了 ...
- Spring Cloud 入门——6.1 Turbine 集群数据监控
代码信息 本篇文章涉及代码版本 组件 版本 Spring Boot 2.0.8.RELEASE Spring Cloud Finchley.SR1 本篇文章涉及应用 应用 说明 base-eureka ...
- Spring Cloud【Finchley】- 21 Spring Cloud Stream 构建消息驱动微服务
文章目录 概述 添加依赖 配置文件配置RabbitMQ的地址信息 接口定义 接收方 @EnableBinding @StreamListener 测试 消费组 发送复杂对象 消息回执 代码 概述 官网 ...
- Spring Cloud【Finchley】实战-01注册中心及商品微服务
文章目录 Spring Cloud[Finchley]专栏 概述 版本说明 搭建Eureka Server注册中心 工程结构 Step1. pom添加依赖 Step2.application.yml ...
- Spring Boot(2.1.2.RELEASE) + Spring Cloud (Finchley.RELEASE)搭建服务注册和发现组件Eureka
前言:由于版本原因,部分关于Spring Cloud的书中使用的是Spring Boot 1.x 版本,很多配置或名称在新版本中已经发生了改变.此篇文章记录的是使用较新的Spring Boot 2.x ...
- Spring Cloud 升级最新 Finchley 版本,踩了所有的坑
转载自 Spring Cloud 升级最新 Finchley 版本,踩了所有的坑 Spring Boot 2.x 已经发布了很久,现在 Spring Cloud 也发布了 基于 Spring Bo ...
- hystrix 全局熔断_跟我学Spring Cloud(Finchley版)14Feign使用Hystrix
Feign默认已经整合了Hystrix,本节详细探讨Feign使用Hystrix的具体细节. 服务降级 1 加配置,默认Feign是不启用Hystrix的,需要添加如下配置启用Hystrix,这样所有 ...
最新文章
- linux批量umount脚本,Linux下批量ping某个网段ip的脚本
- 深度学习——自动编码器,对称网络结构
- vundle按照YouComplete
- SAP Spartacus名为Configuration的injection token
- Git 远程配置_03
- Oracle :备份 、还原数据库
- 非结构化商业文本中隐私信息识别-第2名方案(含数据)
- Logstash实践: 分布式系统的日志监控
- 华为 EC169 3G上网卡在MacPro中的使用
- vmware之VMware Remote Console (VMRC) SDK(一)
- python 定时任务 全局变量_APScheduler-Python定时任务
- h5 video标签
- STM32 Simulink 自动代码生成电机控制——脉振高频注入
- android uikit框架详解,UIKit框架(2)框架简介
- 网页中在线玩街头霸王
- java synchronized_Java中synchronized关键字理解
- mysql 百分比两位小数_SQL中如何让百分比后面保留2位小数?
- 万豪国际成立全球清洁卫生委员会,推行更高标准清洁消毒措施
- 陶泓达:周五黄金原油白银走势分析及操作建议
- 网页HTML5--飞机大战小游戏开发--canvas的应用