避坑指南(二):hystrix.stream端點404問題


轉載請注明作者及出處:

作者:銀河架構師

原文鏈接:https://www.cnblogs.com/luas/p/12166607.html

問題描述

在項目中集成斷路器監控的時候,訪問/actuator/htstrix.stream經常會遇到404問題,如下圖所示:

 

此問題根本原因就在於此端點壓根就沒創建,所以,才會報404錯誤。

分析解決

如何排查呢?具體有以下幾點:

 

actuator依賴

查確認否引入了spring-boot-starter-actuator依賴。另外,spring-boot-starter-actuator、spring-cloud-starter-netflix-hystrix、spring-cloud-starter-netflix-hystrix-dashboard三個依賴,缺一不可。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</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>

 

@EnableHystrixDashboard注解

確認啟動類是否引入了@EnableHystrixDashboard注解。

 

@EnableCircuitBreaker注解

確認啟動類是否添加了@EnableCircuitBreaker注解。這個是忽略比較多的一項重要原因。

 

@EnableHystrix

如果項目基於ribbon,確認啟動類是否添加了@EnableHystrix注解。

 

feign開啟hystrix

feign.hystrix.enabled是否為true。需要注意的是,此參數不會影響端點創建,只會影響feign的熔斷降級功能是否開啟。

 

配置

確認management.endpoints.web.exposure.include包含的有hystrix.stream,或者直接為'*'。此項為最常見的原因,前面都檢查過了,都沒問題,那就100%是這個原因了。

management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream
management:
  endpoints:
    web:
      exposure:
        include: '*'

 

最后,如果全部點均排除完畢,配置也正確,那么,啟動項目之后,查看控制台,出現如下提示即算成功。

 

明確提示,注冊hystrix.stream-actuator-endpoint端點/actuator/hystrix.stream成功

 

刷新/actuator/hystrix.stream端點,已正常出現ping命名獲取數據。

 


 

微信搜索【銀河架構師】,發現更多精彩。

技術資料領取方法:關注公眾號,回復微服務,領取微服務相關電子書;回復MK精講,領取MK精講系列電子書;回復JAVA 進階,領取JAVA進階知識相關電子書;回復JAVA面試,領取JAVA面試相關電子書,回復JAVA WEB領取JAVA WEB相關電子書。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM