Integrating Hystrix Dashboard with Spring Cloud for Visual Service Circuit Breaker Monitoring – A Hands‑On Guide
This article walks through the background of Hystrix, shows how to add Hystrix Dashboard and Turbine dependencies to a Spring Cloud consumer project, configure the necessary annotations and properties, test the services, and use the dashboard and Turbine streams to visualize circuit‑breaker metrics for both single instances and clusters.
Background
Hystrix is a core component of Spring Cloud that isolates potentially failing remote calls to prevent system-wide crashes. While it protects services, operators still need a way to see which methods trigger circuit breaking.
Hystrix Dashboard Overview
Hystrix Dashboard visualizes key metrics such as request latency, error rate, and concurrent calls for each Hystrix command, helping developers and operators quickly assess system health.
1. Create a Service Consumer with Hystrix Dashboard
Copy the eureka-consumer-feign-hystrix project to a new module named eureka-consumer-hystrix-dashboard and add the following Maven dependencies to pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Enable the dashboard and circuit‑breaker annotations in the main application class:
@EnableHystrixDashboard
@EnableCircuitBreaker
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}Add the following properties to application.properties to enable Feign circuit breaking:
spring.application.name=eureka-consumer-hystrix-dashboard
server.port=9006
eureka.client.serviceUrl.defaultZone=http://localhost:8001/eureka/
feign.hystrix.enabled=trueStart eureka-server and the new consumer, then open http://localhost:9006/hystrix in a browser. The dashboard home appears, and the UI supports three monitoring modes:
Default cluster monitoring via http://turbine-hostname:port/turbine.stream Specified cluster monitoring via
http://turbine-hostname:port/turbine.stream?cluster=[clusterName]Single‑instance monitoring via http://hystrix-app:port/hystrix.stream For a single instance, paste its hystrix.stream URL into the dashboard’s URL field and click “monitor stream”. The dashboard shows a health‑status circle (color and size reflect instance health and traffic) and a 2‑minute traffic curve.
2. Integrate Turbine for Cluster Monitoring
To aggregate metrics from multiple service instances, use Netflix’s open‑source Turbine project.
2.1 Create a Turbine‑enabled Consumer
Copy the eureka-consumer project to eureka-consumer-hystrix-turbine and add these Maven dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>2.2 Enable Turbine
Add the Turbine and dashboard annotations to the main class:
@EnableTurbine
@EnableHystrixDashboard
@EnableDiscoveryClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}2.3 Turbine Configuration
In application.properties configure the Turbine settings:
spring.application.name=eureka-consumer-hystrix-turbine
server.port=9007
eureka.client.serviceUrl.defaultZone=http://localhost:8001/eureka/
turbine.app-config=eureka-consumer-hystrix-dashboard
turbine.cluster-name-expression="default"
turbine.combine-host-port=trueExplanation of the properties: turbine.app-config: comma‑separated list of service names whose hystrix.stream data should be aggregated. turbine.cluster-name-expression: defines the cluster name used in the dashboard URL (default is default). turbine.combine-host-port: when true, distinguishes services on the same host by combining host name and port.
2.4 Test the Turbine Setup
Start eureka-server, eureka-consumer-hystrix-dashboard, and eureka-consumer-hystrix-turbine. Access http://localhost:9007/hystrix and enter the Turbine stream URL http://localhost:9007/turbine.stream. The dashboard now displays aggregated metrics for the whole cluster, making it easier to spot faulty or overloaded instances across multiple nodes.
Conclusion
Hystrix Dashboard provides a clear view of individual service circuit‑breaker metrics, while Turbine aggregates those streams for cluster‑wide monitoring. Although Netflix has stopped maintaining Hystrix, the dashboard remains a valuable learning tool for microservice observability.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Pan Zhi's Tech Notes
Sharing frontline internet R&D technology, dedicated to premium original content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
