Overriding Default Configurations

David Liu edited this page May 6, 2016 · 6 revisions

Eureka comes with in-built defaults which works for most of the scenarios. In case, you want to override the default configurations, there are 3 types of configurations you might want to look at.

You can extend the following default configuration classes to provide your own configuration value by using any mechanism you would like.

Important: Please do not use the interfaces, they are just for documentation purposes and is likely to change in the future.

Note that the above also serves as the documentation of default configuration values for all of the above configurations available with Eureka.

Adding custom metadata to registration information

Sometimes, you may want to add custom metadata specific to your deployment environment for registration and query. For example, you may want to propagate a custom environment id that should be available for your specific deployment env. Eureka offers the ability to add custom metadata as key:value pairs outside of the standard registration data. You can do this in two ways:

Accessing metadata

String myValue = instanceInfo.getMetadata().get("myKey");

statically set via configuration:

any config of the form eureka.metadata.mykey=myvalue will have the k:v pair mykey:myvalue added to eureka's metadata map.

dynamically set via code:

To dynamically do this, you will need to first provide your own custom implementation of the EurekaInstanceConfig interface. You can then overload the public Map<String, String> getMetadataMap() method to return a metadata map that contains the desired metadata values. See PropertiesInstanceConfig for an example implementation that provides the configuration based system above.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.