Hystrix 仪表板总是显示加载屏幕
Posted
技术标签:
【中文标题】Hystrix 仪表板总是显示加载屏幕【英文标题】:Hystrix dashboard always showing loading screen 【发布时间】:2020-12-03 04:48:31 【问题描述】:我使用 Netflix-OSS 库开发了微服务应用程序。我在 localhost:9091/hystrix 上运行的 Hystrix 仪表板上遇到问题。我想监控微服务 A 和微服务 B 之间的请求指标。端点“hystrix.stream”已注册。
hystrix 仪表板卡在加载时没有显示任何结果。
我检查了浏览器,发现 jquery 错误 - 未捕获的 TypeError:e.indexOf 不是一个似乎是 jquery 版本问题的函数。
我正在使用 Jdk 14 版本和 Spring boot 2.3 进行开发
【问题讨论】:
你能添加你得到的实际错误吗?从您的帖子中,我假设 e 是一种没有 indexOf 的对象,而不是 jquery 版本问题。 【参考方案1】: @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
【讨论】:
【参考方案2】:将 spring-cloud-dependencies 版本更新为“Hoxton.SR7”解决了我的问题。 带有 spring-cloud-dependencies 版本“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
【讨论】:
【参考方案3】: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;
【讨论】:
以上是关于Hystrix 仪表板总是显示加载屏幕的主要内容,如果未能解决你的问题,请参考以下文章
在 PCF 上部署 Spring Boot 的 Hystrix 仪表板不显示指标