springcloud(六):熔断监控Turbine
在复杂的分布式系统中,相同服务的节点经常需要部署上百甚至上千个,很多时候,运维人员希望能够把相同服务的节点状态以一个整体集群的形式展现出来,这样可以更好的把握整个系统的状态。 为此,Netflix提供了一个开源项目(Turbine)来提供把多个hystrix.stream的内容聚合为一个数据源供Dashboard展示。愿意了解源码的朋友直接求求交流分享技术:二一四七七七五六三三
1、添加依赖
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-turbine</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-hystrix-dashboard</artifactId> </dependency> </dependencies>
2、配置文件
spring.application.name=hystrix-dashboard-turbine server.port=8001 turbine.appConfig=node01,node02 turbine.aggregator.clusterConfig= default turbine.clusterNameExpression= new String("default") eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
turbine.appConfig :配置Eureka中的serviceId列表,表明监控哪些服务
turbine.aggregator.clusterConfig :指定聚合哪些集群,多个使用”,”分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问
turbine.clusterNameExpression : 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称;2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default;3. 当clusterNameExpression: metadata[‘cluster’]时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC
3、启动类
启动类添加@EnableTurbine,激活对Turbine的支持
@SpringBootApplication @EnableHystrixDashboard @EnableTurbine public class DashboardApplication { public static void main(String[] args) { SpringApplication.run(DashboardApplication.class, args); } }
到此Turbine(hystrix-dashboard-turbine)配置完成
4、测试
在示例项目spring-cloud-consumer-hystrix基础上修改为两个服务的调用者spring-cloud-consumer-node1和spring-cloud-consumer-node2
spring-cloud-consumer-node1项目改动如下: application.properties文件内容
spring.application.name=node01 server.port=9001 feign.hystrix.enabled=true eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
spring-cloud-consumer-node2项目改动如下: application.properties文件内容
spring.application.name=node02 server.port=9002 feign.hystrix.enabled=true eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
HelloRemote类修改:
@FeignClient(name= "spring-cloud-producer2", fallback = HelloRemoteHystrix.class) public interface HelloRemote { @RequestMapping(value = "/hello") public String hello2(@RequestParam(value = "name") String name); }
对应的HelloRemoteHystrix和ConsumerController类跟随修改,具体查看代码
修改完毕后,依次启动spring-cloud-eureka、spring-cloud-consumer-node1、spring-cloud-consumer-node1、hystrix-dashboard-turbine(Turbine)
打开eureka后台可以看到注册了三个服务:
访问 http://localhost:8001/turbine.stream
返回:
: ping data: {"reportingHostsLast10Seconds":1,"name":"meta","type":"meta","timestamp":1494921985839}
并且会不断刷新以获取实时的监控数据,说明和单个的监控类似,返回监控项目的信息。进行图形化监控查看,输入:http://localhost:8001/hystrix,返回酷酷的小熊界面,输入: http://localhost:8001/turbine.stream,然后点击 Monitor Stream ,可以看到出现了俩个监控列表
整体代码结构如下:资料和源码来源

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
springcloud(五):熔断监控Hystrix Dashboard
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine.愿意了解源码的朋友直接求求交流分享技术:二一四七七七五六三三 Hystrix Dashboard我们在熔断示例项目spring-cloud-consumer-hystrix的基础上更改,重新命名为:spring-cloud-consumer-hystrix-dashboard。 1、添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId&g...
- 下一篇
dba+工具:PT-kill重构版,慢SQL报警及扼杀利器
/** * Percona PT-kill重构版(PHP) * https://github.com/hcymysql/pt-kill * * UPDATE: * Modified by: hcymysql 2018/11/27 * 1、增加慢SQL邮件报警功能 * 2、增加慢SQL微信报警功能 * * 环境准备: * shell> yum install -y php-process php php-mysql * */ 概述 原生Percona版PT-kill(Perl)工具只是单纯地KILL掉正在运行中的慢SQL,而不能作为一个监控工具使用,例如缺少邮件报警或者微信报警功能,固需要将其重构。 重构版PT-kill(PHP)从information_schema.PROCESSLIST表中捕获正在运行中的SELECT|ALTER等DML/DDL消耗资源过多的查询,过滤它们,然后杀死它们(可选择不杀),并且发邮件/微信报警给DBA和相关开发知悉,避免因慢SQL执行时间过长对数据库造成一定程度的伤害。(注:慢SQL执行完才记录到slow.log里,执行过程中不记录。) 使用方法和...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Red5直播服务器,属于Java语言的直播服务器
- CentOS8编译安装MySQL8.0.19
- CentOS7,8上快速安装Gitea,搭建Git服务器
- CentOS7安装Docker,走上虚拟化容器引擎之路
- CentOS7,CentOS8安装Elasticsearch6.8.6
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程