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实例在执行过程 ...
随机推荐
- .net 分布式锁
原文 : 浅解.Net分布式锁的实现 序言 我晚上有在公司多呆会儿的习惯,所以很多晚上我都是最后一个离开公司的.当然也有一些同事,跟我一样喜欢在公司多搞会儿.这篇文章就要从,去年年末一个多搞会的晚 ...
- Java学习:通过Scanner读取文件
Scanner不仅能够读取用户的键盘输入,还可以读取文件输入. 需要在创建Scanner对象的时候传入一个File对象作为参数.代码如下: import java.util.Scanner; impo ...
- 77. Combinations (JAVA)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- 2019-11-29-Roslyn-使用-Directory.Build.props-文件定义编译
title author date CreateTime categories Roslyn 使用 Directory.Build.props 文件定义编译 lindexi 2019-11-29 08 ...
- asp.net WebApi WebApiConfig.cs Web API 配置和服务
public static void Register(HttpConfiguration config) { ............................... var jsonSett ...
- Laravel-admin 加载视图后,blade 模板 JS 失效
laravel-admin js无法解析 解决 在不需要使用 pjax 的地方使用 Admin::disablePjax();
- puppet自动化搭建lnmp架构
puppet自动化安装lnmp架构 3nginx的搭建 mkdir -p /etc/puppet/modules/nginx/{manifests,files} vim /etc/puppet/mod ...
- mariadb索引、视图、关联查询、备份恢复、外键
连接查询(两张表关联查询) 在sql语句中,- - 代表注释 内关联查询(查询两张表的交集) select * from 表1 inner join 表2 on 表1.id=表2.id(此处id是表1 ...
- putty ssh常用命令小结
打开putty 输入VPS的IP地址输入root回车输入密码回车 vps 更改文件夹所属组 cd /home/vpsuser/domains/afish.cnblogs.com/ chown -R v ...
- robotframework调用外部python多次运行拿到的都是同一个值
外部python是一个爬虫,爬取的内容的定义没有放入函数中.导致一次爬取多次使用的情况出现. 第一版函数如下: 改版后: