Hystrix服務監控Dashboard

Hystrix服務監控Dashboard儀表盤簡介

Hystrix提供了實時的服務調用監控項目Dashboard,能夠實時記錄通過Hystrix發起的請求的執行情況,可以通過圖表的形式展現給用戶看

Hystrix服務監控Dashboard的使用

新建一個項目(microservice-student-consumer-hystrix-dashboard-90),在pom里加入依賴:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.ue</groupId>
        <artifactId>microservice</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>microservice-student-consumer-hystrix-dashboard-90</artifactId>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--Hystrix服務監控Dashboard依賴-->
        <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>
    </dependencies>
</project>

application.yml配置如下:

server:
  port: 90
  context-path: /

在啓動類加@EnableHystrixDashboard註解,因爲這個項目不用跟數據庫打交道,所以也不用去讀數據庫配置:

package com.ue;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
@EnableHystrixDashboard
public class MicroserviceStudentConsumerHystrixDashboard90Application {

    public static void main(String[] args) {
        SpringApplication.run(MicroserviceStudentConsumerHystrixDashboard90Application.class, args);
    }

}

然後啓動這個項目,在瀏覽器輸入http://localhost:90/hystrix,可看到如下界面:

然後再來測試下,先啓動三個eureka,然後再啓動microservice-student-provider-hystrix-1004:

要監控的話,在瀏覽器輸入http://localhost:1004/hystrix.stream即可,然後會一直ping,data返回數據:

圖形化界面的使用如下:

測的時候可以先請求http://localhost:1004/student/getInfo接口後,再看界面上展示的數據:

界面上各指標的含義:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章