Moment For Technology

Hystrix DashBoard and BUG: Unable to connect to Command Metric Stream Fixed

Posted on Aug. 12, 2023, 4:18 a.m. by Gina Harrell
Category: The back-end Tag: Spring Cloud


Hystrix is used for service downsizing, service flow limiting, and service fusing. There is a Hystrix DashBoard tool that monitors the status of services that use Hystrix. Here's a summary of the configuration of this thing.

Hystrix DashBoard configuration is used

1. New module

Here the author uses the previously established module cloud-consumer-Hystrix-Dashboard9001 as an example

2. The configuration of pom

Important dependency items are listed here, and service registration is also required. I used Eureka

/dependencyCopy the code

3. The configuration application. Yml

server: port: 9001 eureka: instance: hostname: localhost ... . spring: application: name: hystrix-dashboardCopy the code

4. Primary boot class

5. Start the HystrixDashBoard service

After simple configuration, you can start the 9001 HystrixDashBoard service

The browser type http://localhost:9001/hystrix, access to success

Hystrix Dashboard supports three different monitoring methods

  1. The default cluster monitoring: through the URL: http://turbine-hostname:port/ open, realize to the default cluster monitoring.
  2. The specified cluster monitoring: through the URL: http://turbine-hostname:port/ Cluster =[clusterName] Enable to monitor the clusterName cluster.
  3. Monitoring a single application: Use the URL:http://hystrix-app:port/ to monitor a specific service instance.
  4. Delay: controls the Delay for polling monitoring information on the server. The default value is 2000 milliseconds. You can configure this property to reduce the network and CPU consumption of the client.
  5. Title: This parameter shows the appropriate Title.

Looking at the Eureka service registry, the registration is successful

6. Start service monitoring

This service must use Hystrix, otherwise loading.. Unable to connect to Command Metric Stream

Cloud-provider-hystrix-payment8005 is degraded using the previously configured Hystrix service

The browser to return to http://localhost:9001/hystrix

If nothing goes wrong, we're out, YEAH! O (* ̄▽ ̄*)

Of course, it may not be so smooth (▔ : ▔)≡

BUG: Unable to connect to Command Metric Stream

It is possible that this BUG will still appear, because of the BUG after the Spring Cloud version was upgraded, and the hoxton.sr1 I used will ( ̄,  ̄)

The solution is to add the following code to 8005, the main startup class of the service to be listened on

public ServletRegistrationBean getServlet() {    
    HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();        
    ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);    
    return registrationBean;
Copy the code

Just like that, and then you can access it normally

As for how to use after launch, please refer to the website or other materials

Hope to be helpful to you! (~ ~ ▽ ~) ~

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.