SpringCloud Study - (六) Hystrix Dashboard

目标:

创建一个Dashboard 服务模块,输入配置有Dashboard的模块控制地址,可以监控地址的健康状况。

步骤:

1. 创建一个Dashboard 模块项目 SpringbootHystrixDashboard ,加入dashboard 支持依赖。

<?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>org.example</groupId>
    <artifactId>SpringbootHystrixDashboard</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.5.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>Greenwich.SR1</spring-cloud.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
            <version>1.4.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.netflix.hystrix</groupId>
            <artifactId>hystrix-javanica</artifactId>
            <version>1.5.12</version>
        </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>

2. 配置Application.peroperties 文件

server.port=9100
spring.application.name=Dashbaord

3.启动类上加入Dashboard的注解

@EnableHystrixDashboard

4. 启动danshboard 模块服务。在浏览器中访问dashboard 页面, 出现以下界面说明dashboard 服务配置成功。

URL : http://192.168.242.1:9100/hystrix

5. 在Consumer1 模块pom加入 dashboard 的支持依赖,用于dashboard 测试。

 

6. 在Consumer1 模块Application.properties 中开启短点控制权限

7.启动Consumer1 

8. 在浏览器中打开dashboard 界面 http://192.168.242.1:9100/hystrix ,输入Consumer1 的测试地址。点击【Monitor Stream】按钮。

http://localhost:7001/actuator/hystrix.stream

调用测试接口并刷新dashboard detail页面  ,dashboard 页面监控数据有变化。数据含义请参照detail 页面右上方的颜色对应说明。

测试接口:http://localhost:7001/hystrixTest ,

 

9. 通过访问Consumer1 的/actuator/hystrix.stream 地址可以访问Dashboard 相关的数据。

URL:http://192.168.242.1:7001/actuator/hystrix.stream

如果界面出现ping ping ping .... , 请先访问一次测试接口地址即可出现dashboard 数据。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值