服务容错保护断路器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 ...
随机推荐
- 【湖南师范大学2018年大学生程序设计竞赛新生赛 L】【HDOJ2476】【区间DP】
https://www.nowcoder.com/acm/contest/127/L L 小小粉刷匠 题目描述 "lalala,我是一个快乐的粉刷匠",小名一边快活地唱着歌,一边开 ...
- if-else练习
练习1 import java.util.Scanner; public class V{ public static void main(String[] args){ Scanner s=new ...
- hdu4847 Wow! Such Doge! KMP
Chen, Adrian (November 7, 2013). “Doge Is An Ac- tually Good Internet Meme. Wow.”. Gawker. Retrieved ...
- JQuery中serialize()方法的使用
- Modularizing your graphQL schemas
转自: https://tomasalabes.me/blog/nodejs/graphql/2018/07/11/modularizing-graphql.html Modularizing you ...
- DevExpress DateEdit控件选择精确到秒
先看看下面的效果图: 设置以下属性 dateEdit1.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True; date ...
- vue 下实现 echarts 全国到省份的地图下钻
vue 下实现 echarts 全国到省份的地图下钻 项目地址:https://github.com/cag2050/vue_echarts_v3_demo
- Iris分类以及数组reshape想到的
最近在研究Iris花的逻辑回归分类中看到了如下的代码: from sklearn.linear_model import LogisticRegression X = iris["data& ...
- CentOS6.x 下安装Python pyyaml模块
Python中使用yaml时候,需要安装下组件pyyaml,直接安装pyyaml时提示“ext/_yaml.c:4:20: error: Python.h: No such file or direc ...
- LOJ 2586 「APIO2018」选圆圈——KD树
题目:https://loj.ac/problem/2586 只会 19 分的暴力. y 都相等,仍然按直径从大到小做.如果当前圆没有被删除,那么用线段树把 [ x-r , x+r ] 都打上它的标记 ...