SpringCloud入门(六): Hystrix监控
Hystrix.stream 监控
<!--. 配置pom文件,引入actuator包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency> <!- . 在Spring的启动入口添加@@EnableCircuitBreaker注解->
@SpringBootApplication
@EnableCircuitBreaker
public class EurekaConsumerApplication { public static void main(String[] args) {
SpringApplication.run(EurekaConsumerApplication.class, args);
}
} <!- . 引入HystrixMetricsStreamServlet->
@Configuration
public class HystrixConfig { @Bean
public ServletRegistrationBean getStreamServlet(){
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(); //系统启动时加载顺序
registrationBean.addUrlMappings("/hystrix.stream");//路径
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
}
通过http://localhost:8006/hystrix.stream访问。hystrix.stream界面简洁,但是显示不友好,不方便运维。

Dashboard监控
<!--1. 配置pom文件,引入dashboard包-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency> <!- 2. 在Spring的启动入口添加@EnableHystrixDashboard注解->
@SpringBootApplication
@EnableHystrixDashboard
public class EurekaConsumerApplication { public static void main(String[] args) {
SpringApplication.run(EurekaConsumerApplication.class, args);
}
}
通过http://localhost:8006/hystrix访问。dashboard 只能监控单个服务,对运维人员依旧不友好,只能监控单工程,不能查看历史

集群监控Turbian
<!--1. 配置pom文件,引入dashboard包-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency> <!- 2. 配置属性文件->
turbine.aggregator.cluster-config=default
turbine.app-config= ms-provider-order,ms-consumer-user
turbine.cluster-name-expression="'default'"
turbine.instanceUrlSuffix=hystrix.stream <!- 3. YML配置属性文件(只有yml生效,prop配置无效)->
turbine:
aggregator:
clusterConfig: default
appConfig: ms-consumer-user
cluster-name-expression: "'default'"
instanceUrlSuffix: hystrix.stream <!- 4. 在Spring的启动入口添加@EnableHystrixDashboard注解->
@SpringBootApplication
@EnableTurbine
public class EurekaConsumerApplication { public static void main(String[] args) {
SpringApplication.run(EurekaConsumerApplication.class, args);
}
}
通过http://localhost:8006/turbine.stream访问。我们可以通过dashboard对turbine.stream进行监控
备注:1)所有被监控的服务都需要配置Hystrix.stream监控,否则turbine识别不到。
2)instanceUrlSuffix的默认值为:actuator/hystrix.stream;这个属性来自SpringClusterMonitor这个类。如果不配置这个属性会抛出一个MisconfiguredHostException的404异常。
3)在为actuator包指定management.context-path=/xxx属性后也需要对instanceUrlSuffix做变更。


SpringCloud入门(六): Hystrix监控的更多相关文章
- springcloud 入门 11 (Hystrix Dashboard)
hystrix: 断路器我在前面已经介绍,不了解的可以参考 :springcloud 入门 6 (断路器hystrix) 关于搭建,测试我都在这里面进行说明了,这章介绍的是 Hystrix Das ...
- Spring Cloud(六):Hystrix 监控数据聚合 Turbine【Finchley 版】
Spring Cloud(六):Hystrix 监控数据聚合 Turbine[Finchley 版] 发表于 2018-04-17 | 更新于 2018-05-07 | 上一篇我们介绍了使用 H ...
- springcloud(八) Hystrix监控
一.Feign项目Hystrix自带的监控 在feign项目pom.xml 添加: <!-- 1,使用 Hystrix的模块 hystrix-metrics-event-stream,就可将这些 ...
- Spring Cloud 入门 之 Hystrix 篇(四)
原文地址:Spring Cloud 入门 之 Hystrix 篇(四) 博客地址:http://www.extlight.com 一.前言 在微服务应用中,服务存在一定的依赖关系,如果某个目标服务调用 ...
- SpringCloud(2)---SpringCloud入门篇
SpringCloud理解篇 一.微服务概述 1.什么是微服务 目前的微服务并没有一个统一的标准,一般是以业务来划分将传统的一站式应用,拆分成一个个的服务,彻底去耦合,一个微服务就是单功能业务,只做一 ...
- SpringCloud入门(一)
一.微服务概述 1.什么是微服务 目前的微服务并没有一个统一的标准,一般是以业务来划分将传统的一站式应用,拆分成一个个的服务,彻底去耦合,一个微服务就是单功能业务,只做一件事. 与微服务相对的叫巨石 ...
- Spring Cloud(五):Hystrix 监控面板【Finchley 版】
Spring Cloud(五):Hystrix 监控面板[Finchley 版] 发表于 2018-04-16 | 更新于 2018-05-10 | 在上一篇 Hystrix 的介绍中,我们提到 ...
- SpringCloud入门概述
SpringCloud入门概述 Spring的三大模块:SpringBoot(构建),Spring Cloud(协调),Spring Cloud Data Flow(连接)注意:Spring Boot ...
- SpringCloud学习之Hystrix
一.为什么要有断路器 在分布式系统当中,服务之间调用关系会随着业务的发展而变的复杂,一个服务可能依赖多个服务,服务之间层层依赖也是家常便饭的事情,如果一个服务的瘫痪很有可能导致整个系统的崩溃.比如说, ...
随机推荐
- java中集合,数组,字符串相互转换
数组转List String[] staffs = new String[]{"Tom", "Bob", "Jane"}; List sta ...
- Flume(三) —— 断点续传 与 事务
断点续传 # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe / ...
- (一)Thread的run() 和 start() 方法
Java多线程在实际开发中会遇到很多问题,对于这种争抢CPU时间片段的选手,我们或许有很多困惑,捉摸不透.即便如此,它也是可以被我们控制的. 最近在看Java多线程的书籍,里面有好多我曾经不怎么注意的 ...
- poj-3658 Artificial Lake(模拟)
http://poj.org/problem?id=3658 Description The oppressively hot summer days have raised the cows' cl ...
- 五、linux-mysql 下mysql的管理(二)
1.插入语句: create table test( id int(4) not null auto_increment, name char(20) not null, primary ...
- 40)PHP,mysql_fetch_row和mysql_fetch_array和mysql_fetch_assoc的区别
分析: mysql_fetch_row,这个函数是从结果集中取一行作为枚举数据,从和指定的结果标识关联的结果集中取得一行数据并作为数组返回.每个结果的列储存在一个数组的单元中,偏移量从 开始. 注意, ...
- getWeekDay TimeUtil
package me.zhengjie.common.utils; import java.util.Calendar; import java.util.Date; /** * @author ji ...
- signal之——异步回收机制2
前言:上一篇的处理方法可以解决所有回收问题,但是如果我们不考虑子进程的返回状态,那么可以使内核来进行对子进程的回收 代码如下: //如果无需关心进程结束状态 可以设置子进程结束时不产生僵尸进程有内核值 ...
- 洛谷-P3919-可持久化数组
题目传送门 sol:在洛谷上看到一种dfs + 离线的方法,可以解决大部分可持久化问题.把依赖关系看成边,然后建树.这样本来要解决的多个版本只要在一个版本上进行修改就好了. 离线 + dfs #inc ...
- 常用的mysql操作
总结一下常用的mysql操作,避免下次遇到类似情况重复地去百度. 方法不是唯一的,但记录一种可行的方法就可以了. 遇到新的问题再继续补充. 1.增加一个列 ALTER TABLE 表名 ADD COL ...