【SpringCloud NetFlix】Hystrix监控

Hystrix监控

调用方引入依赖,监控客户端

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

新建项目

hystrix-dashboard

引入依赖

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

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

配置主启动类

@SpringBootApplication
//开启Hystrix监控
@EnableHystrixDashboard
public class DashboardApp {

    public static void main(String[] args) {
        new SpringApplicationBuilder(DashboardApp.class).properties("server.port=8082").run(args);
    }
}

分别启动

服务注册中心、服务注册端、服务调用端、服务监控端

访问:http://localhost:8082/hystrix

访问服务调用端请求:http://localhost:8081/hello

ping服务调用情况:http://localhost:8081/hystrix.stream

访问监控页面:http://localhost:8082/hystrix 输入需要监控的服务调用方:http://localhost:8081/hystrix.stream

这里写图片描述

这里写图片描述
以上为疯狂SpringCloud微服务架构实战学习笔记
感谢杨恩雄老师:https://my.oschina.net/JavaLaw

猜你喜欢

转载自blog.csdn.net/zlt995768025/article/details/81668095