springcloud-Fuse Monitoring Hystrix dashboard and turbine

Source: Internet
Author: User

A pure Smile
Source: http://www.ityouknow.com/
Copyright belongs to the author, please specify the source of the reprint

Hystrix-dashboard is a real-time monitoring tool for Hystrix, through Hystrix dashboard we can visually see the request response time of each hystrix command, request the success rate and other data. But using only Hystrix dashboard, you can only see the service information in a single app, which is obviously not enough. We need a tool that allows us to summarize data from multiple services within the system and display it on the Hystrix dashboard, which is turbine.

Hystrix Dashboard

We changed on the basis of the fuse example Project Spring-cloud-consumer-hystrix, renamed: Spring-cloud-consumer-hystrix-dashboard.

1. Add 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>

These three packages must be added

2. Startup class

Start class add enable Hystrix dashboard and fuses

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

After starting the project to access Http://localhost:9001/hystrix, you will see the following interface:

There are a few hints in the diagram:

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 probably means that if you look at the default cluster using the first URL, view the specified cluster using the second URL, the monitoring of a single application uses the last one, we only show a single app for now, so enter in the input box: Http://localhost:9001/hystrix.stream , then click Monitor to enter the page.

If no request is shown first Loading ... , access to Http://localhost:9001/hystrix.stream will also continue to show pings.

Request Service Http://localhost:9001/hello/neo, you can see the effect of monitoring, first access to Http://localhost:9001/hystrix.stream, shown as follows:

ping: data: {"type":...}data: {"type":...}

Indicates that the results of the monitoring have been returned

The monitoring page will appear as follows:

In fact, it is the graphical display of Http://localhost:9001/hystrix.stream return results, hystrix Dashboard wiki details the meaning of each indicator on the graph, such as:

The fuse monitoring to this single application has been completed.

Turbine

In the complex distributed system, the same service nodes often need to deploy hundreds or even thousands of, many times, ops people want to be able to the same service node state as a whole cluster, so that can better grasp the state of the whole system. To do this, Netflix offers an open source project (Turbine) that aggregates multiple hystrix.stream content into a single data source for dashboard presentation.

1. Add dependencies
<dependencies><dependency><groupid>org.springframework.cloud</groupId><artifactid>spring-cloud-starter-turbine</artifactId></dependency><dependency><groupid>org.springframework.cloud</groupId><artifactId> Spring-cloud-netflix-turbine</artifactId></dependency><dependency>< Groupid>org.springframework.boot</groupId><artifactid>spring-boot-starter-actuator  </artifactId></dependency><dependency><groupId> Org.springframework.cloud</groupId><artifactid>spring-cloud-starter-hystrix-dashboard </artifactId></dependency></dependencies>       
2. Configuration files
  spring.application.name= Hystrix-dashboard-turbineserver.port=8001 Turbine.appconfig=node01,node02 Turbine.aggregator.clusterconfig= default Turbine.clusternameexpression= new String ("default")  Eureka.client.serviceurl.defaultzone=http://localhost:8000/eureka/  
    • turbine.appConfig: Configure the Serviceid list in Eureka to indicate which services are monitored
    • turbine.aggregator.clusterConfig: Specifies which clusters are aggregated, multiple uses, split, and defaults to default. Access can be used http://.../turbine.stream?cluster={clusterConfig之一}
    • turbine.clusterNameExpression: 1. CLUSTERNAMEEXPRESSION Specifies the cluster name, the default expression appname; At this point: you turbine.aggregator.clusterConfig need to configure the name of the app you want to monitor; 2. When Clusternameexpression:default, turbine.aggregator.clusterConfig do not write, Because the default is default;3. When clusternameexpression:metadata[' cluster '), assuming that the application you want to monitor is configured, eureka.instance.metadata-map.cluster: ABC you need to configure it andturbine.aggregator.clusterConfig: ABC
3. Startup class

Start class Add @EnableTurbine , activate support for turbine

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

To this turbine (hystrix-dashboard-turbine) configuration complete

4. Testing

Modify the caller Spring-cloud-consumer-node1 and Spring-cloud-consumer-node2 for two services on the basis of the sample project Spring-cloud-consumer-hystrix

Spring-cloud-consumer-node1 project changes are as follows: Application.properties file contents

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

Spring-cloud-consumer-node2 project changes are as follows: Application.properties file contents

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

Helloremote Class Modification:

@FeignClient(name=  "Spring-cloud-producer2" = helloremotehystrix. Class) public interface helloremote { @RequestMapping  (value =  "/hello" ) public string hello2 ( @RequestParam  (value =  "name" ) string name); }   

corresponding HelloRemoteHystrix and ConsumerController class following modification, specific view Code

After the modifications are complete, start Spring-cloud-eureka, Spring-cloud-consumer-node1, Spring-cloud-consumer-node1, Hystrix-dashboard-turbine (Turbine)

Open the Eureka background to see three services registered:

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

Return:

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

It is constantly refreshed to get real-time monitoring data, similar to a single monitor, and returns information about the monitoring project. For graphical monitoring view, enter: Http://localhost:8001/hystrix, return to the cool Little Bear interface, enter: Http://localhost:8001/turbine.stream, then click on Monitor Stream , you can see that there are two monitoring lists

Sample code

Reference:

Use Spring cloud and docker live micro Services

springcloud-Fuse Monitoring Hystrix dashboard and turbine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.