服务容错保护断路器Hystrix之四:断路器监控(Hystrix Dashboard)-turbine集群监控
turbine 英[ˈtɜ:baɪn] n. 汽轮机; 涡轮机; 透平机;
OK,上文我们看了一个监控单体应用的例子,在实际应用中,我们要监控的应用往往是一个集群,这个时候我们就得采取Turbine集群监控了。Turbine有一个重要的功能就是汇聚监控信息,并将汇聚到的监控信息提供给Hystrix Dashboard来集中展示和监控。那我们就来看看Turbine集群监控如何使用。本文通过引入Turbine来聚合ribbon-consumer服务的监控信息,并输出给hystrix dashboard来进行展示。
先上部署拓扑图:

构建turbine项目:
1、添加依赖,pom文件:主要是:spring-cloud-starter-turbine和spring-boot-starter-actuator
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.dxz.turbine</groupId>
<artifactId>turbine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>hystrix-dashboard</name>
<description>dashboard project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version> <!--配合spring cloud版本 -->
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<!--设置字符编码及java版本 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--增加turbine的依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--用于测试的,本例可省略 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <!--依赖管理,用于管理spring-cloud的依赖 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.SR3</version> <!--官网为Angel.SR4版本,但是我使用的时候总是报错 -->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <build>
<plugins>
<!--使用该插件打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
2、添加注解
启动类TurbineApplication
package com.dxz.turbine; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.turbine.EnableTurbine; @EnableTurbine
@EnableDiscoveryClient
@SpringBootApplication
public class TurbineApplication { public static void main(String[] args) {
SpringApplication.run(TurbineApplication.class, args);
}
}
3、修改配置 配置信息
spring.application.name=turbine
server.port=2260
management.port=8990 eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ turbine.app-config=ribbon-consumer
turbine.cluster-name-expression="default"
turbine.combine-host-port=true
其中说明:
1.turbine.app-config=ribbon-consumer指定了要监控的应用名字为ribbon-consumer
2.turbine.cluster-name-expression="default",表示集群的名字为default
3.turbine.combine-host-port=true表示同一主机上的服务通过host和port的组合来进行区分,默认情况下是使用host来区分,这样会使本地调试有问题
查看监控图
OK,监控服务创建成功之后,我们再次依次启动eureka-server、provider和consumer,其中consumer启动两个实例,两个实例的端口不一致,再分别启动hystrix-dashboard和turbine,
启动turbine项目,
http://127.0.0.1:2260/turbine.stream
将http://127.0.0.1:2260/turbine.stream填入dashboard里,
然后在hystrix监控地址栏输入如下地址(监控之前要记得先访问一下服务中的任意一个接口):http://localhost:2002/turbine...,访问结果如下:

结果:小伙伴们可以看到,集群下的主机报告一栏显示已经有所不同了。

与消息代理结合

