1

I am new to Hystrix Dashboard. I have written sample application with Hystrix. I want to see the Hystrix chart (command metric stream). But I am getting the below error:

Circuit: Unable to connect to Command Metric Stream
Thread Pools: Loading...

I am using STS with Maven.

Below is the code used:

Simple server microservice application (Spring boot web running in port 8085)

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
@SpringBootApplication
public class BookstoreApplication {

    @RequestMapping(value = "/recommended")
    public String readingList(){
    return "Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)";
    }

    public static void main(String[] args) {
    SpringApplication.run(BookstoreApplication.class, args);
    }
}

Simple client microservice application (Spring boot web running in port 8095) I have included the dependency of Hystrix and Hystrix Dashboard along with Web, so all the Hystrix dependencies are in classpath

package hello;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.net.URI;

@Service
public class BookService {

    private final RestTemplate restTemplate;

    public BookService(RestTemplate rest) {
    this.restTemplate = rest;
    }

    @HystrixCommand(fallbackMethod = "reliable")
    public String readingList() {
    URI uri = URI.create("http://localhost:8090/recommended");

    return this.restTemplate.getForObject(uri, String.class);
    }

    public String reliable() {
    return "Cloud Native Java (O'Reilly)";
    }

}


package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.web.client.RestTemplate;

@EnableHystrixDashboard
@EnableHystrix
@EnableCircuitBreaker
@RestController
@SpringBootApplication
public class ReadingApplication {

    @Autowired
    private BookService bookService;

    @Bean
    public RestTemplate rest(RestTemplateBuilder builder) {
    return builder.build();
    }

    @RequestMapping("/to-read")
    public String toRead() {
    return bookService.readingList();
    }

    public static void main(String[] args) {
    SpringApplication.run(ReadingApplication.class, args);
    }
}

By running the above code, the hystrix is working fine, when the BooKStoreApplication is down, it is going to fallback method.

Both the urls are working fine. Normal Case:

http://localhost:8085/recommended
Output: Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)

http://localhost:8095/to-read
Output: Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)


When BookStoreApplication is down (http://localhost:8085/recommended) accessing http://localhost:8095/to-read returns "Cloud Native Java (O'Reilly)" as expected.

But when I tried to invoke this url http://localhost:8095/hystrix, I am getting the Hystrix DashBoard Page and asking for the stream value.

I have tried given http://localhost:8095/ or http://localhost:8095/to-read, and clicked "Monitor Stream" and it is going to next page with error:

Circuit: Unable to connect to Command Metric Stream
Thread Pools: Loading...
Alykoff Gali
  • 1,121
  • 17
  • 32
Ahmed
  • 83
  • 1
  • 6

1 Answers1

4

I've experienced the same. The main problem was, that I didn't have the actuator dependency in my maven pom. So I could not get the hystrix stream.

  1. Include the spring-boot-actuator.
  2. Check if localhost:8085/health is running.
  3. Try to enter localhost:8085/hystrix.stream to stream value in Hystrix Dashboard.
  4. Execute the service few times -> the dashboard should show the monitored method/command.
RadekSohlich
  • 182
  • 1
  • 3
  • 11