SpringCloud的hystrixdashboard监控

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触发断路器。那么这个页面上的监控数据就会变化
这个页面的响应对应的解释如下:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值