详细见《spring cloud微服务实战》
2.2 turbine AMQP
在某些环境中(如在PaaS),典型的turbine模型的指标从所有分布式Hystrix命令不起作用。在这种情况下,你可能想要你Hystrix命令推动指标turbine,和spring cloud,就要使用AMQP消息传递。所有您需要做的是在客户端添加一个依赖spring-cloud-netflix-hystrix-amqp并确保代rabbitmq可用。(有关详细信息,请参阅弹簧引导文档如何配置客户端凭据,但它应该工作的当地代理或云计算)。
服务容错保护断路器Hystrix之四:断路器监控(Hystrix Dashboard)-turbine集群监控的更多相关文章
- SpringCloud学习笔记(16)----Spring Cloud Netflix之Hystrix Dashboard+Turbine集群监控
前言: 上一节中,我们使用Hystrix Dashboard,只能看到单个应用内的服务信息.在生产环境中,我们经常是集群状态,所以我们需要用到Turbine这一应用. 作用:汇总系统内的多个服务的数据 ...
- 断路器Hystrix与Turbine集群监控-Spring Cloud学习第三天(非原创)
文章大纲 一.Hystrix基础介绍二.断路器Hystrix简单使用三.自定义Hystrix请求命令四.Hystrix的服务降级与异常处理五.Hystrix的请求缓存与请求合并六.Hystrix仪表盘 ...
- Spring Cloud Hystrix Dashboard熔断器-Turbine集群监控(六)
序言 上一篇说啦hystrix的使用方法与配置还有工作流程及为何存在,我去,上一篇这么屌,去看看吧,没这么屌的话,我贴的有官方文档,好好仔细看看 hystrix除啦基本的熔断器功能之外,还可以对接口的 ...
- spring cloud: Hystrix(八):turbine集群监控(dashboard)
turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群, 因此可以通过turbine来监控集群下hystrix的metrics情况,通过eur ...
- 服务容错保护断路器Hystrix之三:断路器监控(Hystrix Dashboard)-单体监控
turbine:英 [ˈtɜ:baɪn] 美 [ˈtɜ:rbaɪn] n.汽轮机;涡轮机;透平机 一.Hystrix Dashboard简介 在微服务架构中为了保证程序的可用性,防止程序出错导致网络阻 ...
- SpringCloud (十) Hystrix Dashboard单体监控、集群监控、与消息代理结合
一.前言 Dashboard又称为仪表盘,是用来监控项目的执行情况的,本文旨在Dashboard的使用 分别为单体监控.集群监控.与消息代理结合. 代码请戳我的github 二.快速入门 新建一个Sp ...
- Spring Cloud第八篇 | Hystrix集群监控Turbine
本文是Spring Cloud专栏的第八篇文章,了解前七篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...
- 服务容错保护断路器Hystrix之五:配置
接着<服务容错保护断路器Hystrix之二:Hystrix工作流程解析>中的<2.8.关于配置>再列举重要的配置如下 一.hystrix在生产中的建议 1.保持timeout的 ...
- 服务容错保护断路器Hystrix之二:Hystrix工作流程解析
一.总运行流程 当你发出请求后,hystrix是这么运行的 红圈 :Hystrix 命令执行失败,执行回退逻辑.也就是大家经常在文章中看到的“服务降级”. 绿圈 :四种情况会触发失败回退逻辑( fal ...
随机推荐
- HPU组队赛L(没有标题。。)(贪心)
时间限制 1 Second 内存限制 512 Mb 题目描述 给个字符串s和整数k.(字符串中只有0-9) 问至少修改字符串中的几位才可以让字符串的各个位之和大于等于k. 输入 第一行一个整数T表 ...
- 51Nod 1007:正整数分组(01背包)
1007 正整数分组 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 将一堆正整数分为2组,要求2组的和相差最小. 例如:1 2 3 4 5,将1 ...
- A Spy in the Metro(UVA 1025 ACM/ICPC World Finals2003)
---恢复内容开始--- 题意:有n(2<=n<=50)个车站,从左到右编号为1~n,有M1辆列车从第1站向右开,还有M2辆列车从第N站向左开.在时刻0,间谍从第1站出发,目的是在时刻T( ...
- .Net Core开发环境迁移到Linux
.Net开发环境迁移到Linux上去 .Net Core发布之前,多年来,.Net程序员的开发环境都在Windows上. 三街第一帅的我,虽然上班的8小时一直在windows上撸C#,但是下班时间一般 ...
- LSOF查看linux中文件打开情况
如何查看linux中文件打开情况 前言 我们都知道,在linux下,“一切皆文件”,因此有时候查看文件的打开情况,就显得格外重要,而这里有一个命令能够在这件事上很好的帮助我们-它就是lsof. lin ...
- access-control-allow-origin
when use vastinspector to check our vast response ,it tiped : "no 'access-control-allow-origi ...
- day3 python学习
---恢复内容开始--- 运算 在Python中有很多种运算方法,我们在这里只是先说比较运算,逻辑运算,赋值运算,算数运算 在这里要记住 == 判断两个值是否相等 是比较运算符 >= 是否大 ...
- BizDevOps — the true value proposition of workflow engines
转自:https://blog.bernd-ruecker.com/bizdevops-the-true-value-proposition-of-workflow-engines-f342509ba ...
- IAR intrinsic functions
You can insert asm code example asm("NOP") into the c or c++ source code to get a good per ...
- 使用Managed Extensibility Framework方便的扩展应用程序
概述 Managed Extensibility Framework(MEF)是.NET平台下的一个扩展性管理框架,它是一系列特性的集合,包括依赖注入(DI)以及Duck Typing等.MEF为开发 ...