springcloud-Hystrix图形化Dashboard搭建

Hystrix也能做对服务的监控,观察服务被调用的情况。下面是步骤:

  1.创建一个模块,用于监控其他服务

  2.添加依赖

    <dependencies>
# 该依赖是hystrix核心监控的依赖
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>cn.aib.springcloud</groupId>
            <artifactId>springclud-api-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
# 该依赖是用于监控的
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>

  3.添加配置

server:
  port: 9001

  4.主启动

@SpringBootApplication
@EnableHystrixDashboard #该注解是激活监控
public class HysDashApplication {
    public static void main(String[] args) {
        SpringApplication.run(HysDashApplication.class, args);
    }
}

  接下来只需要启动本模块,访问:http://locahost:9001/hystrix,如果出现界面则代表成功

原文地址:https://www.cnblogs.com/ibcdwx/p/14440468.html