5

I am setting up the spring boot admin using spring cloud. Now I have set up a stand alone eureka server and one spring boot admin and some spring boot apps as admin clients. If I don't set management.context-path for all the clients, everything works fine. But Now I need to monitor all clients(some with no management.context-path, some with different management.context-paths). I know that I should use the meta-data to achieve this, but after reading the relative docs, I still could get this done. Here are my configurations on client and admin sides.

Client side:

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}}

Admin side:

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'

Questions:

  1. I set the spring.boot.admin.discovery.converter.management-context-path to be /mgmt, the value is the same as the client side and this only works fine if I set all the client apps with the same value, and this is impossible. How should I do to support different 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).

leo
  • 583
  • 2
  • 7
  • 20

1 Answers1

13

On the client:

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

As described in the 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.

joshiste
  • 2,638
  • 1
  • 14
  • 19
  • Hi, If I want to set different `management.context-path` for different clients, what should I set in the admin side for `spring.boot.admin.discovery.converter.management-context-path`? – leo Nov 09 '16 at 12:47
  • How to set this config `spring.boot.admin.discovery.converter` on the admin side? @joshiste – leo Nov 09 '16 at 13:05
  • leave `spring.boot.admin.discovery.converter.management-context-pat‌​h` empty (default) – joshiste Nov 09 '16 at 13:36
  • 1
    if you set `eureka.instance.metadata-map.management.context-path=${management.context-path}` on all clients sba will use the individal values from the metadata. – joshiste Nov 09 '16 at 13:37
  • 1
    You are right, I made it works this way. Thanks so much. – leo Nov 10 '16 at 03:17
  • @joshiste : What if my management.port is different ? I understand that we can set the port also within this metadata-map but that doesnt solve for healthCheckUrlPath. Currently, I have ${management.context-path}/health, but I want it to use the management.port for health check as well (without giving the entire path with hostname). Any suggestions? PS : Not posting as a new question since I thought this question was much relevant here since its very related. – PavanSandeep Nov 23 '16 at 17:27
  • You can force the Spring Boot Admin to use the `DefaultServiceInstanceConverter` if you add a bean of this type. Then the `management.port` from the instance metadata is used to construct the healthUrl. And the healthCheckUrlPath from Eureka is ignored. – joshiste Nov 23 '16 at 17:57
  • I was chasing spring-admin configurations not fully groking the fact that spring-admin was only getting the values from eureka!! This worked perfectly! – Kieveli Mar 13 '19 at 14:15