spring cloud:HystrixDashboard
hystrix-dashboard-server
1. File-->new spring starter project
2.add dependency
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
3.Edit application.yml
server:
port: spring:
application:
name: hystrix-dashboard-server #
#eureka:
# client:
# service-url:
# defaultZone: http://localhost:8761/eureka/
4.program
package com.smile; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean; import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; @SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardServerApplication { public static void main(String[] args) {
SpringApplication.run(HystrixDashboardServerApplication.class, args);
} }
5.Run
visit : http://localhost:9000/hystrix
输入要监控的地址 http://localhost:9001/actuator/hystrix.stream 点击 monitor
hystrix-dashboard-client
1. File-->new spring starter project
2.add dependency
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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
</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
3.Edit application.yml
server:
port:
spring:
application:
name: hystrix-dashboard-client eureka:
client:
service-url:
defaulZone: http://localhost:8761/eureka/ management:
endpoints:
web:
exposure:
include: '*' feign:
hystrix:
enabled: true
4.program
package com.smile; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableCircuitBreaker //开启断路器,否则监控不到
public class HystrixDashboardClientApplication { public static void main(String[] args) {
SpringApplication.run(HystrixDashboardClientApplication.class, args);
} }
package com.smile.controller; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import com.smile.remote.HelloService; @RestController
public class ConsumerController { @Autowired
HelloService helloService; @RequestMapping("/hello/{name}")
public String helloConsumer(@PathVariable("name") String name) {
return helloService.getHello(name);
} }
package com.smile.remote; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; @FeignClient(name = "producer",fallback = HelloServiceHystrix.class)
public interface HelloService { @RequestMapping("/getHello")
public String getHello(@RequestParam String name);
}
package com.smile.remote; import org.springframework.stereotype.Component; @Component
public class HelloServiceHystrix implements HelloService{ @Override
public String getHello(String name) {
return "hello "+name+",this is hystrix!";
} }
5.Run
visit: http://localhost:9001/hello/smile
hello smile
停止producer 再次访问 http://localhost:9001/hello/smile
hello smile,this is hystrix!
监控也会监控到hystrix
hystrix-dashboard 就到这里了
spring cloud:HystrixDashboard的更多相关文章
- spring cloud 学习研究- spring-cloud-microservice-example
spring cloud + docker 微服务架构 http://www.open-open.com/lib/view/open1437363835818.html 实例项目 https://gi ...
- 【译文】用Spring Cloud和Docker搭建微服务平台
by Kenny Bastani Sunday, July 12, 2015 转自:http://www.kennybastani.com/2015/07/spring-cloud-docker-mi ...
- 从架构演进的角度聊聊Spring Cloud都做了些什么?
Spring Cloud作为一套微服务治理的框架,几乎考虑到了微服务治理的方方面面,之前也写过一些关于Spring Cloud文章,主要偏重各组件的使用,本次分享主要解答这两个问题:Spring Cl ...
- 玩转Spring Cloud之熔断降级(Hystrix)与监控
本文内容导航目录: 前言:解释熔断降级一.搭建服务消费者项目,并集成 Hystrix环境 1.1.在POM XML中添加Hystrix依赖(spring-cloud-starter-netflix-h ...
- Spring Cloud Alibaba基础教程:使用Sentinel实现接口限流
最近管点闲事浪费了不少时间,感谢网友libinwalan的留言提醒.及时纠正路线,继续跟大家一起学习Spring Cloud Alibaba. Nacos作为注册中心和配置中心的基础教程,到这里先告一 ...
- Spring Cloud项目之断路器集群监控Hystrix Dashboard
微服务(Microservices Architecture)是一种架构风格,一个大型复杂软件应用由一个或多个微服务组成.系统中的各个微服务可被独立部署,各个微服务之间是松耦合的.每个微服务仅关注于完 ...
- Spring Cloud 2-Hystrix DashBoard仪表盘(五)
Spring Cloud Hystrix DashBoard 1.监控系统配置 pom.xml application.yml Application.java 2.被监控服务配置 pom.xml ...
- Spring Cloud 微服务架构全链路实践
阅读目录: 1. 网关请求流程 2. Eureka 服务治理 3. Config 配置中心 4. Hystrix 监控 5. 服务调用链路 6. ELK 日志链路 7. 统一格式返回 Java 微服务 ...
- spring cloud Hystrix监控面板Hystrix Dashboard和Turbine
我们提到断路器是根据一段时间窗内的请求情况来判断并操作断路器的打开和关闭状态的.而这些请求情况的指标信息都是HystrixCommand和HystrixObservableCommand实例在执行过程 ...
随机推荐
- list 小练习
li = ["alex", "WuSir", "ritian", "barry", "wenzhou" ...
- 2018icpc宁夏邀请赛网络赛_G_Trouble of Tyrant
题意 一列\(n\)个点,给定一个特殊的图,有两种边\(E(1,i)\)和\(E(i-1,i)\),多个询问,每次给一个\(d\),求所有路径长度加上\(d\)后1到\(n\)的最短路. 分析 首先这 ...
- 使用了框架iframe的页面如何跳出框架
"window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...
- elementui 之el-pagination爬坑,属性pager-count的设定
我想设置总页数为10页,页码条总是显示两个页码,其余省略号显示,我选择了pager-count,如下: <el-pagination @size-change="handleSizeC ...
- Smoke Testing
[Smoke Testing 释义] Smoke Testing 的概念最早源于制造业,用于测试管道.测试时,用鼓风机往管道里灌烟,看管壁外面是否有烟冒出来,以便检验管道是否有缝隙.这一测试显然比较初 ...
- jfinal layui 多选传值问题整理
使用layui在显示数据表格进行多选的时候遇到的几个问题: 1.增加监听,让你的数据表格可以进行复选. layui.use('table', function(){ var $ = layui.jqu ...
- func_get_args func_num_args 的使用
func_get_args是获取方法中参数的数组,返回的是一个数组,与func_num_args搭配使用: func_num_args一般写在方法中,用于计数 function eeee($a='gg ...
- Delphi简介
- OpenCV笔记(I)
这里记一下开始入手OpenCV碰到的一些问题以及解决办法.学习参考书是<OpenCV 4 计算机视觉项目实战(原书第2版)>,ISBN:978-7-111-63164-4. Ubuntu ...
- 交叉工具链和makefile
交叉工具链: arm-linux-gcc:交叉编译器 arm-linux-ld:交叉连接器 arm-linux-readelf:交叉ELF文件工具 arm-linux-objdump:交叉反汇编器 a ...