首页 > 解决方案 > 带有 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 的管理界面,我注意到扳手端点和健康端点不一样:

我已经摆弄了一些设置,但是在管理设置、执行器设置和尤里卡设置之间,我不确定要配置哪一个才能使其工作。

我试过了:

我目前正在使用 spring boot 2.1.2.RELEASE 和 SBA 的匹配版本

标签: spring-bootnetflix-eurekaspring-boot-admin

解决方案


你能试试这些配置吗

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: "*"

推荐阅读