hystrixDashboard (Service Monitor)

1, the new project

microservicecloud-consumer-hystrix-dashboard

2, yml file

server:
  port: 9001

3, add the following in the pom.xml file

    <dependencies>
        <!-- 自己定义的api -->
        <dependency>
            <groupId>com.yufeng.springcloud</groupId>
            <artifactId>microservicecloud-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- 修改后立即生效,热部署 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>springloaded</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <!-- Ribbon相关 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-ribbon</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <!-- feign相关 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
        </dependency>
        <!-- hystrix和 hystrix-dashboard相关 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
    </dependencies>

4, the master boot class added EnableHystrixDashboard

@ EnableHystrixDashboard open the dashboard monitor notes

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

@SpringBootApplication
@EnableHystrixDashboard
public class DeptConsumer_DashBoard_App
{
    public static void main(String[] args)
    {
        SpringApplication.run(DeptConsumer_DashBoard_App .class, args);
    }
}

5, micro service providers add monitoring jar

For example: micro service provider microservicecloud-provider-dept-8001/8002/8003

pom.xml file, add the following jar package, in order to be monitoring dashboard

<!-- actuator监控信息完善 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

6, the test

(1) Start 3 eureka services;

(2) start a new monitoring service: microservicecloud-consumer-hystrix-dashboard

 

(3) access the browser: http: // localhost: 9001 / hystrix, if as shown below is displayed, the normal start micro-service monitoring service;

 

 


(3) start being monitored with a micro Hystrix service: microservicecloud-provider-dept-hystrix-8001

<1> Open browser: http: // localhost: 8001 / hystrix.stream (ie: http: // {hystrix-app}: {port} /hystrix.stream)

 

 

<2> 在9001的监控界面输入要监控的微服务(http://localhost:8001/hystrix.stream),如下所示:

 

 

 

显示以下监控内容:

 

 

 

(a)Deplay 该参数用来控制服务器上轮询监控信息的延迟时间,默认是2000毫秒,可以通过配置该属性来降低客户端的网络和cpu消耗。

(b)Title该参数对应了头部标题Hystrix Stream之后的内容,默认会使用哦具体监控实例的URL,可疑通过配置该信息来展示更合适的标题。

<4> 在浏览器中输入:http://localhost:8001/dept/get/1,并多次刷新,显示如下:

 

 

 

实心圆:共有两种含义。它通过颜色的变化代表了实例的健康程度,它的健康程度从 绿色 > 黄色 > 橙色 > 红色 递减;

该实心圆除了颜色的变化之外,它的大小也会根据实例的请求流量发生变化,流量越大实心圆就越大,所以通过该实心圆的展示,就可以在大量实例中快速的发现故障实例和高压力实例

<5> 说明

 

 

 

Guess you like

Origin www.cnblogs.com/yufeng218/p/11489175.html