Hystrix Dashboard

Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。

添加依赖

我们新建一个工程 spring-cloud-consul-monitor,修改 pom 文件,添加相关依赖。

pom.xml

    <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
</dependencies>

启动类

在启动类中添加注解 @EnableHystrixDashboard 开启熔断监控支持。

ConsuleMonitorApplication.java

package com.louis.spring.cloud.consul.monitor;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; @EnableHystrixDashboard
@SpringBootApplication
public class ConsuleMonitorApplication { public static void main(String[] args) {
SpringApplication.run(ConsuleMonitorApplication.class, args);
}
}

修改配置

修改配置文件,配置启动端口和应用名称。

application.yml

server:
port: 8531
spring:
application:
name: spring-cloud-consul-monitor

配置监控路径

注意,如果你使用的是2.x等比较新的版本,需要在 Hystrix 的消费端配置监控路径,我们这里消费端是 spring-cloud-consul-consumer, 所以修改它的启动类。

ConsuleConsumerApplication.java

    // 此配置是为了服务监控而配置,与服务容错本身无关,
// ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
// 只要在自己的项目里配置上下面的servlet就可以了
@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}

测试效果

先后启动 spring-cloud-consul-producer、 spring-cloud-consul-consumer、spring-cloud-consul-monitor 服务。

访问 http://localhost:8531/hystrix,会看到如下图所示界面。

此时没有任何具体的监控信息,需要输入要监控的消费者地址及监控信息的轮询时间和标题。

Hystrix Dashboard 共支持三种不同的监控方式:

单体Hystrix 消费者:通过URL http://hystrix-app:port/hystrix.stream 开启,实现对具体某个服务实例的监控。

默认集群监控:通过URL http://turbine-hostname:port/turbine.stream 开启,实现对默认集群的监控。

自定集群监控:通过URL http://turbine-hostname:port/turbine.stream?cluster=[clusterName] 开启,实现对clusterName集群的监控。

我们这里现在是对单体 Hystrix 消费者的监控,后面整合 Turbine 集群的时候再说明后两种的监控方式。

我们先访问 http://localhost:8521/feign/call, 查看要监控的服务是否可以正常访问。

确认服务可以正常访问之后,在监控地址内输入 http://localhost:8521/hystrix.stream,然后点击 Monitor Stream 开始监控。

刚进去,页面先显示 loading... 信息, 多次访问 http://localhost:8521/feign/call 之后,统计图表信息如下图所示。

各个指标的含义参见下图。

熔断监控面板(Hystrix Dashboard)的更多相关文章

  1. spring cloud Hystrix监控面板Hystrix Dashboard和Turbine

    我们提到断路器是根据一段时间窗内的请求情况来判断并操作断路器的打开和关闭状态的.而这些请求情况的指标信息都是HystrixCommand和HystrixObservableCommand实例在执行过程 ...

  2. SpringCloud断路器监控面板——Hystrix Dashboard

    一.简介 Hystrix Dashboard是Hystrix的一个组件,Hystrix Dashboard提供一个断路器的监控面板,可以使我们更好的监控服务和集群的状态,仅仅使用Hystrix Das ...

  3. Spring Boot + Spring Cloud 构建微服务系统(五):熔断监控面板(Hystrix Dashboard)

    Hystrix Dashboard Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Comma ...

  4. 006服务监控看板Hystrix Dashboard

    1.POM配置 和普通Spring Boot工程相比,仅仅添加了Hystrix Dashboard和Spring Boot Starter Actuator依赖 <dependencies> ...

  5. 断路器监控(Hystrix Dashboard)

    继上一篇http://www.cnblogs.com/EasonJim/p/7613595.html介绍了断路器之后,其实它还提供了一个管理页面来监控这些应用的调用数据. 首先,我是基于上一个例子Zo ...

  6. [Spring cloud 一步步实现广告系统] 19. 监控Hystrix Dashboard

    在之前的18次文章中,我们实现了广告系统的广告投放,广告检索业务功能,中间使用到了 服务发现Eureka,服务调用Feign,网关路由Zuul以及错误熔断Hystrix等Spring Cloud组件. ...

  7. Spring Cloud学习笔记【五】Hystrix Dashboard监控面板

    ystrix除了隔离依赖服务的调用以外,Hystrix 还提供了准实时的调用监控(Hystrix Dashboard),Hystrix 会持续地记录所有通过 Hystrix 发起的请求的执行信息,并以 ...

  8. spring cloud深入学习(六)-----熔断监控Hystrix Dashboard和Turbine

    Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...

  9. 玩转Spring Cloud之熔断降级(Hystrix)与监控

    本文内容导航目录: 前言:解释熔断降级一.搭建服务消费者项目,并集成 Hystrix环境 1.1.在POM XML中添加Hystrix依赖(spring-cloud-starter-netflix-h ...

随机推荐

  1. Windows 下使用virtualenv 第一次使用flask

    前几天在Windows下virtualenv 了一个名为 venv的目录,然后,今天差点忘了怎么进去虚拟环境. 发现在创建虚拟环境的venv目录下有个Scripts目录,里面有一堆 名为activat ...

  2. HTML 标记 3 —— CSS

    <style type="text/css">body { background-color: #F00;} p{ color:#0F0; } .自己定义 { colo ...

  3. eclipse中选中一个单词 其他相同的也被选中 怎么设置

    转自:https://zhidao.baidu.com/question/72621094.html 打开Window——Preferences 选择Java——Editor——Mark Occure ...

  4. Pandas存储为Excel格式:单个xlsx文件下多sheet存储方法

    Notes If passing an existing ExcelWriter object, then the sheet will be added to the existing workbo ...

  5. 第 8 章 容器网络 - 054 - 准备 macvlan 环境

    准备 macvlan 环境 macvlan 本身是 linux kernel 模块,其功能是允许在同一个物理网卡上配置多个 MAC 地址,即多个 interface,每个 interface 可以配置 ...

  6. python+selenium2(一)

    一.安装python (1)在官网下载python的安装包,这里使用的是python3.5.安装一路下一步,安装路径我的是D:\Python35. (2)在计算机的path变量中添加D:\Python ...

  7. centos 安装npm node

    最近那vue全套造了个管理系统的轮子,发现node简直太好用了. elment-UI的出现就是不懂ui设计的后台工程师的福音~ 正好自己买的两个云服务器空闲着没用,就拿来试试看了 首先软件都安装在/u ...

  8. 雷林鹏分享:XML 验证器

    XML 验证器 使用我们的 XML 验证器来对您的 XML 文件进行语法检查. XML 错误会终止您的程序 XML 文档中的错误会终止您的 XML 应用程序. W3C 的 XML 规范声明:如果 XM ...

  9. English trip EM2-LP-6A Teacher:Julia

    课上内容(Lesson) How many children are in the family? there are 16 kids How old is the oldest child? He' ...

  10. LeetCode--326--3的幂

    问题描述: 给定一个整数,写一个函数来判断它是否是 3 的幂次方. 示例 1: 输入: 27 输出: true 示例 2: 输入: 0 输出: false 示例 3: 输入: 9 输出: true 示 ...