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接口后,再看界面上展示的数据:
界面上各指标的含义: