December 03, 2019

Part 8: Microservices (Hystrix Dashboard)


What is Hystrix Dashboard and how can we add it in our Spring Boot App?
Hystrix also provides an optional feature to monitor all of your circuit breakers in a visually-friendly fashion.

Steps to add Hystrix Dashboard:
1). We need to add spring-cloud-starter-netflix-hystrix-dashboard and spring-boot-starter-actuator in the pom.xml.
2). To enable it we have to add the @EnableHystrixDashboard annotation to our main class.
3). Also, in our application.properties let's include the stream, 'management.endpoints.web.exposure.include= hystrix.stream'. Doing so exposes the /actuator/hystrix.stream as a management endpoint.



Hystrix Dashboard Demo

Let's add dashboard dependencies in 'depart-employee-details'
 < dependency >  
    < groupid > org.springframework.cloud < /groupid > 
    < artifactid > spring-cloud-starter-netflix-hystrix-dashboard < /artifactid > 
    < version > 2.2.3.RELEASE < /version >
< /dependency > 
< dependency > 
    < groupid > org.springframework.boot < /groupid > 
    < artifactid > spring-boot-starter-actuator < /artifactid >
< /dependency >

Add @EnableHystrixDashboard in main class of 'depart-employee-details' [i.e DepartEmployeeDetailsApplication.java]. Then we need to add below property in our application.properties, this will expose the /actuator/hystrix.stream as a management endpoint.

management.endpoints.web.exposure.include= hystrix.stream

After this start discovery-server and depart-employee-details (for the time being we will not start department-details and employee-details, so that we can test fallbacks). And then open http://localhost:8081/hystrix in browser.
To check the hystrix dashboard, access the getDetails API a couple of times (by opening it in http://localhost:8081/details/getDetails) and then go to hystrix dashboard add the URL https://localhost:8081/actuator/hystrix.stream and click on Monitor Stream.

Download the code till now from below GIT url:
GIT URL: microservices

-K Himaanshu Shuklaa..

No comments:

Post a Comment