美文网首页
Spring Cloud Hystrix Dashboard

Spring Cloud Hystrix Dashboard

作者: 歌哥居士 | 来源:发表于2019-03-30 12:34 被阅读0次

    添加依赖

    <?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>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.3.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
        <groupId>org.baozi</groupId>
        <artifactId>cloud-hystrix</artifactId>
        <version>1.0</version>
        <packaging>pom</packaging>
    
        <modules>
            <module>hystrix-registration</module>
            <module>hystrix-provider</module>
            <module>hystrix-consumer</module>
            <module>hystrix-dashboard</module>
        </modules>
    
    
        <properties>
            <java.version>1.8</java.version>
            <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
        </properties>
    
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </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>
    
    <?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>
       <parent>
          <groupId>org.baozi</groupId>
          <artifactId>cloud-hystrix</artifactId>
          <version>1.0</version>
          <relativePath>..</relativePath>
       </parent>
    
       <artifactId>hystrix-dashboard</artifactId>
    
    
    </project>
    

    服务消费者

    1. 确保被监控的(这里是前面的服务消费者)添加了@EnableCircuitBreaker或者@EnableHystrix。
    2. 修改application.properties,开放actuator。
    spring.application.name=hystrix-consumer
    server.port=11000
    
    eureka.client.service-url.defaultZone=http://localhost:9000/eureka
    
    management.endpoints.web.exposure.include=*
    management.endpoint.health.show-details=always
    

    Hystrix Dashboard

    spring.application.name=hystrix-dashboard
    server.port=12000
    
    eureka.client.service-url.defaultZone=http://localhost:9000/eureka
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
    
    @SpringBootApplication
    @EnableHystrixDashboard
    public class HystrixDashboardApplication {
    
       public static void main(String[] args) {
          SpringApplication.run(HystrixDashboardApplication.class, args);
       }
    
    }
    

    访问:http://localhost:12000/hystrix

    hystrix-dashboard
    单体监控:输入http://localhost:11000/actuator/hystrix.stream hystrix-dashboard

    实心圆:共有两种含义。
    1.颜色代表实例的健康度,健康度从绿色、黄色、橙色、红色递减。
    2.大小也会根据实例的请求流量发生变化,流量越大该实心圆就越大。

    相关文章

      网友评论

          本文标题:Spring Cloud Hystrix Dashboard

          本文链接:https://www.haomeiwen.com/subject/mfxhvqtx.html