I am trying to filter a fleet of cloudsql
instances based on if they have a recommendation using gcloud cli.
For example I want to list the all the instances that are nearing storage capacity.
I tried this but no luck:
➜ gcloud sql instances list --project <project-name> --filter='recommendations:on'
➜ gcloud sql instances list --project <project-name> --filter='recommendations:*'
WARNING: The following filter keys were not present in any resource : recommendations
Listed 0 items.
Any help please?
You can use the Recommender API through the gcloud CLI to work directly with these recommendations for your instances. In this case, try using the gcloud recommender recommendations list
command and passing the --recommender=RECOMMENDER
flag with any of the available Cloud SQL recommendations (including out of disk):
gcloud recommender recommendations list --project=PROJECT_ID --location=LOCATION --recommender=google.cloudsql.instance.RECOMMENDER
Adding more context for gcloud sql instances list
, the available filters for any given gcloud
command can be seen by sampling the YAML output (using --format=yaml
), as noted in the documentation. I tried it, but recommendation data is not returned as an available property.