Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hystrix Dashboard not working

Tags:

I am using REST service in springboot application. I am working on Hystrix to enable metrics. So, I deployed hystrix dashboard war in a tomcat server of version 7. I am able to open the page http://localhost:8080/hystrix-dashboard/. After I added the stream url and clicked on Monitor streams button, It takes me to the monitor page, Where all I can see is the message " Unable to connect to command metrix stream". When I look into the hystrix console, I see the below message repeatedly. PLease help me!

2016-10-04 07:23:28 INFO  com.netflix.turbine.discovery.InstanceObservable$1:289 [InstanceObservable$1] [run]: Hosts up:1, hosts down: 0
2016-10-04 07:23:28 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:460 [InstanceMonitor] [getNextStatsData]: no more data from c
onnection to 138.12.51.246
2016-10-04 07:23:28 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:477 [InstanceMonitor] [retryHostConnection]: Re-initing host
connection: 138.12.51.246 default
2016-10-04 07:23:30 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:460 [InstanceMonitor] [getNextStatsData]: no more data from c
onnection to 138.12.51.246
2016-10-04 07:23:30 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:477 [InstanceMonitor] [retryHostConnection]: Re-initing host
connection: 138.12.51.246 default
2016-10-04 07:23:31 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:460 [InstanceMonitor] [getNextStatsData]: no more data from c
onnection to 138.12.51.246
2016-10-04 07:23:31 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:477 [InstanceMonitor] [retryHostConnection]: Re-initing host
connection: 138.12.51.246 default
2016-10-04 07:23:32 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:460 [InstanceMonitor] [getNextStatsData]: no more data from c
onnection to 138.12.51.246
2016-10-04 07:23:32 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:477 [InstanceMonitor] [retryHostConnection]: Re-initing host
connection: 138.12.51.246 default
2016-10-04 07:23:33 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:460 [InstanceMonitor] [getNextStatsData]: no more data from c
onnection to 138.12.51.246
2016-10-04 07:23:33 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:477 [InstanceMonitor] [retryHostConnection]: Re-initing host
connection: 138.12.51.246 default
2016-10-04 07:23:35 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:460 [InstanceMonitor] [getNextStatsData]: no more data from c
onnection to 138.12.51.246
2016-10-04 07:23:35 INFO  com.netflix.turbine.monitor.instance.InstanceMonitor:477 [InstanceMonitor] [retryHostConnection]: Re-initing host
connection: 138.12.51.246 default
2016-10-04 07:23:36 INFO 
like image 487
Kaliappan Avatar asked Oct 04 '16 11:10

Kaliappan


1 Answers

Found the answer.. We need to add MIME type as text/event-stream in the response header. The fix I write here for specific to Springboot integration with Hystrix dashboard. All you need to do is,

1) Add metrics event stream dependency in your pom.xml

<dependency>
    <groupId>com.netflix.hystrix</groupId>
    <artifactId>hystrix-metrics-event-stream</artifactId>
    <version>1.5.5</version>
</dependency>

2) Add new servlet with Bean annotation in your SpringApplication class

@Bean
public ServletRegistrationBean servletRegistration() {
 ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet(), "/hystrix.stream"); 
 return registration;
}

3) Return the response with response header having text/event-stream MIME type. Even, if you have another content type as application/xml, no matter, you can this new one too.

HttpHeaders resHeaders = new HttpHeaders();
resHeaders.add("Content-Type", "application/xml; charset=utf-8");
resHeaders.add("Content-Type", "text/event-stream; charset=utf-8");
if(!isError){
return new ResponseEntity<String>(responseXml, resHeaders, HttpStatus.OK);
}
else{
return new ResponseEntity<com.test.pack.fault.Error>(error, resHeaders,HttpStatus.CREATED);
    }

4) Download and deploy the Hystrix dashboard war file in Tomcat server of version 7 or more and start the server.

5) Open the dashboard with url, http://localhost:port/hystrix-dashboard

6) In the hystrix home page, add the application url as http://localhost:port/contextPath(if any)/hystrix.stream. Then click add stream buttom and click on monitor stream button. The hystrix.stream is the url mapping that we've have given in servlet registration.

like image 96
Kaliappan Avatar answered Sep 22 '22 16:09

Kaliappan