SpringCloud之Hystrix Dashboard的简单实现

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_31122833/article/details/97780431

步骤一:服务注册中心的改进(作为Hystrix Dashboard入口,设置密码访问)

1、在服务注册中心添加如下依赖:
        <!--认证jar包-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <!--hystrix监控-->
        <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>
        </dependency>
2、在服务注册中心的启动类上添加如下注解:
        @EnableHystrixDashboard
3、在服务注册中心的.properties配置文件中添加如下内容:
        security.basic.enabled=true
        security.user.name=root
        security.user.password=root

步骤二:网关zuul的改进(路由规则已经写好了)

1、.properties配置添加如下内容:
        #这里按照项目服务名称写,我需要监控这三个服务
        turbine.appConfig=spring-cloud-website,spring-cloud-user,spring-cloud-project
        turbine.aggregator.clusterConfig=default
        turbine.clusterNameExpression=new String("default")
        turbine.instanceUrlSuffix=/api/hystrix.stream

步骤三:

1、启动微服务;
2、地址栏输入注册中心地址:例如我的注册中心端口是9001
    地址:http://localhost:9001/hystrix,然后输入用户名密码
3、在Hystrix页面输入网关配置的Hystrix.stream的访问地址
    例如:localhost/api/hystrix.stream(我网关的端口是80,自动省略)
4、点击monitor stream按钮

截图:

猜你喜欢

转载自blog.csdn.net/qq_31122833/article/details/97780431