问题描述
我已经使用Netflix-OSS库开发了微服务应用程序。我在本地主机:9091 / hystrix上运行的Hystrix仪表板上遇到问题。我想监视微服务A和微服务B之间的请求指标。端点“ hystrix.stream”已经注册。
hystrix仪表板在加载时卡住,但未显示任何结果。
我检查了浏览器,发现jquery错误- 未被捕获的TypeError:e.indexOf不是似乎是jquery版本问题的函数。
我正在使用Jdk 14版本和Spring Boot 2.3进行开发
解决方法
@bob0the0mighty
I am adding code snippet for your reference. This is my springboot main class
@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableHystrixDashboard
public class DramaServiceApplication {
}
My controller looks like :
@GetMapping("/acts")
@com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand(fallbackMethod = "fallbackMethodForGetActor",commandKey = "test-Act",groupKey = "test-Act")
public ActorList getActors() {
ActorList actorList = restTemplate.getForObject("http://actor-service/actor/actorsList",ActorList.class);
return actorList;
}
public ActorList fallbackMethodForGetActor() {
return new ActorList(" Requested Actor page is under maintenance!!");
}
application.yml file looks like :
management:
endpoints:
web:
base-path: /
exposure:
include: hystrix.stream,health,info,metrics
After hitting request multiple times,I am getting hystrix dashboard as "loading" always
and screen looks like
[enter image description here][1]
[1]: https://i.stack.imgur.com/hOeZf.png
,
将spring-cloud-dependencies版本更新为“ Hoxton.SR7”对我来说解决了这个问题。 带有弹簧云依赖版本“ Hoxton.SR6”的jquery 3.4.1出现问题。
您可以在此处获取问题的详细信息和解决方案。 https://github.com/spring-cloud/spring-cloud-netflix/issues/3811 https://github.com/spring-cloud/spring-cloud-netflix/pull/3817
,This issue got fixed by adding following configuration changes:
1. Updating Hoxton to SR7 in pom.xml:
<properties>
<java.version>14</java.version>
<spring-cloud.version>Hoxton.SR7</spring-cloud.version>
</properties>
2. Add these entries in application.yml:
hystrix:
dashboard:
proxy-stream-allow-list: '*'
management:
endpoints:
web:
base-path: /
exposure:
include: '*'
3. Creating a separate config Java class:
package com.ibm.drama.controller;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
@Configuration
public class HystrixConfig {
@Bean
public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean<HystrixMetricsStreamServlet> registrationBean = new ServletRegistrationBean<HystrixMetricsStreamServlet>(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/actuator/hystrix.stream");
registrationBean.setName("hystrix.stream");
return registrationBean;
}
}