概述
1.hystrix项目修改
对hystrix进行监控,要使得hystrix项目有actuator功能
这首先需要添加springboot-actuator.
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
以及配置hystrix.stream端点打开
server:
port: 8101
spring:
application:
name: hystrix-service
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
service-url:
user-service: http://user-service
#打开hystrix.stream端点
management:
endpoints:
web:
exposure:
include: 'hystrix.stream'
2.新建监控项目hystrixdashboard
pom.xml
<properties>
<spring.cloud-version>Hoxton.SR8</spring.cloud-version>
</properties>
<dependencies>
<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-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
java启动类
@EnableHystrixDashboard
@EnableDiscoveryClient
@SpringBootApplication
public class HystrixDashBoardApp {
public static void main(String[] args) {
new SpringApplicationBuilder(HystrixDashBoardApp.class).run(args);
}
}
application.yml
server:
port: 8501
spring:
application:
name: hystrix-dashboard
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka/
hystrix:
dashboard:
proxyStreamAllowList: 'localhost'
注意:
- 此时hystrix项目端口是8101,hystrixdashboard项目的端口是8501
- hystrix:dashboard:proxyStreamAllowList是为了解决Hystrix 仪表盘功能出现Unable to connect to Command Metric Stream.的异常解决方案一个问题https://blog.csdn.net/dmw412724/article/details/115575454
启动eurekaserver/hystrix/hystrixdashboard项目
打开http://localhost:8501/hystrix
输入监控的项目
点击确定就进入了监控的页面
如果此时你访问http://localhost:8101/aaa?id=1触发断路器。那么这个页面上的监控数据就会变化
这个页面的响应对应的解释如下:
最后
以上就是紧张汉堡为你收集整理的SpringCloud的hystrixdashboard监控的全部内容,希望文章能够帮你解决SpringCloud的hystrixdashboard监控所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复