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

Filtering a service based on multiple tags? #1841

Closed
gt-tech opened this issue Mar 16, 2016 · 1 comment
Closed

Filtering a service based on multiple tags? #1841

gt-tech opened this issue Mar 16, 2016 · 1 comment

Comments

@gt-tech
Copy link

gt-tech commented Mar 16, 2016

I have a service registered with 2 different service instance id with some variations in tag, see below on how it looks like

[{
    "Node": "app-registry-discovery-node1",
    "Address": "x.x.x.x",
    "ServiceID": "api-server-8000",
    "ServiceName": "api-server",
    "ServiceTags": ["dev", "provider-abc"],
    "ServiceAddress": "someserver.domain.com",
    "ServicePort": 8000
}, {
    "Node": "app-registry-discovery-node1",
    "Address": "x.x.x.x",
    "ServiceID": "api-server-8001",
    "ServiceName": "api-server",
    "ServiceTags": ["dev", "provider-xyz"],
    "ServiceAddress": "someserver.domain.com",
    "ServicePort": 8001
}]

If I fire a request to filter the service with filtering by just one tag it works fine ....
http://consul-server/v1/catalog/service/api-server?tag=dev - works
http://consul-server/v1/catalog/service/api-server?tag=provider-abc - works

http://consul-server/v1/catalog/service/api-server?tag=dev&tag=junk - still works but shouldn't since there's no service that has both the provided tags, it just filters on tag: dev?

Surprisingly continuing with previous example -
http://consul-server/v1/catalog/service/api-server?tag=junk&tag=provider-abc- doesn't work so it seems that filtering is only done by the first value of "tag" in query parameters.

What's the best way to filter a specific service instance with filtering done using more than one "tags", if i am guessing it's possible.

@slackpad
Copy link
Contributor

Hi @gt-tech this is currently not possible via those endpoints (see #1781 and #294). The only way to do this currently is using prepared queries but those require a little state to be set up beforehand (create the query for multiple tags and then execute it). Closing this as a dup - please watch #1781 for updates on the other endpoints!

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

2 participants