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实例在执行过程 ...
随机推荐
- PHP手册在7.1迁移页面给出了替代方案,就是用OpenSSL取代MCrypt.
/** * [AesSecurity aes加密,支持PHP7.1] */ class AesSecurity { /** * [encrypt aes加密] * @p ...
- nrm切换npm的镜像
安装node环境 npm -v 1. 安装nrm npm install nrm -g 2. 查看可选的镜像源 nrm ls 号代表目前使用的镜像源 3. 切换镜像源 现在将镜像源切换到淘宝为例 nr ...
- numpy-数据格式之 int 与 uint
概念 整型分为 有符号整型 和 无符号整型,其区别在于 无符号整型 可以存放的正数范围 比 有符号整型 大一倍,因为 有符号整型 将最高位存储符号,而 无符号整型 全部存储数字 # 1 111000 ...
- 6-4 如何构建xml文档
>>> from xml.etree.ElementTree import Element,ElementTree Element 是节点元素 ElementTree是由 Eleme ...
- vue学习之vue-resource的引入
npm安装的命令 npm install vue-resource --save 安装完成后在main.js中导入 import VueResource from 'vue-resource' V ...
- VIM如何自动保存文件、自动重加载文件、自动刷新显示文件
1.手动重加载文件的命令是:e! 2.一劳永逸的方法是:vim提供了自动加载的选项 autoread,默认关闭. 在vimrc中添加 set autoread即可打开自动加载选项,相关选项: :hel ...
- C#实现Base64处理加解密
using System;using System.Text; namespace Common{ /// <summary> /// 实现Base64加密解密 /// ...
- (转) windows 下ORA-12514:TNS 监听问题
在使用Orcale数据库的时候不知道各位是否遇到过如图的监听问题(或者显示类似的问题),以下方法就是来解决这样的问题的. 首先右击计算机,选择管理.选择左侧栏的服务与应用程序,右侧栏选服务. ...
- u-boot initf_bootstage函数分析
这篇博客主要分析 init_sequence_f 函数指针数组中的initf_bootstage函数: static int initf_bootstage(void){ bool from_s ...
- sftp接口机上传脚本
sftp只要有秘钥,就不需要输入密码. #!/bin/bash #上传现在时间的前一小时的文件 date=`date -d -1hour +%Y%m%d` hour=`date -d -1hour + ...