spring cloud: Hystrix(七):Hystrix的断容器监控dashboard

Hystrix的断容器监控dashboard。

dashboard是用来监控Hystrix的断容器监控的,图形化dashboard是如何实现指标的收集展示的。

dashboard

本地端口8730

项目地址:http://localhost:8730/hystrix

在Pom.xml文件引入:

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>

  

在入口文件开启注解

@SpringBootApplication

@EnableHystrixDashboard
@SpringBootApplication
public class FeignApp {

	public static void main(String[] args) {
		SpringApplication.run(FeignApp.class, args);
	}
}

  

然后运行,http://localhost:8730/hystrix

Hystrix

本项目地址:http://192.168.1.6:8010

pom.xml加入hystrix引入

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>

  

入口文件引入hystrix注解

@EnableCircuitBreake

@EnableEurekaClient
@SpringBootApplication
//hystrix
@EnableCircuitBreaker
public class HystrixApplication {	

	//ribbon
	@Bean
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

	public static void main(String[] args) {
		SpringApplication.run(HystrixApplication.class, args);
	}
}

  

Controller文件调用hystrix

@HystrixCommand(fallbackMethod = "notfindback", [email protected](name="execution.isolation.strategy", value="SEMAPHORE") )

其中fallbackMethod 方法是回退,当网络不通,或者无法访问时访问:notfindback方法,返回默认值

commandProperties是合并线程

@RestController
public class MovieController {

	@Autowired
	private RestTemplate restTemplate;	

	@GetMapping("/movie/{id}")
	@HystrixCommand(fallbackMethod = "notfindback", [email protected](name="execution.isolation.strategy", value="SEMAPHORE") )
	public User findById(@PathVariable Long id)
	{
		//http://localhost:7900/simple/
		return restTemplate.getForObject("http://spring-boot-user/simple/" + id, User.class);
	}

	public User notfindback(Long id)
	{
		User user = new User();
		user.setId(0L);
		return user;

	}

}

  

访问:

http://192.168.1.6:8010/movie/1

查看hystrix.stream信息

http://192.168.1.6:8010/hystrix.stream

dashboard监控http://192.168.1.6:8010/hystrix.stream信息

在http://localhost:8730/hystrix中输入要监控的hystrix.stream

如下

每当我刷新:http://192.168.1.6:8010/movie/1数据时,http://localhost:8730/hystrix/monitor?stream=http%3A%2F%2F192.168.1.6%3A8010%2Fhystrix.stream 的指示图就发生变化

原文地址:https://www.cnblogs.com/achengmu/p/9912080.html

时间: 2024-07-29 21:18:17

spring cloud: Hystrix(七):Hystrix的断容器监控dashboard的相关文章

spring cloud 学习(4) - hystrix 服务熔断处理

hystrix 是一个专用于服务熔断处理的开源项目,当依赖的服务方出现故障不可用时,hystrix有一个所谓的断路器,一但打开,就会直接拦截掉对故障服务的调用,从而防止故障进一步扩大(类似中电路中的跳闸,保护家用电器). 使用步骤:(仍然在之前的示例代码上加以改造) 一.添加hystrix依赖 compile 'org.springframework.cloud:spring-cloud-starter-hystrix' 二.在需要熔断的方法上添加注解 package com.cnblogs.y

Spring Cloud入门教程-Hystrix断路器实现容错和降级

简介 Spring cloud提供了Hystrix容错库用以在服务不可用时,对配置了断路器的方法实行降级策略,临时调用备用方法.这篇文章将创建一个产品微服务,注册到eureka服务注册中心,然后我们使用web客户端访问/products API来获取产品列表,当产品服务故障时,则调用本地备用方法,以降级但正常提供服务. 基础环境 JDK 1.8 Maven 3.3.9 IntelliJ 2018.1 Git 项目源码 Gitee码云 添加产品服务 在intelliJ中创建一个新的maven项目,

Spring Cloud(Dalston.SR5)--Hystrix 断路器

Spring Cloud 对 Hystrix 进行了封装,使用 Hystrix 是通过 @HystrixCommand 注解来使用的,被 @HystrixCommand 注解标注的方法,会使用 AspectJ 对其进行代理,Spring 会将相关的类转换为 Bean 放到容器中,在 @HystrixCommand 注解中,还可以通过 commandProperties.threadPoolProperties 属性来设置命令的配置. Hystrix 示例如下: 创建项目 创建名称为 spring

Spring Cloud Feign 整合 Hystrix

在前面随笔Spring Cloud 之 Feign的feign工程基础上进行改造 1.pom.xml依赖不变 2.application.yml文件添加feign.hystrix.enabled=true开启Hystrix断路器,即: spring: application: name: feign server: port: 8766 eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ feign: hy

Spring Cloud Ribbon 整合 Hystrix

在前面随笔 Spring Cloud 之 Ribbon 的ribbon工程基础上进行改造 1.pom.xml 加入依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> 即pom.xml为 <?xml version="

Spring Cloud第七篇 | 声明式服务调用Feign

本文是Spring Cloud专栏的第七篇文章,了解前六篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Cloud第二篇 | 使用并认识Eureka注册中心 Spring Cloud第三篇 | 搭建高可用Eureka注册中心 Spring Cloud第四篇 | 客户端负载均衡Ribbon Spring Cloud第五篇 | 服务熔断Hystrix Spring Cloud第六篇 | Hystrix仪表盘监控Hy

Spring Cloud(七):服务网关zuul过滤器

上文介绍了Zuul的基本使用与路由功能,本文接着介绍Zuul的核心概念 -- Zuul过滤器(filter). Zuul的功能基本通过Zuul过滤器来实现(类比于Struts的拦截器,只是Struts拦截器用到责任链模式,Zuul则是通过FilterProcessor来控制执行),在不同的阶段,通过不同类型的过滤器来实现相应的功能. Zuul过滤器 过滤器类型 zuul的过滤器根据对HTTP请求的不同处理阶段包括如下四种类型 pre :在请求转发到后端目标服务之前执行,一般用于请求认证.确定路由

Spring Cloud(七)服务网关 Zuul Filter 使用

上一篇文章中,讲了Zuul 转发,动态路由,负载均衡,等等一些Zuul 的特性,这个一篇文章,讲Zuul Filter 使用,关于网关的作用,这里就不再次赘述了,重点是zuul的Filter ,我们可以实现安全控制,比如,只有请求参数中有token和密码的客户端才能访问服务端的资源.那么如何来实现Filter了? Spring Cloud Zuul zuul 执行流程 Zuul大部分功能都是通过过滤器来实现的.Zuul中定义了四种标准过滤器类型,这些过滤器类型对应于请求的典型生命周期. PRE:

Spring Cloud 学习 (四) Hystrix &amp; Hystrix Dashboard &amp; Turbine

在复杂的分布式系统中,可能有几十个服务相互依赖,这些服务由于某些原因,例如机房的不可靠性.网络服务商的不可靠性等,导致某个服务不可用 . 如果系统不隔离该不可用的服务,可能会导致整个系统不可用.Hystrix 提供了熔断器功能,能够阻止分布式系统中出现联动故障.Hystrix 是通过隔离服务的访问点阻止联动故障的,并提供了故障的解决方案,从而提高了整个分布式系统的弹性. 使用 Hystrix 在 Ribbon 使用 Hystrix 添加依赖包 <dependency> <groupId&