[JAVA] Circuit Breaker Pattern with Apache Camel Part 2 (Try Hystrix Dashboard)

Introduction

I tried Hystrix in the previous article Circuit breaker pattern with Apache Camel. Hystrix has a Dashboard that can graphically display the state of the circuit, so this time I will move it.

The combination of Apache + Spring Boot seems to be able to run Hystrix Dashboard using Spring Cloud Netflix components. However, I will not use Spring Boot this time, so let's run Hystrix Dashboard in a standalone application.

Output Hyryx Metrics in your application

Use hystrix-metrics-event-stream to allow your application to output Hyrix Metrics.

First, add the following library (for Maven).

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

Embed jetty in your application to make hystrix-metrics-event-stream available. The URL is "http: //localhost:8090/hystrix.stream".

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

~ Omitted ~

			Server server = new Server(8090);
			ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
			server.setHandler(servletContext);
			final HystrixMetricsStreamServlet servlet = new HystrixMetricsStreamServlet();
			final ServletHolder holder = new ServletHolder(servlet);
			servletContext.addServlet(holder, "/hystrix.stream");
			server.start();

Download and launch the standalone version of Hystrix Dashboard

First, go to the following page and download the Hystrix Dashboard standalone version jar file.

As of January 2019, 1.5.6 was the latest version. The downloaded file will be "standalone-hystrix-dashboard-1.5.6-all.jar".

After downloading, execute the following command to start Hystrix Dashboard.

>java -jar standalone-hystrix-dashboard-1.5.6-all.jar
21:13:03.272 [vert.x-eventloop-thread-0] INFO  c.g.k.h.c.s.d.HystrixDashboardVerticle - Initializing the HystrixDashboardVerticle instance 1
21:13:03.571 [vert.x-eventloop-thread-0] INFO  c.g.k.h.c.s.d.HystrixDashboardVerticle - Compression support enabled: true
21:13:03.901 [vert.x-eventloop-thread-0] INFO  c.g.k.h.c.s.d.HystrixDashboardVerticle - Listening on port: 7979
21:13:03.901 [vert.x-eventloop-thread-0] INFO  c.g.k.h.c.s.d.HystrixDashboardVerticle - Access the dashboard in your browser: http://localhost:7979/hystrix-dashboard/
21:13:03.902 [vert.x-eventloop-thread-1] INFO  i.v.c.i.l.c.VertxIsolatedDeployer - Succeeded in deploying verticle

The URL to access the Hystrix Dashboard is as follows.

http://localhost:7979/hystrix-dashboard/

When you access it, the following screen will be displayed.

image.png

After the screen is displayed, enter "http: //localhost:8090/hystrix.stream" in the text box below the text "Eureka Application ~" and click the "Add Stream" button. .. Next, click the "Monitor Streams" button to move to the screen below.

hystrixdashboard.gif

When the error rate exceeds 50%, "Circuit" is set to open. How to read the graph is as follows.

image.png

reference

Recommended Posts

Circuit Breaker Pattern with Apache Camel Part 2 (Try Hystrix Dashboard)
Circuit Breaker Pattern with Apache Camel
Circuit Breaker Pattern I checked