我是靠谱客的博主 痴情芒果,最近开发中收集的这篇文章主要介绍turbine、hystrix熔断监控图出现loading或Unable to connect to Command Metric Stream的一些坑,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
提取码:qlu9
一、被监控的服务设置。
1、pom中必须添加以下包。
<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>
<!--想要用spring-cloud-netflix-hystrix-dashboard
但是@enablehystrixdashboard引入不进去
属于springBot版本问题,使用以下包,begin-->
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
<!-- 默认使用的版本是 2.2.2.RELEASE-->
<version>2.2.2.RELEASE</version>
</dependency>
<!--@enablehystrixdashboard包引入End-->
2、配置文件中必须添加暴露端点,如果是使用Feign进行熔断设置,还需配置熔断开启。
#暴露端点
management.endpoints.web.exposure.include=*
#开启feign熔断
feign.hystrix.enabled=true
3、启动类中要使用以下注解。
@EnableHystrix
@EnableEurekaClient
--EnableFeignClients注解在使用feign熔断时使用
@EnableFeignClients
@EnableCircuitBreaker
二、监控服务
1、pom中添加以下包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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-hystrix</artifactId>
</dependency>
<!--想要用spring-cloud-netflix-hystrix-dashboard
但是@enablehystrixdashboard引入不进去
属于springBot版本问题,使用以下包,begin-->
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
<!-- 默认使用的版本是 2.2.2.RELEASE-->
<version>2.2.2.RELEASE</version>
</dependency>
<!--@enablehystrixdashboard包引入End-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2、如果是turbine整合,还需引入以下包
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
3、单个监控服务启动类配置,“@EnableHystrixDashboard”必须添加。
package com.example.hystrixdashboard;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
@SpringBootApplication
@EnableDiscoveryClient
@EnableHystrixDashboard
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
}
4、整合多个服务监控启动类配置,“@EnableTurbine”必须添加。
package com.example.hystrixturbine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
@SpringBootApplication
@EnableHystrixDashboard
@EnableTurbine
public class HystrixTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixTurbineApplication.class, args);
}
}
最后
以上就是痴情芒果为你收集整理的turbine、hystrix熔断监控图出现loading或Unable to connect to Command Metric Stream的一些坑的全部内容,希望文章能够帮你解决turbine、hystrix熔断监控图出现loading或Unable to connect to Command Metric Stream的一些坑所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复