queries for multiple tags
We would like the ability to query multiple tags via DNS and HTTP.
An example of this would be using environment name as a tag, but also needing additional tag functionality such as master/slave. For example to get the master mysql server in the qa environment, we'd like the service to publish both those tags and allow a DNS query such as:
dig @127.0.0.1 -p 8600 master.qa.mysql.service.consul. ANY
Or for HTTP:
curl 'http://localhost:8500/v1/catalog/service/mysql?tag=master&tag=qa
Or whatever HTTP param syntax is sensible (I suppose multiple params named the same would not work. Perhaps an array syntax is needed).
For DNS, I'm not sure how easy it would be to support multiple tags in the format I suggested, so a delimiter could also work. Perhaps master_qa.mysql.service.consul using underscore as a delimiter. Although this would remove the ability to put underscore in tags.
This is somewhat related to #290 since it solves the multiple environments problem for those that are willing to use tags. After much internal discussion, we are.
+1 -- tag intersections should be supported, at least for the HTTP API. DNS is another matter: not really sure how one could implement it given its hierarchical design.
+1 ... if multiple tag= args could form an implicit AND / intersection, that would help a lot.
+1 - this would be very useful.
:+1: having multiple hosts + different services -> we need different tags
for dns maybe double-underscore as delimiter
:+1:
:+1: Though simple and/not/or/grouping syntax would quickly become desirable. For DNS could it be as simple as
dig ... '(foo&bar)|!baz).mysvc.service.consul.'
Those aren't legal characters in DNS, @babbottscott
Not for hostnames, but for queries, this should be fine.
Many forwarding resolvers will return errors before the queries ever get to Consul's DNS server. So it's not really practical.
I can certainly see it working in HTTP, DNS will require more thought to avoid breaking backwards compatibility
:+1: In most architectures having the possibility to query based on more than one tag would be a great feature.
isn't possible to use dots as tag delimiter in DNS?
@i0rek The problem is a tag could be "foo.bar", which is hard to disambiguate from "foo" and "bar" or just "foo.bar".
@armon it already is a problem, no? service "foo.bar" VS service "bar" and tag "foo".
Yes, currently any additional dots are considered to be part of the tag. So if your service name contains a period you cannot resolve it via DNS.
We should probably forbid that.. (separate issue though)
I think if dots are forbidden in service names the same should apply to tag names. Then we can have dots as tag delimiter and the lookup should be easy too.
+1 for consistency amongst reserved characters. Since DNS is one of the primary APIs for consul it seems reasonable to reserve . as a delimiter across the board.
:+1:
:+1: