Consul: Ability to set a tag on Consul's own service registration

Created on 23 Aug 2016  路  7Comments  路  Source: hashicorp/consul

It would be useful if consul was able to add tags to its own service registration. This could be to allow referring to particular instances by DNS or it could be for external uses such as Fabio proxy routing.

themservice-metadata typenhancement

Most helpful comment

A good use case for this is when using traefik's consul_catalog.

Consul's self registration gets picked up as a real service on port 8300. The way you tell traefik to ignore this is by setting a tag traefik.enable=false on the service (like traefik does to its own services):

% curl -s http://127.0.0.1:8500/v1/catalog/services | jq
{
  "consul": [],
  "traefik-dashboard": [
    "traefik.enable=false"
  ],
  "traefik-http": [
    "traefik.enable=false"
  ]
}

I stumbled across this issue looking for how to set a tag on consul's self-registration 馃槈

All 7 comments

Hi @far-blue - what uses were you thinking of? We probably should just have Consul tag itself automatically for most things (leader, follower seems like a good one for servers), any other use cases you had in mind?

leader / follower is a good example for an automated tag but tagging is also helpful just as labels for managing resources. Some third party apps such as Fabio and anything built using consul-template to react to service data also tend to use tags to identify or exclude services.

Are you looking to add tags related to Consul's service itself, though, or are you more looking for tags that represent the node as a whole?

That's a good question. I guess I was thinking in terms of Consul's Rest API as a service - much like Nomad and Vault present their API interface(s) as services and that is still my interest.

However, I guess it is also fair to say that nodes themselves could have tags rather than the consul service per-se. I guess this would be closer to Nomad's 'meta' info for agents. Grouping of nodes based on a tag would allow dns queries for nodes similar to services.

A good use case for this is when using traefik's consul_catalog.

Consul's self registration gets picked up as a real service on port 8300. The way you tell traefik to ignore this is by setting a tag traefik.enable=false on the service (like traefik does to its own services):

% curl -s http://127.0.0.1:8500/v1/catalog/services | jq
{
  "consul": [],
  "traefik-dashboard": [
    "traefik.enable=false"
  ],
  "traefik-http": [
    "traefik.enable=false"
  ]
}

I stumbled across this issue looking for how to set a tag on consul's self-registration 馃槈

I'm using tags to point Prometheus what services to scrape for metrics and what metric_path to use - this would be useful to be able to scrape from Consul's /v1/agent/metrics?format=prometheus endpoint

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eshujiushiwo picture eshujiushiwo  路  3Comments

philsttr picture philsttr  路  3Comments

wing731 picture wing731  路  3Comments

nicholasjackson picture nicholasjackson  路  3Comments

nschoe picture nschoe  路  4Comments