springcloud(十):熔断监控Hystrix Dashboard
申明: 这里比较坑爹,大家写的时候要小心,这里和springboot的版本有关系哈,我使用的是2.0 版本,要么调频为1.5 版本,要么使用其他方式 解决错误,我选择了还是用2.0 各位慎重参考哈!
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据
话不多说看项目,为了避免在一个项目上反复修改,大家看的一头雾水,所以我还是选择重新创建项目
1.创建项目

2. 选择项目类型

3.选择项目名称,可以随便写,但是不能有大写

4.选择我们要生成的依赖

5.选择工程和模块命名

6.项目结构如下,和上一个木有大的变化,只是配置变了

7. 编辑pom.xml文件
<dependencies>
<dependency>
<groupId>cn.kgc</groupId>
<artifactId>eureka-common-school</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--@EnableDiscoveryClient-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<!--@EnableHystrixDashboard-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<!--@EnableCircuitBreaker-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--@EnableFeignClients-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
8.编辑我们的属性文件
server.port=8765
spring.application.name=hystrix-dashboard
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
# 将feign集成的断路器设置成有效状态
feign.hystrix.enabled=true
# 加载所有的端点
management.endpoints.web.exposure.include="*"
9..在cn.kgc.feign包下编写StudentFeign业务接口,好多人在这里添加service注解,木有看懂,但是我这里也能拿到数据
package cn.kgc.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping; /*FeignClient的name属性值和eureka_client_product的appliaction属性文件找那个的spring.application.name保持一致
fallback属性指定容错处理类
springcloud默认已经为feign整合了hystrix,只要hystrix在项目中,使用feign就会
默认使用熔断器处理所欲的请求
熔断器模式类似于生活中的电路保险丝,当电流抄在可能银帆危险时就会自动断开,使用熔断器模式,
如果请求出现异常,所有的请求都会直接返回而不会等待或阻塞,这样可以减少资源的浪费。
熔断器还有一种半开的状态,当熔断器发现异常后悔进入半打开状态,此时会定时接受
一个请求来检测系统是否恢复,如果请求调用成功,代表系统已经恢复正常,救护关掉熔断器,
否则继续打开*/
@FeignClient(name="client-school-provider",fallback = StudentFeignFallBack.class)
public interface StudentFeign {
//下面的调用接口标准要和eureka-client-provider中的controller请求方法必须保持一致
@RequestMapping("/data.do")
public String stuData(); }
10..在cn.kgc.feign包下编写StudentFeignFallBack容错处理类
package cn.kgc.feign; import org.springframework.stereotype.Component; //容错处理类
@Component
public class StudentFeignFallBack implements StudentFeign{
@Override
public String stuData() {
return "服务器异常,请稍后在尝试登陆";
}
}
11.在cn.kgc.controller包下编写StudentController控制器类
package cn.kgc.controller; import cn.kgc.feign.StudentFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
public class StudentController {
@Autowired
private StudentFeign studentFeign; @RequestMapping("/studata.do")
public String showOptionsData(){
return studentFeign.stuData();
}
}
12.启动拉。还是老规矩依次启动:eureka-server、eureka-client-provider、hystrix-dashboard

13. 正常访问


图中会有一些提示:
Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream
Cluster via Turbine (custom cluster): http://turbine-hostname:port/turbine.stream?cluster=[clusterName]
Single Hystrix App: http://hystrix-app:port/actuator/hystrix.stream
大概意思就是如果查看默认集群使用第一个url,查看指定集群使用第二个url,单个应用的监控使用最后一个,我们暂时只演示单个应用的所以在输入框中输入: http://localhost:8765/actuator/hystrix.stream ,输入之后点击 monitor,进入页面。如果没有请求会先显示Loading ...,

访问http://localhost:8765/actuator/hystrix.stream 也会不断的显示ping。

请求服务hhttp://localhost:8765/studata.do,

在刷新地址

