Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mapping metadata of service (registered in Eureka) to ServiceMeta… #16

Merged

Conversation

ziebapawel
Copy link
Contributor

Firstly I would like to thank you for creating this library. It's very helpful.
Several months ago we've started to monitoring our applications by Prometheus.
Most of the time Consul has been used as Discover Service but two weeks ago we've decided to use Eureka with Eureka Consul Adapter as Discovery Service. Our services are registered with additional metadata and we use them in relabeling phase of Prometheus. During relabeling phase we use following meta label __meta_consul_service_metadata_<key>. With Consul it works correctly but with Eureka with Eureka Consul Adapter it doesn't work as we expected. We noticed that metadata associated with service (registered in Eureka) appears as NodeMeta instead of ServiceMeta. In our opinion metadata of service registered in Eureka should appear as ServiceMeta because these metadata are associated with service, not with node of Consul.

We've made changes that make metadata of service (registered in Eureka) appears as ServiceMeta.

For backward compatibility we introduce following properties:

  • eurekaConsulAdapter.useNodeMeta : boolean (default: false)
  • eurekaConsulAdapter.nodeMetaPrefix : String (default: "")

Possible scenarios of usage:

1

  • eurekaConsulAdapter.useNodeMeta is not set or is set to false
  • eurekaConsulAdapter.nodeMetaPrefix in this case is not used
    each metadata of service (registered in Eureka) appears as ServiceMeta, NodeMeta map is empty

2

  • eurekaConsulAdapter.useNodeMeta is set to true
  • eurekaConsulAdapter.nodeMetaPrefix is not set (default value) or is set to "" (empty string)
    each metadata of service (registered in Eureka) appears as NodeMeta, ServiceMeta map is empty

3

  • eurekaConsulAdapter.useNodeMeta is set to true
  • eurekaConsulAdapter.nodeMetaPrefix is set to e.g. nodeMeta_
    each metadata of service (registered in Eureka) is filtered according to the following rules:
    • metadata which key begins with nodeMeta_ is moved to NodeMeta map (during moving prefix is removed nodeMeta_k1 -> k1)
    • metadata which key not begins with nodeMeta_ is moved to ServiceMeta map

@tine2k
Copy link
Collaborator

tine2k commented Apr 1, 2019

Thanks for your PR @ziebapawel. Please give me a couple a days for the review. Work is very busy atm :(

@tine2k tine2k merged commit 7562b74 into twinformatics:master Apr 5, 2019
@tine2k
Copy link
Collaborator

tine2k commented Apr 5, 2019

@ziebapawel I merged your PR and released your changes as version 1.3.0. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants