Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example analysis of Hystrix Dashboard and Turbine for springcloud fuse monitoring

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you the example analysis of springcloud fuse monitoring Hystrix Dashboard and Turbine, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Hystrix-dashboard is a tool for real-time monitoring of Hystrix. Through Hystrix Dashboard, we can directly see the request response time, request success rate and other data of each Hystrix Command. But if you only use Hystrix Dashboard, you can only see the service information in a single application, which is obviously not enough. We need a tool that allows us to aggregate data from multiple services in the system and display it on Hystrix Dashboard. This tool is Turbine.

Hystrix Dashboard

We changed it based on the circuit breaker sample project spring-cloud-consumer-hystrix and renamed it: spring-cloud-consumer-hystrix-dashboard.

1. Add dependencies

Org.springframework.cloud spring-cloud-starter-hystrix org.springframework.cloud spring-cloud-starter-hystrix-dashboard org.springframework.boot spring-boot-starter-actuator

These three packages must be added

2. Startup class

Start class add enable Hystrix Dashboard and fuse

@ SpringBootApplication@EnableDiscoveryClient@EnableFeignClients@EnableHystrixDashboard@EnableCircuitBreakerpublic class ConsumerApplication {public static void main (String [] args) {SpringApplication.run (ConsumerApplication.class, args);}}

3. Testing

When you visit http://localhost:9001/hystrix after starting the project, you will see the following interface:

There are some hints in the figure:

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream

Cluster via Turbine (custom cluster): http://turbine-hostname:port/turbine.stream?cluster=[clusterName]

Single Hystrix App: http://hystrix-app:port/hystrix.stream

It roughly means that if you look at the default cluster using the first url, the specified cluster uses the second url, and the monitoring of a single application uses the last, we only demonstrate a single application for the time being, so enter it in the input box:

Http://localhost:9001/hystrix.stream, enter and click monitor to go to the page.

If there is no request, Loading will be displayed first, and access to http://localhost:9001/hystrix.stream will continue to display ping.

If you request the service http://localhost:9001/hello/neo, you can see the monitoring effect. First, visit http://localhost:9001/hystrix.stream, which is shown as follows:

Ping:

Data: {"type": "HystrixCommand", "name": "HelloRemote#hello (String)", "group": "spring-cloud-producer", "currentTime": 1494915453986, "isCircuitBreakerOpen": false, "errorPercentage": 100," errorCount ": 1," requestCount ": 1," rollingCountBadRequests ": 0," rollingCountCollapsedRequests ": 0," rollingCountEmit ": 0," rollingCountExceptionsThrown ": 0," rollingCountFailure ": 0," rollingCountFallbackEmit ": 0," rollingCountFallbackFailure ": 0," rollingCountFallbackMissing ": 0," rollingCountFallbackRejection ": 0," rollingCountFallbackSuccess ": 1 "rollingCountResponsesFromCache": 0, "rollingCountSemaphoreRejected": 0, "rollingCountShortCircuited": 0, "rollingCountSuccess": 0, "rollingCountThreadPoolRejected": 0, "rollingCountTimeout": 1, "currentConcurrentExecutionCount": 0, "rollingMaxConcurrentExecutionCount": 0, "latencyExecute_mean": 0, "latencyExecute": {"0": 0, "25": 0, "50": 0, "75": 0, "90": 0, "95": 0, "99": 0, "99.5": 0,100 ": 0}," latencyTotal_mean ": 0 "latencyTotal": {"0": 0, "25": 0, "50": 0, "75": 0, "90": 0, "95": 0, "99": 0, "99.5": 0,100 ": 0}," propertyValue_circuitBreakerRequestVolumeThreshold ": 20," propertyValue_circuitBreakerSleepWindowInMilliseconds ": 5000," propertyValue_circuitBreakerErrorThresholdPercentage ": 50," propertyValue_circuitBreakerForceOpen ": false," propertyValue_circuitBreakerForceClosed ": false," propertyValue_circuitBreakerEnabled ": true," propertyValue_executionIsolationStrategy ":" THREAD "," propertyValue_executionIsolationThreadTimeoutInMilliseconds ": 1000 "propertyValue_executionTimeoutInMilliseconds": 1000, "propertyValue_executionIsolationThreadInterruptOnTimeout": true, "propertyValue_executionIsolationThreadPoolKeyOverride": null, "propertyValue_executionIsolationSemaphoreMaxConcurrentRequests": 10, "propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests": 10, "propertyValue_metricsRollingStatisticalWindowInMilliseconds": 10000, "propertyValue_requestCacheEnabled": true, "propertyValue_requestLogEnabled": true, "reportingHosts": 1, "threadPool": "spring-cloud-producer"}

