How do I query for nodebalancers with more than 1 tag?

I have a nodebalancer with tag "zzz" and tag "aaa"

This command does not return the nodebalancer:
linode-cli nodebalancers list --tags "aaa,zzz"

What command would return the nodebalancer containing BOTH tags?

2 Replies

I tried on my own account to see if I could find what syntax would cause the CLI to return a list of Nodebalancers that have both tags and I wasn't able figure it out.

I've let the appropriate team know that this doesn't seem possible at the moment. Whether it's a bug and the results should come back, or if it's a feature that doesn't exist yet, any changes would be made public on GitHub. I don't have a timeline on when a change would be made and can't promise that it will be changed, but you can follow along there if you'd like.

For now, we can offer a few workarounds. First, one of our Engineers took some time to figure out the syntax for this using the API instead of the CLI. Here is the syntax for that:

curl -X GET \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -H 'X-Filter: { "+and": [ {"tags": "aaa"}, {"tags": "zzz" } ] }' \
    https://api.linode.com/v4/nodebalancers \
    | jq '.data'

He mentioned that jq '.data' is there to make the result more readable and isn't needed. I tested this on my own account and confirmed it worked with or without that part.

Next, one of my teammates was able to come up with an alternative that uses the CLI, though it doesn't get exactly what you're looking for:

linode-cli nodebalancers list --format label,tags --tags aaa && linode-cli nodebalancers list --format label,tags --tags zzz

If you run this as one command, it should provide two lists, one for each tag. Anything on both lists has both tags:

┌─────────────────┬─────────┐
│ label           │ tags    │
├─────────────────┼─────────┤
│ NBwbothtags     │ aaa,zzz │
│ NBwaaatag       │ aaa     │
└─────────────────┴─────────┘
┌──────────────────┬──────────┐
│ label            │ tags     │
├──────────────────┼──────────┤
│ NBwbothtags      │ aaa,zzz  │
│ NBwzzztag        │ zzz      │
└──────────────────┴──────────┘

While neither is exactly what you were looking for, option 1 should allow you to get back just NodeBalancers with both tags, and would be the best option if this were part of a script. The second option will provide two neatly formatted charts that will allow you to extrapolate the information. Hopefully one of the two is a good choice for your needs, at least for now.

I wanted to update that we did add this feature. You should not be able to search for multiple tags. The call would look like this:

linode-cli nodebalancers list --format label,tags --tags zzz --tags aaa 

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct