metadataMap
in a Eureka client. Bound it to the SCS Eureka server by adding them in your Spring configurationapplication.yml
and that will add a value-pair to the metadata:
eureka: instance: metadata-map: author: my-dev-team department : our-dept
View the registered app details from Eureka Service using the /eureka/apps endpoint:
<applications> <versions__delta>1</versions__delta> <apps__hashcode>UP_1_</apps__hashcode> <application> <name>greeter-message</name> <instance> <instanceId>eureka-client.apps.smoke.springapps.io:58e84ed7-714e-4d83-4c08-9288</instanceId> <hostName>eureka-client.apps.smoke.springapps.io</hostName> <app>greeter-messages</app> ... </dataCenterInfo> ... <metadata> <author>my-dev-team</author> <department>our-dept</department> </metadata> </application> </applications>
One thing to note when attempting to add metadata to a Eureka server is that the metadata may take a moment to appear in the Eureka server if the client was already registered prior to the metadata being added. If you had an already running client with no metadata then add a metadata and restart the client; it may take about 1.5 minutes for the metadata to appear in Eureka Server. This is expected, as Eureka tends to cache things and also will wait for heartbeat to refresh cache.
Another useful scenario of specifying a custom metadata map is for customizing your spring.application.name. You can combine this to reference CF env variables. Below is a sample config:
eureka: instance: instanceId: ${spring.application.name}:${vcap.application.instance_id}:${vcap.application.application_version}:${vcap.application.application_uris}:${CF_INSTANCE_IP}:${CF_INSTANCE_PORT} metadata-map: appContainerIp: ${CF_INSTANCE_IP} appContainerPort: ${CF_INSTANCE_PORT}