Data: {"type": "HystrixThreadPool", "name": "spring-cloud-producer", "currentTime": 1494915453986, "currentActiveCount": 0, "currentCompletedTaskCount": 1, "currentCorePoolSize": 10, "currentLargestPoolSize": 1, "currentMaximumPoolSize": 10, "currentPoolSize": 1, "currentQueueSize": 0, "currentTaskCount": 1, "rollingCountThreadsExecuted": 0, "rollingMaxActiveThreads": 0, "rollingCountCommandRejections": 0, "propertyValue_queueSizeRejectionThreshold": 5, "propertyValue_metricsRollingStatisticalWindowInMilliseconds": 10000, "reportingHosts": 1}

Indicates that the monitoring results have been returned.

When you go to the monitoring page, the following figure is displayed:

In fact, it is the graphical display of the result returned by http://localhost:9001/hystrix.stream. The meaning of each metric on the Hystrix Dashboard Wiki is described in detail, as shown in the following figure:

The circuit breaker monitoring for this single application has been completed.

Turbine

In complex distributed systems, hundreds or even thousands of nodes with the same service often need to be deployed. in many cases, operators hope to show the state of the nodes with the same service in the form of an overall cluster. in this way, we can better grasp the state of the whole system. To this end, Netflix provides an open source project (Turbine) to provide the aggregation of the content of multiple hystrix.stream into a data source for Dashboard presentation.

1. Add dependencies

Org.springframework.cloud spring-cloud-starter-turbine org.springframework.cloud spring-cloud-netflix-turbine org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-hystrix-dashboard

2. Configuration file

Spring.application.name=hystrix-dashboard-turbineserver.port=8001turbine.appConfig=node01,node02turbine.aggregator.clusterConfig= defaultturbine.clusterNameExpression= new String ("default") eureka.client.serviceUrl.defaultZone= http://localhost:8000/eureka/

Turbine.appConfig: configure the serviceId list in Eureka to indicate which services to monitor

Turbine.aggregator.clusterConfig: specifies which clusters to aggregate, and multiple clusters are split using ",". The default is default. Can be accessed using one of the http://.../turbine.stream?cluster={clusterConfig}

Turbine.clusterNameExpression: 1. ClusterNameExpression specifies the cluster name, the default expression appName; at this time: turbine.aggregator.clusterConfig needs to configure the name of the application you want to monitor; 2. When clusterNameExpression: default, turbine.aggregator.clusterConfig can not write, because the default is default;3. When clusterNameExpression: metadata ['cluster'], assume that the application you want to monitor is configured with eureka.instance.metadata-map.cluster: ABC, then you need to configure it, and turbine.aggregator.clusterConfig: ABC

3. Startup class

Add @ EnableTurbine to the startup class to activate support for Turbine

@ SpringBootApplication@EnableHystrixDashboard@EnableTurbinepublic class DashboardApplication {public static void main (String [] args) {SpringApplication.run (DashboardApplication.class, args);}}

At this point, the Turbine (hystrix-dashboard-turbine) configuration is complete

4. Test

Based on the sample project spring-cloud-consumer-hystrix, it is modified to be the caller spring-cloud-consumer-node1 and spring-cloud-consumer-node2 of two services.

The spring-cloud-consumer-node1 project changes are as follows:

Application.properties file content

Spring.application.name=node01server.port=9001feign.hystrix.enabled=trueeureka.client.serviceUrl.defaultZone= http://localhost:8000/eureka/

The spring-cloud-consumer-node2 project changes are as follows:

Application.properties file content

Spring.application.name=node02server.port=9002feign.hystrix.enabled=trueeureka.client.serviceUrl.defaultZone= http://localhost:8000/eureka/

The HelloRemote class modifies:

FeignClient (name= "spring-cloud-producer2", fallback = HelloRemoteHystrix.class) public interface HelloRemote {@ RequestMapping (value = "/ hello") public String hello2 (@ RequestParam (value = "name") String name);}

The corresponding HelloRemoteHystrix and ConsumerController classes follow the modification. Check the code for details.

After modification, start spring-cloud-eureka, spring-cloud-consumer-node1, spring-cloud-consumer-node1, hystrix-dashboard-turbine (Turbine) in turn

When you open the eureka backend, you can see that three services are registered:

Visit http://localhost:8001/turbine.stream

Return:

: pingdata: {"reportingHostsLast10Seconds": 1, "name": "meta", "type": "meta", "timestamp": 1494921985839}

And will constantly refresh to obtain real-time monitoring data, indicating that similar to a single monitoring, the information of the monitoring project is returned. For a graphical monitoring view, enter: http://localhost:8001/hystrix, return to the cool bear interface, enter: http://localhost:8001/turbine.stream, and then click Monitor Stream, you can see that two monitoring lists appear

The above is all the contents of the article "sample Analysis of springcloud fuse Monitoring Hystrix Dashboard and Turbine". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report