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简介 在微服务架构中为了保证程序的可用性,防止程序出错导致网络阻 ...
随机推荐
- libnids TCP数据流重组,显示TCP连接过程的程序总无法捕获数据包解决办法:
法一: 指定可用网卡: nids_params.device="lo"; 法二: nids.h中有这么一段: struct nids_chksum_ctl { u_int ne ...
- 1章 SpringBoot介绍
新建一个SpringBoot版的Hello World.
- [Swift通天遁地]一、超级工具-(12)使用Toaster制作简短提示语的吐司窗口
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- ACM_同余+暴力找规律
小光的忧伤 Time Limit: 2000/1000ms (Java/Others) Problem Description: 锴神:我尊重作者原意,你们出什么我就加什么.于是小光打了道水题(也就是 ...
- centos源码编译安装nginx过程记录
前言:Centos系统编译安装LNMP环境是每来一台新服务器或换电脑都需要做的事情.这里仅做一个记录.给初学者一个参考! 一.安装前的环境 这里用的是centos 7系统. 我们默认把下载的软件放在 ...
- 连接服务器的mysql
在服务器配置好Mysql 数据库,在客户端连接,报错: 解决方法: 1.在MySQL 数据库中修改user表,将host 中的localhoust 改为 %: 2.配置访问数据库的全选 根据需要配置权 ...
- 我的DBDA类
<?php class DBDA { public $host="localhost"; public $uid="root"; public $pwd= ...
- Linux 学习(二)
Linux相关命令 命令 说明 startx 当前用户界面切换至图形界面 init5 切换至另一用户的图形化界面 init3 从图形界面切换回文本界面 pwd 显示当前用户路径 logout 注销 s ...
- apache hadoop 伪分布式安装
1. 准备工作 1.1. 软件准备 1.安装VMWare 2.在VMWare上安装CentOS6.5 3.安装XShell5,用来远程登录系统 4.通过rpm -qa | grep ssh 检查cen ...
- FPGA编程技巧系列之输入输出偏移约束详解
1. 偏移约束的作用 偏移约束(Offset Constraint)用来定义一个外部时钟引脚(Pad)和数据输入输出引脚之间的时序关系,这种时序关系也被称为器件上的Pad-to-Setup或Clo ...