注意这些是啥意思,自己翻译下面的图,这个是把上面个列表以图形化的形式展示出来了,需要使用工具哦

断头了,为了发帖子,脖子要折了,转帖请注明出处
有问题请联系我哈:微信、QQ:964918306
此帖子为原创
作者:红酒人生
转载请注明出处:https://www.cnblogs.com/holly8/p/11025732.html
springcloud(十):熔断监控Hystrix Dashboard的更多相关文章
- 微服务SpringCloud之熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- 跟我学SpringCloud | 第五篇:熔断监控Hystrix Dashboard和Turbine
SpringCloud系列教程 | 第五篇:熔断监控Hystrix Dashboard和Turbine Springboot: 2.1.6.RELEASE SpringCloud: Greenwich ...
- springcloud(五):熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- spring cloud(五)熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- Spring Cloud(五):熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- spring cloud深入学习(六)-----熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- spring cloud熔断监控Hystrix Dashboard和Turbine
参考: http://blog.csdn.net/ityouknow/article/details/72625646 完整pom <?xml version="1.0" e ...
- spring-cloud:熔断监控Hystrix Dashboard和Turbine的示例
1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.GITHUB地址 https://github.com/nbfujx/springCl ...
- 服务容错保护断路器Hystrix之三:断路器监控(Hystrix Dashboard)-单体监控
turbine:英 [ˈtɜ:baɪn] 美 [ˈtɜ:rbaɪn] n.汽轮机;涡轮机;透平机 一.Hystrix Dashboard简介 在微服务架构中为了保证程序的可用性,防止程序出错导致网络阻 ...
随机推荐
- uva11542
https://vjudge.net/problem/UVA-11542 xor高斯消元... 答案为2^f-1 其实书上有一个问题 样例有3种情况,其中4,6,15是绑在一起的,也就是他们必须满足一 ...
- Java中的经典算法之冒泡排序
原理:比较两个相邻的元素,将值大的元素交换至右端. 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面.即在第一趟:首先比较第1个和第2个数,将小数放前,大数放后.然后比较第2个数和第3个数,将 ...
- libnids 显示UDP数据报,编译,运行,正确。
#include<stdio.h>#include<nids.h>#include<string.h>#include <sys/socket.h>#i ...
- System.Drawing.Color的几种使用方法
System.Drawing.Color cl = Color.Red; System.Drawing.Color cl = Color.FromArgb(255,0,0); ...
- bzoj4987: Tree(树形dp)
Description 从前有棵树. 找出K个点A1,A2,…,Ak. 使得∑dis(AiAi+1),(1<=i<=K-1)最小. Input 第一行两个正整数n,k,表示数的顶点数和 ...
- Akka源码分析-Cluster-Sharding
个人觉得akka提供的cluster工具中,sharding是最吸引人的.当我们需要把actor分布在不同的节点上时,Cluster sharding非常有用.我们可以使用actor的逻辑标识符与ac ...
- spring cxf 配置步骤
spring 项目增加web service的步骤:1.复制cxf的jar包2.web.xml配置cxf的核心控制器:org.apache.cxf.transport.servlet.CXFServl ...
- 为WebSphere Application Server v8.5安装并配置JDK7
IBM WebSphere Application Server v8.5可以同时支持不同版本的JDK共存,并且可以通过命令设置概要文件所使用的JDK版本.WAS8.5默认安装JDK6,如果要使用JD ...
- [转]mysql的查询、子查询及连接查询
转自:http://www.cnblogs.com/rollenholt/archive/2012/05/15/2502551.html 一.mysql查询的五种子句 where(条件 ...
- Vue组件之间通信的三种方式
最近在看梁颠编著的<Vue.js实战>一书,感觉颇有收获,特此记录一些比价实用的技巧. 组件是MVVM框架的核心设计思想,将各功能点组件化更利于我们在项目中复用,这类似于我们服务端面向对象 ...