之前讨论了Hystrix的监控,但访问/hystrix.stream端点获得的数据是以文字形式展示的。很难通过这些数据,一眼看到系统当前的运行状态。
可使用Hystrix Dashboard,从而让监控数据图形化,可视化。
下面通过一个例子说明。
一 创建项目microservice-hystrix-dashboard
二 为项目添加下面依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
三 编写启动类,在启动类上添加@EnableHystrixDashboard
package com.itmuch.cloud.study;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
}
四 在配置文件中添加如下内容
server:
port: 8030
五 测试
1 启动该项目
2 访问http://localhost:8030/hystrix,可以看到Hystrix Dashboard的主页
3 在该主页中,地址栏中输入http://localhost:8020/hystrix.stream,随意设置一个title,并点击Monitor Stream按钮,将看到下面界面
4 界面说明