Hystrix仪表板始终显示加载屏幕。

huangapple go评论77阅读模式
英文:

Hystrix dashboard always showing loading screen

问题

I have developed Micro service application using Netflix-OSS libraries. I am facing issue on Hystrix dashboard running on localhost:9091/hystrix. I want to monitor request metrics between Micro service-A and Micro service-B. Endpoint "hystrix.stream" is already registered.

hystrix dashboard stucks on loading without showing any results.

I inspected browser and found jquery error -
Uncaught TypeError: e.indexOf is not a function which seems to be a jquery version issue.

I am using Jdk 14 version and Spring boot 2.3 for my development

英文:

I have developed Micro service application using Netflix-OSS libraries. I am facing issue on Hystrix dashboard running on localhost:9091/hystrix. I want to monitor request metrics between Micro service-A and Micro service-B. Endpoint "hystrix.stream" is already registered.

hystrix dashboard stucks on loading without showing any results.

I inspected browser and found jquery error -
Uncaught TypeError: e.indexOf is not a function which seems to be a jquery version issue.

I am using Jdk 14 version and Spring boot 2.3 for my development

答案1

得分: 1

@bob0the0mighty
我正在为您提供代码片段供参考。这是我的Spring Boot主类:
@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableHystrixDashboard
public class DramaServiceApplication {
}

我的控制器如下:
@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("请求的演员页面正在维护中!");
}

application.yml文件如下:

management:
  endpoints:
    web:
      base-path: /
      exposure:
        include: hystrix.stream, health, info, metrics

多次发送请求后,我始终得到Hystrix仪表板显示为“加载中”,并且屏幕看起来像这样:
[查看图像描述][1]

[1]: https://i.stack.imgur.com/hOeZf.png
英文:
            @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

得分: 0

Updating the spring-cloud-dependencies version to "Hoxton.SR7" resolved the problem for me.
There is an issue with jquery 3.4.1 with spring-cloud-dependencies version "Hoxton.SR6".

You can get the details of the issue and the fix here.
https://github.com/spring-cloud/spring-cloud-netflix/issues/3811
https://github.com/spring-cloud/spring-cloud-netflix/pull/3817

英文:

Updating the spring-cloud-dependencies version to "Hoxton.SR7" resolved the problem for me.
There is an issue with jquery 3.4.1 with spring-cloud-dependencies version "Hoxton.SR6".

You can get the details of the issue and the fix here.
https://github.com/spring-cloud/spring-cloud-netflix/issues/3811
https://github.com/spring-cloud/spring-cloud-netflix/pull/3817

答案3

得分: 0

这个问题通过添加以下配置更改来解决:

  1. 在 pom.xml 中更新 Hoxton 到 SR7 版本:
<properties>
    <java.version>14</java.version>
    <spring-cloud.version>Hoxton.SR7</spring-cloud.version>
</properties>
  1. 在 application.yml 中添加以下条目:
hystrix:
  dashboard:
    proxy-stream-allow-list: '*'

management:
  endpoints:
    web:
      base-path: /
      exposure:
        include: '*'
  1. 创建一个单独的配置 Java 类:
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;
    }
}
英文:
This issue got fixed by adding following configuration changes:
1. Updating Hoxton to SR7 in pom.xml:
   &lt;properties&gt;
		&lt;java.version&gt;14&lt;/java.version&gt;
		&lt;spring-cloud.version&gt;Hoxton.SR7&lt;/spring-cloud.version&gt;
	&lt;/properties&gt;
2. Add these entries in application.yml:
hystrix:
  dashboard:
    proxy-stream-allow-list: &#39;*&#39;        
        
management:
  endpoints:
    web:
      base-path: /
      exposure:
        include: &#39;*&#39;
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&lt;HystrixMetricsStreamServlet&gt; getServlet() {
		HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
		ServletRegistrationBean&lt;HystrixMetricsStreamServlet&gt; registrationBean = new ServletRegistrationBean&lt;HystrixMetricsStreamServlet&gt;(streamServlet);
		registrationBean.setLoadOnStartup(1);
		registrationBean.addUrlMappings(&quot;/actuator/hystrix.stream&quot;);
		registrationBean.setName(&quot;hystrix.stream&quot;);
		return registrationBean;
	}
}

huangapple
  • 本文由 发表于 2020年8月13日 18:45:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63393432.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定