`
raymond.chen
  • 浏览: 1418137 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Hystrix DashBoard监控面板

 
阅读更多

Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,提供了数据监控和友好的图形化界面。通过Hystrix Dashboard可以直观地看到Hystrix的各项指标信息。通过Hystrix Dashboard反馈的实时信息,可以帮助我们快速发现系统中存在的问题。

 

Spring Cloud Hystrix Dashboard的底层原理是间隔一定时间去“Ping”目标服务,返回的结果是最新的监控数据,最后将数据显示出来。

 

Hystrix Dashboard监控单实例节点需要通过访问实例的/hystrix.stream端点来实现的,所以需要为服务实例添加这个端点。

 

 

 

为服务消费者工程添加/hystrix.stream端点

    在pom.xml文件添加以下依赖:

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

 

 

    在启动类定义 ServletRegistrationBean 对象,配置hystix.stream端点

/**
 * SpringBoot2+版本需要手动配置hystrix.stream端点
 */
@Bean
public ServletRegistrationBean getServlet() {
	HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
	ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
	registrationBean.setLoadOnStartup(1);
	registrationBean.addUrlMappings("/hystrix.stream");
	registrationBean.setName("hystrixMetricsStreamServlet");
	return registrationBean;
}

 

 

    在浏览器访问hystix.stream端点,查看监控的指标信息

             http://localhost:9003/hystrix.stream


 

 

 

创建Hystrix DashBoard监控工程

    pom.xml文件关键配置:

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.7.RELEASE</version>
	<relativePath/>
</parent>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.8</java.version>
</properties>

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

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>Finchley.RELEASE</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

 

    启动类

    添加@EnableHystrixDashboard注解

@SpringBootApplication
@EnableHystrixDashboard //启用Hystrix Dashboard功能
public class Main {
	public static void main(String[] args) {
		SpringApplication.run(Main.class, args);
	}
}

 

    application.properties文件的配置

spring.application.name=hystrix-dashboard
server.port=6001

 

    运行该工程,在浏览器访问 http://localhost:6001/hystrix ,即可看到Hystrix Dashboard主界面


 

在主界面上输入一个服务消费者的hystix.stream端点地址,点击“Monitor Stream”按钮进行实时监控。仅使用Hystrix Dashboard只能监控到单个断路器的状态


 

监控页面详细说明如下图所示:


 

  • 大小: 270.9 KB
  • 大小: 49.6 KB
  • 大小: 45.3 KB
  • 大小: 30.7 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics