This is the sixth article in the Spring Cloud column, and knowing the first five will help you understand it better:

  1. Spring Cloud first article | Spring Cloud preface introduces an overview and its commonly used components

  2. The second Spring Cloud | use and understand Eureka registry

  3. Spring Cloud third | build a high availability Eureka registry

  4. Spring Cloud fourth article | client side load balancing Ribbon

  5. The fifth canto of Spring Cloud fusing Hystrix | service

Introduction to Hystrix Dashboard monitoring

The Hystrix Dashboard, like a Dashboard in a car that displays data about the car in real time, The Hystrix dashboard is designed to monitor Hystrix performance in real time. Through the dashboard, we can see Hystrix indicators and quickly find problems in the system. To use the Hystriⅸ dashboard, we need a Hystrix first Dashboard is a feature that we can add on top of the original consumer application, so that the original consumer application can have the Hysr Dashboard function, but the general idea of microservices architecture is to advocate the separation of services, Hystrix Dashboard is also a service, so a new project is usually created exclusively for the Hystrix Dashboard service. The functions of Hystrix Dashboard are shown in the figure below

Hystrix dashboard monitoring applications

1. Create a new module named (SpringCloud-Hystrix-Dashboard)

2. Add Dashboard dependencies that depend on Hystrix

<! - hystrix - dashboard functions rely on start, dashboard features - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency>Copy the code

Dependencies may not download at this point, you can add Ali cloud repository

<repositories>
    <repository>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>Copy the code

3. Add the @enablehystrixDashboard annotation to the startup class

4, port configuration for 3721, to which we hystrix monitoring service is set up, start to http://localhost:3721/hystrix

The Hystrix dashboard project has been created. We need to have a service that provides a /actuator/hystrix.stream interface, and then the Hystrix dashboard can be used to monitor the service

5. Transform Consumers (Springcloud-service-consumer)

We transformed the consumer services to provide/skeletonoid /hystrix.stream. The steps are as follows:

5-1. The consumer project needs to be Hystrix dependent, which was added when the service fuse was used in the previous case

5-2. A SpringBoot service monitoring dependency is required, which can be added directly to the parent module dependency

<! --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>Copy the code

5-3. Configuration file You need to configure the endpoint access permission for Springboot monitoring

Because endPoints can contain a lot of sensitive information,
Health and info can be accessed directly by default.
# so we give them all access to (*), or specify springBoot monitor endpoint access,
#* indicates that all endpoints are allowed access. If only hystrix.stream is written, it will turn off the default info and health endpoints
management:
  endpoints:
    web:
      exposure:
        include: ["info"."health"."hystrix.stream"]Copy the code

As you can see from the console log

The 2019-08-07 15:58:31. 7396-187 the INFO [ost startStop - 1] O.S.B.A.E.W eb. ServletEndpointRegistrar: Registered'/actuator/hystrix.stream' to hystrix.stream-actuator-endpointCopy the code

6, the first visit, to visit other belt with the fuse interfaces, access: http://localhost:9090/actuator/hystrix.stream

Note: To access /hystrix.stream, first visit any of the fuses in the SpringCloud-service-consumer project. Otherwise, when accessing /hystrix.stream directly, A string of ping: ping:…. is output

7, to http://localhost:9090/actuator/hystrix.stream fill in to the Hystrix Dashboard Dashboard, directly on the Internet to find a detailed diagram, the diagram below

Detailed reference case source: gitee.com/coding-farm…