Fork me on GitHub

SpringCloud个人笔记-07-Hystrix-Dashboard初体验

 

  • sb-cloud-hystrix-dashboard

 

Hystrix Dashboard,它主要用来实时监控Hystrix的各项指标信息。通过Hystrix Dashboard反馈的实时信息,可以帮助我们快速发现系统中存在的问题

但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine

 

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.huarui</groupId>
    <artifactId>sb_cloud_hystrix_dashboard</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>sb_cloud_hystrix_dashboard</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.19.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

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

    <dependencies>
        <!-- eureka client -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>

        <!-- -hystrix-dashboard依赖 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
        
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
pom.xml
spring:
  application:
    name: sb-cloud-hystrix-dashboard


eureka:
  client:
    serviceUrl:
      defaultZone: http://39.108.85.204:8761/eureka/
  #instance:
    #注册时使用ip而不是主机名
    #prefer-ip-address: true
    #指定ip
    #ip-address: ip
server:
  port: 9007
application.yml
@SpringBootApplication
@EnableHystrixDashboard //启用HystrixDashboard
public class SbCloudHystrixDashboardApplication {

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

}

 

访问 http://localhost:9007/hystrix

 

  监控之前的 sb-cloud-hystrix项目,单实例情况下访问 http://hystrix-app:port/hystrix.stream

  但是得在 sb-cloud-hystrix项目中要添加依赖。

  添加actuator依赖后访问 http://localhost:9006/hystrix.stream 出现ping 即可

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

 

 

最终测试结果如下:

 

posted @ 2019-03-17 10:49  youxiu326  阅读(109)  评论(0编辑  收藏  举报