Spring Cloud使用Hystrix Dashboard(熔断仪表盘)查看监控数据

  • 内容
  • 评论
  • 相关

我们已经知道 Hystrix 提供了监控的功能,可以通过 hystrix.stream 端点来获取监控数据,但是这些数据是以字符串的形式展现的,实际使用中不方便查看。我们可以借助 Hystrix Dashboard 对监控进行图形化展示。

Hystrix Dashboard 是一款针对 Hystrix 进行实时监控的工具,通过 Hystrix Dashboard 可以直观地看到各 Hystrix Command 的请求响应时间,请求成功率等数据。

下面我们单独创建一个项目来集成 dashboard。

创建一个 Maven 项目 hystrix-dashboard-demo,在 pom.xml 中添加 dashboard 的依赖,代码如下所示。

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>

创建启动类,在启动类上添加 @EnableHystrixDashboard 注解,代码如下所示。

@SpringBootApplication
@EnableHystrixDashboard
public class DashboardApplication {

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

在属性配置文件中只需要配置服务名称和服务端口:

spring.application.name=hystrix-dashboard-demo
server.port=9011

然后启动服务,访问 http://localhost:9011/hystrix 就可以看到 dashboard 的主页,如图 1 所示。

dashboard主页
图 1  dashboard 主页

本文标题:Spring Cloud使用Hystrix Dashboard(熔断仪表盘)查看监控数据

本文地址:http://www.hosteonscn.com/6648.html

评论

0条评论

发表评论

邮箱地址不会被公开。 必填项已用*标注