Spring Cloud Hystrix Dashboard的使用 5.1.3
要想实时地对服务进行监控,需要在项目中添加相关的监控依赖,具体如下:
<dependency><!--监控依赖--><!--http://localhost:8030/hystrix.stream-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
在xcservice-eureka-user-hystrix工程的pom.xml中引入上述依赖后,即可查看监控信息,具体操作步骤如下。
(1)分别启动注册中心、服务提供者(7901)和服务消费者工程。
(2)通过浏览器访问地址http://localhost:8030/findOrder-sByUser/1(此步骤不可省略,否则将由于系统应用的所有接口都未被调用,而只输出ping:)。
(3)通过浏览器访问地址http://localhost:8030/hystrix.stream,将看到如下所示的输出信息。
ping:
data: {"type":"HystrixCommand","name":"findOrdersByUser","group":"UserController","currentTime":1563192973047,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountBadRequests":0,"rollingCountCollapsedRequests":0,"rollingCountEmit":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackEmit":0,"rollingCountFallbackFailure":0,"rollingCountFallbackMissing":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"rollingMaxConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1,"threadPool":"UserController"}
data: {"type":"HystrixThreadPool","name":"UserController","currentTime":1563192973047,"currentActiveCount":0,"currentCompletedTaskCount":6,"currentCorePoolSize":10,"currentLargestPoolSize":6,"currentMaximumPoolSize":10,"currentPoolSize":6,"currentQueueSize":0,"currentTaskCount":6,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"rollingCountCommandRejections":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"reportingHosts":1}

可以看出,访问具体地址后,浏览器会不断地执行刷新操作以获取实时的监控数据。这样运维人员就可以通过这些数据来判断出系统当前的监控状态。虽然采用上面这种纯文字输出的方式可以实时监控数据,但其可读性十分差。
为此,我们可以通过Hystrix Dashboard以可视化的方式来查看实时监控数据。Hystrix Dashboard是Hystrix的一个组件,它提供了数据监控和友好的图形化界面支持。
下面通过一个具体的应用来演示Hystrix Dashboard的使用。
(1)新建xcservice-springcloud的子工程xcservice-hystrix-dashboard,在其pom.xml文件中添加监控依赖和Hystrix Dashboard依赖,如文件5-5所示。
文件5-5 pom.xml
<?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>
<parent>
<groupId>com.xc</groupId>
<artifactId>xcservice-springcloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.xc</groupId>
<artifactId>xcservice-hystrix-dashboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>xcservice-hystrix-dashboard</name>
<description>Hystrix Dashboard是Hystrix的一个组件,它提供了数据监控和友好的图形化界面支持。</description> <properties>
<java.version>1.8</java.version>
</properties> <dependencies> <dependency><!--数据监控和友好的图形化界面支持--><!--http://localhost:8031/hystrix.stream-->
<groupId>org.springframework.cloud</groupId>
<artifactId> spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency> <dependency><!--监控依赖--><!--http://localhost:8030/hystrix.stream-->
<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> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
(2)编写配置文件application.yml,指定应用的端口号和名称等信息,如文件5-6所示。
文件5-6 application.yml
server:
port: 8031 # 指定该Eureka实例的端口号 spring:
application:
name: xcservice-hystrix-dashboard # 指定应用名称
(3)编写启动类Application.java,并在其类上添加@EnableHystrixDashboard注解来开启Hystrix仪表板功能,如文件5-7所示。
文件5-7 Application.java
package com.xc.xcservicehystrixdashboard; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; @SpringBootApplication
@EnableHystrixDashboard
public class XcserviceHystrixDashboardApplication { public static void main(String[] args) {
SpringApplication.run(XcserviceHystrixDashboardApplication.class, args);
} }
(4)启动工程后,通过浏览器访问地址http://local-host:8031/hystrix.stream将会看到如图5-8所示的信息。

在Hystrix Dashboard下的输入框中输入http://localhost:8030/hystrix.stream,并设置Title为“订单微服务”后,单击【Monitor Stream】按钮。
此时如果通过另一个浏览器访问http://localhost:8030/findOrdersByUser/1,并且不断地刷新地址,将出现如下所示页面。
关于图中各个指标的含义,在Hystrix Dashboard Wiki上已经给出了详细说明,读者可访问地址https://github.com/Netflix/Hystrix/wiki/Dashboard查看。
Spring Cloud Hystrix Dashboard的使用 5.1.3的更多相关文章
- Spring Cloud Hystrix Dashboard熔断器-Turbine集群监控(六)
序言 上一篇说啦hystrix的使用方法与配置还有工作流程及为何存在,我去,上一篇这么屌,去看看吧,没这么屌的话,我贴的有官方文档,好好仔细看看 hystrix除啦基本的熔断器功能之外,还可以对接口的 ...
- spring cloud hystrix dashboard 没有/actuator/hystrix.stream路径解决
首先我用的是spring boot Greenwich.SR2 在测试hystrix-dashboard监控服务时,发现访问localhost:9001/actuator/hystrix.stream ...
- Spring Cloud 2-Hystrix DashBoard仪表盘(五)
Spring Cloud Hystrix DashBoard 1.监控系统配置 pom.xml application.yml Application.java 2.被监控服务配置 pom.xml ...
- 微服务架构之spring cloud hystrix&hystrix dashboard
在前面介绍spring cloud feign中我们已经使用过hystrix,只是没有介绍,spring cloud hystrix在spring cloud中起到保护微服务的作用,不会让发生的异常无 ...
- Spring Cloud 微服务笔记(六)Spring Cloud Hystrix
Spring Cloud Hystrix Hystrix是一个延迟和容错库,旨在隔离远程系统.服务和第三方库,阻止链接故障,在复杂的分布式系统中实现恢复能力. 一.快速入门 1)依赖: <dep ...
- 试水Spring Cloud Hystrix
Spring Cloud Hystrix是一个容错库,它实现了断路器模式,使得当服务发生异常时,会自动切断连接,并将请求引导至预设的回调方法. 服务端 在Spring Tool Suite的文件菜单中 ...
- Spring Cloud Hystrix理解与实践(一):搭建简单监控集群
前言 在分布式架构中,所谓的断路器模式是指当某个服务发生故障之后,通过断路器的故障监控,向调用方返回一个错误响应,这样就不会使得线程因调用故障服务被长时间占用不释放,避免故障的继续蔓延.Spring ...
- 分布式系统的延时和故障容错之Spring Cloud Hystrix
本示例主要介绍 Spring Cloud 系列中的 Eureka,如何使用Hystrix熔断器容错保护我们的应用程序. 在微服务架构中,系统被拆分成很多个服务单元,各个服务单元的应用通过 HTTP 相 ...
- 7、Spring Cloud Hystrix
1.Spring Cloud Hystrix简介 (1).分布式问题 复杂分布式体系结构中的应用程序有数十个依赖关系,每个依赖关系在某些时候将不可避免地失败. 多个微服务之间调用的时候,假设微服务A调 ...
随机推荐
- python - Django 跨域配置
一:settings 中间件配置路径 MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.s ...
- Post Office Problem
Description There are n houses on a line. Given an array A and A[i] represents the position of i-th ...
- Qt读写三种文件,QSettings读ini配置文件,QJsonDocument读JSON文件,QDomDocument读xml文件
第一种INI配置文件 .ini 文件是Initialization File的缩写,即初始化文件. 除了windows现在很多其他操作系统下面的应用软件也有.ini文件,用来配置应用软件以实现不同用户 ...
- RookeyFrame 通用页面 加载数据 原理
说明: 我是一步一步跳转进去的哈 测试的功能:通用列表页面的普通查询 点一下查询按钮,就能看到请求的地址:/DataAsync/LoadGridData.html 1.DataController - ...
- V语言 基本使用
新手必看-如何安装配置vlang运行环境(linux,macOS篇) 前置条件 发稿截止前只有Linux 或者 macOS系统能编译通过. 你需要安装clang或gcc 如果是macOS上需运行xco ...
- Anaconda3自带jupyter
1.cmd命令行中输入 JupyterNotebook 2.系统自动调起下面页面(注册端口冲突是打不开的)
- Git的使用(5) —— 在IDEA上使用
1. 在IDEA中配置Git 前言:IDEA中鼓捣Git是真的费劲,建议还是用TortoiseGit. 打开IDEA的Settings,左侧菜单列表中的Version Control里面找到Git. ...
- 14.LAMP服务 Linux Apache Mysql Php和防护机制 xinetd、tcp wapper
一.安装LAMP服务 Linux Apache Mysql Php 要求操作系统支持 php解析 apache调用php插件解析 phpmyadmin yum install ...
- MVC框架的主要问题是什么?
以下是MVC框架的一些主要问题: 对 DOM 操作的代价非常高 程序运行缓慢且效率低下 内存浪费严重 由于循环依赖性,组件模型需要围绕 models 和 views 进行创建
- JVM常量的含义与反编译助记符详解
1.定义一个常量 public class MyTest2 { public static void main(String[] args) { System.out.println(MyParent ...