SpringCloud-hystrix-dashboard实战01

服务监控

端口修改

server.port=19000

pom依赖:

<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix-dashboard -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    <version>2.1.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>2.1.2.RELEASE</version>
        </dependency>

启动类中增加#EnableHystrixDashboard注解

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
@EnableHystrixDashboard
public class ApplicationConsumerhystrixDashboard {
    private static Logger logger = Logger.getLogger(ApplicationConsumerhystrixDashboard.class);

    /**
     * Start
     */
    public static void main(String[] args) {
        SpringApplication.run(ApplicationConsumerhystrixDashboard.class, args);
//        logger.info("SpringBoot Start Success");
    }
}

检查服务提供者是否增加了监控依赖

<!--actuator监控信息完善-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
服务提供者中添加监控依赖

验证服务启动ok

启动eureka集群

eureka集群

启动一个服务提供者


证明服务提供者启动ok

服务提供项目启动之后访问不到http://localhost:18084/hystrix.stream,添加以下配置及bean

#application.properties中
management.endpoints.web.exposure.include="*"
#启动类中注入bean
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registration.addUrlMappings("/hystrix.stream");
        return registration;
    }

访问 http://localhost:18084/hystrix.stream 出现好多个ping

这个属于正常情况(只有ping,没有数据)

将这个地址添加到hystrixDashboard中,如下图:

将这个地址添加到hystrixDashboard中

点击monitor stream会出现如下展示:

这个属于正常情况

访问服务提供者接口,如下图:

再次访问 http://localhost:18084/hystrix.stream 会看到有数据出现,如下图:

我们刷新dashboard的监控页面,会看到如下图:

发现有图形,有折线图

如何看图

7色
一圈
一线

多次访问服务提供者,会发现折线图上升,绿色的实心圆不断变大

实心圆变大,折线图上升,说明接口调用在增加

实心圆的两种含义

它通过颜色的变化代表了实力的健康程度,它的健康度从绿色<黄色<橙色<红色递减,红色代表服务基本不可用了。
该实心圆除了颜色的变化之外,它的大小也会根据实例的请求流量发生变化,流量越大,该实心圆就越大。所以通过该实心圆的展示,就可以在大量实例中快速的发现故障和高压力实例

整图说明

整图说明.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容