List resources without labels

Hi,

I am trying to list resources in a GCP project without any labels.  I am trying to check resources related to support services as documented in https://cloud.google.com/resource-manager/docs/labels-supported-services .

I used the following command, but it lists all assets (the ones with labels as well).

gcloud asset search-all-resources --asset-types=file.googleapis.com.* --filter=-labels.* --project=<project_name>

Any hints please?

Regards

Yogeesh Venkanna

Solved Solved
0 2 344
1 ACCEPTED SOLUTION

Hi,

The following command works:

 

 

I will be able to figure out using the above for other asset-types which supports labelling.

 gcloud asset search-all-resources --scope='projects/<project_name>' --asset-types='container.googleapis.com/NodePool' --filter=-labels:*

 

View solution in original post

2 REPLIES 2

Looking at your cmd - I believe you want to add --query=label.* and remove the --filter as it doesn't set the scope or the fields being returned
but I would try it in the console under Asset Inventory in a project to ensure you it returned what you expected. Also if you only want specific fields returned use the --read-mask

https://cloud.google.com/sdk/gcloud/reference/asset/search-all-resources
https://cloud.google.com/asset-inventory/docs/supported-asset-types
https://cloud.google.com/resource-manager/docs/labels-supported-services

Hi,

The following command works:

 

 

I will be able to figure out using the above for other asset-types which supports labelling.

 gcloud asset search-all-resources --scope='projects/<project_name>' --asset-types='container.googleapis.com/NodePool' --filter=-labels:*