It would be useful to be able to query DNS / HTTP with a 'conditional' tag. The use case I am thinking of is that I have a service in AWS that is in multiple availability zones. I want clients in us-east-1a to prefer services that are also in us-east-1a, so I've added that as a tag to the service. However if the 1a service fails, I'd like it to fall back to the other zones.
This makes sense, let me think about it more generically.
+1
That could be solved using a external load balancer, correct? I was thinking what would be the criteria to redirect to a new endpoint, especially if you have multiple options (us-west-1a, us-west-2a, us-central-1).
This can be done at the datacenter level with prepared queries - https://www.consul.io/docs/agent/http/query.html. There's still no ability to do it by tag, though.
Yes, we very much need this feature. An additional parameter in prepared queries allowing specification of a priority tag or tags would probably address this need (but would also require the DNS prepared-query API _not_ to randomly shuffle the results) without having to extend the DNS syntax.
Hi ! Any news on this update ?
Having the same use case as @jhmartin, I can tell the cost savings of this simple change would be HUGE 馃槂
Consul now supports specifying tags in prepared queries: https://www.consul.io/api/query.html#tags. Thanks for reporting and thanks for your patience!
I'm confused, why was this closed, @i0rek ? Tags can be specified, but the docs you link imply that the tags are then required. This issue is asking for a preferred, but not required tag. So, for example, _if_ a service with tag "x" exists, then use that, otherwise, fall back to something else.
The original example is still very relevant: if I tag my services with what AZ they are located in, then I can have my consumers query for my service preferring tag us-east-1a. But if us-east-1a isn't available, it is okay to return other values.
In short, there needs to be an additional way to specify "preferred tags" in addition to "required tags" and "excluded tags".
If that is too specific, it would also be nice to have a way to failover to another query, instead of just to another datacenter.
Thank you for clarifying @daveadams! I can see how that would be useful in your scenario!
Having that said, right now we are very busy with other things and the only help I can offer is that I would be open to review a pull request that implements this functionality.
Thanks,
Hans
After giving it more thought and coming back to this a couple of times, we decided that this is not something we will implement anytime soon. Instead of adding features to prepared queries, we are proposing that you look into https://www.consul.io/docs/connect/l7-traffic-management.html. I am not sure it covers your use case 100% but it definitely is the way to create to create rules for advanced routing.
I am closing this feature request, because we are not going to have time to work on it any time soon. Thank you everybody for reporting and clarifying.
Most helpful comment
I'm confused, why was this closed, @i0rek ? Tags can be specified, but the docs you link imply that the tags are then required. This issue is asking for a preferred, but not required tag. So, for example, _if_ a service with tag "x" exists, then use that, otherwise, fall back to something else.
The original example is still very relevant: if I tag my services with what AZ they are located in, then I can have my consumers query for my service preferring tag
us-east-1a. But ifus-east-1aisn't available, it is okay to return other values.In short, there needs to be an additional way to specify "preferred tags" in addition to "required tags" and "excluded tags".