标签:open one port serve href turn artifact ping board
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-metrics-event-stream</artifactId>
<version>1.5.18</version>
</dependency>
package com.itlaoqi.springcloud.memberserviceopenfeign;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableFeignClients
public class MemberServiceOpenfeignApplication {
// 被引入的bean
@Bean
public ServletRegistrationBean hystrixServlet(){
HystrixMetricsStreamServlet servlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
registrationBean.setLoadOnStartup(1);
return registrationBean;
}
public static void main(String[] args) {
SpringApplication.run(MemberServiceOpenfeignApplication.class, args);
}
}
<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>
server:
port: 9100
spring:
application:
name: hystrix-dashboard
eureka:
client:
service-url:
defaultZone:
http://localhost:8761/eureka
package com.itlaoqi.springcloud.hystrix.dashboard.dashboardservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
@SpringBootApplication
@EnableHystrixDashboard
public class DashboardServiceApplication {
public static void main(String[] args) {
SpringApplication.run(DashboardServiceApplication.class, args);
}
}
在 浏览器 输入 http://localhost:9100/hystrix
注意:springboot2.2.x, hystrix-dashboard监控页面一直显示loading的问题 (https://blog.csdn.net/weixin_43493520/article/details/106646860?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.nonecase)
我的其他微服务 使用的是 2.3.x版本 。但是2.3.X 版本的 dashboard 前端代码有问题。所以该用2.1.x 版本的dashboard 。使用正常
springCloud(十二) hystrix dashboard
标签:open one port serve href turn artifact ping board
原文地址:https://www.cnblogs.com/guhualin/p/13194266.html