Build a Spring Cloud Hystrix Dashboard to Monitor Circuit‑Breaker Metrics in Real Time
This guide walks through creating a Spring Cloud Hystrix Dashboard application, configuring its Maven dependencies, enabling the Hystrix stream on a service instance, and using the dashboard’s controls to monitor real‑time circuit‑breaker metrics such as health, traffic volume, and latency.
Hystrix records runtime metrics for each HystrixCommand and HystrixObservableCommand. These metrics are aggregated in a rolling time window and can be visualized with Hystrix Dashboard. This article shows how to build a Hystrix Dashboard in Spring Cloud and monitor a single service instance.
Prerequisites
eureka-server – service registry
eureka-client – service provider
eureka-consumer-ribbon-hystrix – consumer that uses Ribbon and Hystrix; its /consumer endpoint is annotated with @HystrixCommand so calls are recorded.
Step‑by‑step: Create the Dashboard Application
Create a standard Spring Boot project named hystrix-dashboard.
Add the required dependencies to pom.xml:
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Dalston.SR1</version>
<relativePath />
</parent>
<dependencies>
<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>
</dependencies>Enable the dashboard by adding @EnableHystrixDashboard to the main class:
@EnableHystrixDashboard
@SpringCloudApplication
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
}Optionally configure application.properties (e.g., change the port):
spring.application.name=hystrix-dashboard
server.port=1301Run the application and open http://localhost:1301/hystrix. The dashboard page loads but shows no data yet.
Expose the Hystrix Stream on the Monitored Service
To make /hystrix.stream available, add spring-boot-starter-actuator and ensure Hystrix dependencies are present in the service’s pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Also annotate the service’s main class with @EnableCircuitBreaker or @EnableHystrix to activate the circuit‑breaker.
Connect the Dashboard to the Stream
Enter the stream URL (for example http://localhost:2101/hystrix.stream) in the dashboard’s “Monitor Stream” field and click the button. The dashboard now displays real‑time metrics for the eureka-consumer-ribbon-hystrix instance.
Dashboard Controls
Delay: polling interval in milliseconds (default 2000 ms). Reducing it lowers client CPU and network usage. Title: text shown next to “Hystrix Stream”. By default it is the stream URL but can be customized.
Key Visual Elements
Solid circle: color indicates health (green → yellow → orange → red) and size reflects request volume.
Curve: shows relative traffic over the last two minutes.
Additional numeric metrics are displayed below the chart.
With the dashboard configured, developers can quickly spot unhealthy instances, monitor traffic spikes, and adjust circuit‑breaker settings based on live data.
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.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
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.
