如何在 eureka 发现环境下正确设置 management.context-path for spring boot admin client?

How to correctly set management.context-path for spring boot admin client under eureka discovery environment?

我正在使用 spring 云设置 spring 引导管理员。现在我已经设置了一个独立的尤里卡服务器和一个 spring 引导管理员和一些 spring 引导应用程序作为管理客户端。如果我不为所有客户端设置 management.context-path,一切正常。但是现在我需要监视所有客户端(有些没有 management.context-path,有些有不同的 management.context-path)。我知道我应该使用元数据来实现这一点,但是在阅读了相关文档之后,我仍然可以完成它。这是我在客户端和管理端的配置。

客户端:

spring:
  application:
    instance_id: user
    name: microservice-provider-user
management:
  context-path: '/mgmt'
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    preferIpAddress: false
    statusPageUrlPath: ${management.context-path}${endpoints.info.path:/info}
    healthCheckUrlPath: ${management.context-path}${endpoints.health.path:/health}
    metadata-map:
      instanceId:
${spring.application.name}:${spring.application.instance_id:${random.value}}

管理员端:

spring:
  application:
    name: wahaha-admin
  boot:
    admin:
      routes:
        endpoints: env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,hystrix.stream,turbine.stream

      url: http://${HOST_NAME:localhost}:${server.port}
      discovery:
        converter.management-context-path: '/mgmt'

问题:

  1. 我将 spring.boot.admin.discovery.converter.management-context-path 设置为 /mgmt,该值与客户端相同,只有当我将所有客户端应用程序设置为相同值时,这才有效,这是不可能的。支持不同的应该怎么办management.context-path?

PS: I did all of these on my local desktop not on any public cloud, and will move to the product env later(still not using public cloud).

在客户端:

eureka:
  instance:
    metadata-map:
      management.context-path: ${management.context-path}

docs所述:

If you want to customize the default conversion of services you can either add health.path, management.port and/or mangament.context-path entries to the services metadata.