Configure idle VM recommendations

Preview

This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.

This page describes how to view and modify the configuration of your idle VMrecommendations. You might want to modify the configuration to increase thenumber of recommendations that you receive or to avoid misclassifyingVMs with intentionally small workloads as idle VMs.

Before you begin

Pricing

Configurable recommendations are available free of charge. Using recommendationsto reduce your resource usage can result in cost savings.

Configure your recommendations

To configure your idle VM recommendations, perform the following steps:

  1. Get the current configuration to obtainthe JSON file of the configuration.
  2. Edit the configuration file in JSON format.
  3. Upload the new configuration fileto apply the changes.

Get the current configuration

You can obtain the current configuration for idle VM recommendations for yourproject by using the Google Cloud CLI or REST.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • recommender.computeInstanceIdleResourceRecommenderConfig.get on the project.

gcloud

To get the current configuration parameters, use thegcloud recommender recommender-config describecommand and usegoogle.compute.instance.IdleResourceRecommender as theRecommender ID:

gcloud recommender recommender-config describe google.compute.instance.IdleResourceRecommender \  --project=PROJECT_ID \  --location=ZONE

Replace the following:

  • PROJECT_ID: the ID of your project
  • ZONE: the zone for which you want to obtain thecurrent configuration

For example:

gcloud recommender recommender-config describe google.compute.instance.IdleResourceRecommender \  --project=my-project \  --location=us-central1-c

The command returns the recommender configuration, including the modifiablesubfieldparams.observation_period.

{  "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config",  "recommenderGenerationConfig": {    "params": {      "observation_period": "1209600s"    }  },  "etag": "\"2f3c9b65cda6a4ba\"",  "updateTime": "2021-02-03T04:41:15.330351Z"}

REST

To retrieve the current configuration, use therecommenders.getConfigmethod and specifygoogle.compute.instance.IdleResourceRecommender as theRecommender ID:

GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config

Replace the following:

  • PROJECT_ID: the ID of the project for which youwant to retrieve the recommender config.
  • ZONE: the zone that contains your project.

From the command line, execute the following command to get the recommenderconfiguration for a project:

PROJECT_ID=PROJECT_IDZONE=ZONEcurl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \-H "x-goog-user-project: ${PROJECT_ID}" \https://recommender.googleapis.com/v1/projects/$PROJECT_ID/locations/$ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config

The command returns the recommender configuration, including the subfieldthat you can modify:params.observation_period.

{  "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config",  "recommenderGenerationConfig": {    "params": {      "observation_period": "1209600s"    }  },  "etag": "\"2f3c9b65cda6a4ba\"",  "updateTime": "2021-02-03T04:41:15.330351Z"}
Note: When you submit the new configuration, remove theupdateTimeparameter.

Update the configuration for a project

To update the configuration of your idle VM recommendations, modify the valueforobservation_period and upload the new configuration for your project.

You can set the observation period to a value between 1 day and 14 days, usinga string with the total number of seconds, followed by the letters.

After you upload the new configuration, it takes approximately 48 hours for itto take effect. Until that time, any generated recommendations use the previousconfiguration.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • recommender.computeInstanceIdleResourceRecommenderConfig.get on the project to view the configuration.
  • recommender.computeInstanceIdleResourceRecommenderConfig.update on the project to modify the configuration.

gcloud

To update the configuration parameters, use thegcloud recommender recommender-config updatecommand and usegoogle.compute.instance.IdleResourceRecommender as theRecommender ID:

gcloud recommender recommender-config update google.compute.instance.IdleResourceRecommender\  --project=PROJECT_ID \  --location=ZONE \  --config-file=CONFIG_FILE_PATH \  --etag=ETAG

Replace the following:

  • PROJECT_ID: the ID of your project
  • ZONE: the zone for which you want to obtain thecurrent configuration
  • CONFIG_FILE_PATH: the path to the JSON file withthe current configuration
  • ETAG: the etag value of the current configuration

In your configuration file, specify only therecommenderGenerationConfigobject with the updated configuration parameters. For example, to specifyan observation period of five days, use the following configuration file:

{  "params": {    "observation_period": "432000s"  }}

If the command is successful, it returns a response body similar to thefollowing, showing the new configuration with the parameters you justmodified.

{  "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config",  "recommenderGenerationConfig": {    "params": {      "observation_period": "432000s"    }  },  "etag": "\"1245f9435cd01ea8\"",  "updateTime": "2021-02-03T05:00:05Z"}
Note: theetag value changes from the previous configuration. Youmust use the new value if you update the configuration again.

REST

To update the configuration, use therecommenders.updateConfigmethod and specifygoogle.compute.instance.IdleResourceRecommender as theRecommender ID:

PATCH https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config{  "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config",  "recommenderGenerationConfig": {    "params": {      "observation_period": "1209600s"    }  },  "etag": "\"2f3c9b65cda6a4ba\""}

Replace the following:

  • PROJECT_ID: the ID of the project for which youwant to modify the recommender configuration.
  • ZONE: the zone that contains your project.

Save the request body in a file, for exampleconfig.json.You can then reference the file when you update the recommender configurationfor your project, using a command similar to the following:

curl -X PATCH \-H "Authorization: Bearer $(gcloud auth print-access-token)" \-H "Content-Type: application/json; charset=utf-8" \-H "x-goog-user-project: ${PROJECT_ID}" \-d @config.json \https://recommender.googleapis.com/v1/projects/$PROJECT_ID/locations/$ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config

ThePOST command returns a response body similar to the following, showingthe new configuration with the parameters you just modified.

{  "name": "projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.instance.IdleResourceRecommender/config",  "recommenderGenerationConfig": {    "params": {      "observation_period": "432000s"    }  },  "etag": "\"1245f9435cd01ea8\"",  "updateTime": "2021-02-03T05:00:05Z"}
Note: theetag value changes from the previous configuration. Youmust use the new value if you update the configuration again.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.