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集群监控的更多相关文章

  1. SpringCloud学习笔记(16)----Spring Cloud Netflix之Hystrix Dashboard+Turbine集群监控

    前言: 上一节中,我们使用Hystrix Dashboard,只能看到单个应用内的服务信息.在生产环境中,我们经常是集群状态,所以我们需要用到Turbine这一应用. 作用:汇总系统内的多个服务的数据 ...

  2. 断路器Hystrix与Turbine集群监控-Spring Cloud学习第三天(非原创)

    文章大纲 一.Hystrix基础介绍二.断路器Hystrix简单使用三.自定义Hystrix请求命令四.Hystrix的服务降级与异常处理五.Hystrix的请求缓存与请求合并六.Hystrix仪表盘 ...

  3. Spring Cloud Hystrix Dashboard熔断器-Turbine集群监控(六)

    序言 上一篇说啦hystrix的使用方法与配置还有工作流程及为何存在,我去,上一篇这么屌,去看看吧,没这么屌的话,我贴的有官方文档,好好仔细看看 hystrix除啦基本的熔断器功能之外,还可以对接口的 ...

  4. spring cloud: Hystrix(八):turbine集群监控(dashboard)

    turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群, 因此可以通过turbine来监控集群下hystrix的metrics情况,通过eur ...

  5. 服务容错保护断路器Hystrix之三:断路器监控(Hystrix Dashboard)-单体监控

    turbine:英 [ˈtɜ:baɪn] 美 [ˈtɜ:rbaɪn] n.汽轮机;涡轮机;透平机 一.Hystrix Dashboard简介 在微服务架构中为了保证程序的可用性,防止程序出错导致网络阻 ...

  6. SpringCloud (十) Hystrix Dashboard单体监控、集群监控、与消息代理结合

    一.前言 Dashboard又称为仪表盘,是用来监控项目的执行情况的,本文旨在Dashboard的使用 分别为单体监控.集群监控.与消息代理结合. 代码请戳我的github 二.快速入门 新建一个Sp ...

  7. Spring Cloud第八篇 | Hystrix集群监控Turbine

    ​ 本文是Spring Cloud专栏的第八篇文章,了解前七篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...

  8. 服务容错保护断路器Hystrix之五:配置

    接着<服务容错保护断路器Hystrix之二:Hystrix工作流程解析>中的<2.8.关于配置>再列举重要的配置如下 一.hystrix在生产中的建议 1.保持timeout的 ...

  9. 服务容错保护断路器Hystrix之二:Hystrix工作流程解析

    一.总运行流程 当你发出请求后,hystrix是这么运行的 红圈 :Hystrix 命令执行失败,执行回退逻辑.也就是大家经常在文章中看到的“服务降级”. 绿圈 :四种情况会触发失败回退逻辑( fal ...

随机推荐

  1. 《DSP using MATLAB》Problem 5.19

    代码: function [X1k, X2k] = real2dft(x1, x2, N) %% --------------------------------------------------- ...

  2. linux----磁盘介绍

    1.磁盘简图: 2.常见分区 mbr:主引导区,共512byte 扩展分区 逻辑分区

  3. codeforce 804B Minimum number of steps

    cf劲啊 原题: We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each ...

  4. 文件I/0缓冲

    设置stdio流缓冲模式 #include<stdio.h> int setvbuf(FILE *stream,char *buf,int mode,size_t size) int se ...

  5. 基于lfslivecd-x86-6.3-r2145安装vnc和qemu

    文章目录 把lfslivecd复制到硬盘上使用 编译安装vnc 前后下载了多个软件包进行编译安装 编译VNC 启动VNC 编译安装qemu 启动VNC客户端并连接虚拟机的vncviewer 把lfsl ...

  6. Module Sources

    转自:https://www.terraform.io/docs/modules/sources.html 主要记录module source 的格式 The source argument in a ...

  7. vernemq 集群 docker-compose 搭建简单试用

    vernemq 是一款开源的mqtt broker, 支持cluster 模式部署,而且部署比较简单 以下是一个使用docker-compose 搭建环境的demo 环境准备 docker-compo ...

  8. 互换元素(swap,swap_ranges)

    swap template <class Assignable> void swap(Assignable &a,Assignable &b); iter_swap tem ...

  9. ML(5)——神经网络3(随机初始化与梯度检验)

    随机初始化 在线性回归和逻辑回归中,使用梯度下降法之前,将θ设置为0向量,有时会习惯性的将神经网络中的权重全部初始化为0,然而这在神经网络中并不适用. 以简单的三层神经网络为例,将全部权重都设置为0, ...

  10. MySQL中如何实现 select top n

    mysql 没有 top n 语法,mysql 用 limit 来实现相关功能,而且功能更加强大. 语法: SELECT * FROM table LIMIT [offset,] rows | row ...