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

Exposing consul service instance meta data #196

Open
m1keil opened this issue Nov 13, 2020 · 10 comments
Open

Exposing consul service instance meta data #196

m1keil opened this issue Nov 13, 2020 · 10 comments

Comments

@m1keil
Copy link
Contributor

m1keil commented Nov 13, 2020

Currently, consul_exporter exposes both catalogue KV and service tags via consul_service_tag.

Registered services in consul can also expose metadata which is a KV structure but without the special meaning of tags during lookups.

I wonder if support for service metadata is something that you would consider adding in a future release?

@simonpasquier
Copy link
Member

I would need to dig deeper into this but maybe could you give me a concrete example?

@m1keil
Copy link
Contributor Author

m1keil commented Feb 3, 2021

Service instances in Consul can include both tags and meta:

The tags property is a list of values that are opaque to Consul but can be used to distinguish between primary or secondary nodes, different versions, or any other service level labels.

The meta object is a map of max 64 key/values with string semantics (...). All those meta data can be retrieved individually per instance of the service and all the instances of a given service have their own copy of it.

We use the meta where we want to attach metadata to a service and don't require any special DNS handling. Stuff like service version, service owner, and so on.
From what I can tell, the meta is only exposed in Web UI or the HTTP API, not the Consul CLI.

So exposing this metadata with consul_exporter can be useful, for example, it can expose service versions in one central location without the need to instrument every service individually with info_* metrics.

For example, today consul_exporter exposes tags like this:

consul_service_tag{service_id="_nomad-client-c753udjlfd7tszi4r5hgwuypz3n4xwey", tag="http"} 1

Would be nice if similarly we could see the meta:

consul_service_meta{service_id="_nomad-client-c753udjlfd7tszi4r5hgwuypz3n4xwey", key1="value1", key2="value2"} 1

@simonpasquier
Copy link
Member

I can see how it could potentially lead to high label cardinality. At the very least it should be behind a flag.
Does it make sense to be able to filter which keys get exported (e.g. like it's done for K/V pairs)?

@m1keil
Copy link
Contributor Author

m1keil commented Feb 6, 2021

Yep, that would make sense, similar to kv filter.

Its been a while since I wrote Go, but I can give it a crack, would a PR be welcome?

@simonpasquier
Copy link
Member

sure go for it :)

@m1keil
Copy link
Contributor Author

m1keil commented May 2, 2021

Took me a while to get back to it but just opened a PR for initial attempt. Let me know if I'm in a good direction. Cheers.

@rfelgent
Copy link

rfelgent commented May 25, 2021

Hi @m1keil ,

I have the same requirement: using "consul_service_meta" instead of "consul_service_tag". What's the current status ?

@m1keil
Copy link
Contributor Author

m1keil commented May 25, 2021

I opened up an initial PR with a POC (#204), waiting to hear feedback from maintainers if this is the way to go.

@roidelapluie
Copy link
Member

I will look at this in the coming days.

@m1keil
Copy link
Contributor Author

m1keil commented May 26, 2021

no worries @roidelapluie, cheers!

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

No branches or pull requests

4 participants