spring-boot - 带有 Eureka 客户端和自定义上下文路径的 Spring Boot 管理员在健康状态上失败
问题描述
我已将我的 Spring Boot 应用程序配置monitor-client
为注册到 Eureka。我有一个单独的 spring boot admin (SBA) 应用程序monitor
,它监视注册到 Eureka 的所有应用程序。
如果我的应用程序中未设置上下文路径,则一切正常。但是,如果设置了上下文路径,SBA 将不再显示正确的信息。从文档看来,我需要更新我已经完成的 Eureka 的元数据属性。
我的monitor
应用程序配置如下:
应用程序属性:
spring.application.name=monitor-client
server.servlet.context-path=/monitor-client
server.port=9876
# Monitoring config
management.endpoints.web.exposure.include=*
eureka.instance.metadataMap.management.context-path=/monitor-client/actuator
我的应用程序显示为“离线”,但我可以浏览“洞察”选项卡中的所有详细信息。我想 SBA 正确访问了执行器端点,但错误地使用了 /health 端点,我不明白这怎么可能?
如果我去 SBA 的管理界面,我注意到扳手端点和健康端点不一样:
- 本地主机:9876/monitor-client/actuator(扳手)
- 本地主机:9876/执行器/健康(健康)
我已经摆弄了一些设置,但是在管理设置、执行器设置和尤里卡设置之间,我不确定要配置哪一个才能使其工作。
我试过了:
- management.endpoints.web.base-path
- eureka.instance.health-check-url-path
我目前正在使用 spring boot 2.1.2.RELEASE 和 SBA 的匹配版本
解决方案
你能试试这些配置吗
server:
servlet:
context-path: /monitor-client
#management config
eureka:
instance:
health-check-url-path: /actuator/health
metadata-map:
management.context-path: /monitor-client/actuator
client:
serviceUrl:
defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/
management:
endpoint:
health:
show-details: always
endpoints:
web:
base-path: /actuator
exposure:
include: "*"
推荐阅读
- r - 删除列中的部分字符串 (R)
- python - 在这种情况下使用文本文件存储数据的最佳方式是什么?
- java - 从 Artifactory 远程存储库下载大型工件
- python - 使用curve_fit的Python非线性回归误差
- python - 将 Pandas 多索引作为元组列表返回?
- scala - Slick - 如何在没有主键的情况下插入表
- google-apps-script - 粘贴到特定列 - Google 表格
- nativescript - 如何使用 RadListView 制作手风琴列表?(本机脚本)
- laravel - Laravel - 避免模型中的代码重复
- android - Android Espresso 分片随机失败并出现 INSTALL_FAILED_INVALID_APK