View and apply idle VM recommendations

This page describes how you can use idle VM recommendations to identify and stopidle VM instances to reduce waste of resources and reduce your compute billon your projects.

Before you begin

Pricing

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

Viewing idle VM instance recommendations

To view recommendations about idle VMs, use the gcloud CLI orREST.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • recommender.computeInstanceIdleResourceRecommendations.list on the project

gcloud

Use thegcloud recommender recommendations list commandwith--recommender=google.compute.instance.IdleResourceRecommender:

gcloud recommender recommendations list \  --project=PROJECT_ID \  --location=ZONE \  --recommender=google.compute.instance.IdleResourceRecommender \  --format=yaml

Replace the following:

  • PROJECT_ID: the ID of your project
  • ZONE: the zone that contains instancesto list recommendations for

For example:

gcloud recommender recommendations list \  --project=my-project \  --location=us-central1-c \  --recommender=google.compute.instance.IdleResourceRecommender \  --format=yaml

If there are no idle VMs in the location, the response is empty. Otherwise,the response includes the following fields for each recommendation:

---content:...operationGroups:- operations:  - action: test    path: /status    resource: //compute.googleapis.com/projects/my-project/zones/us-central1-c/instances/vm-name    resourceType: compute.googleapis.com/Instance    value: RUNNING  - action: replace    path: /status    resource: //compute.googleapis.com/projects/my-project/zones/us-central1-c/instances/vm-name    resourceType: compute.googleapis.com/Instance    value: TERMINATEDdescription: Save cost by stopping Idle VM 'vm-name'.etag: '"83da314c23f634e1"'lastRefreshTime: '2020-02-24T07:56:40Z'name: projects/141732092341/locations/us-central1-c/recommenders/google.compute.instance.IdleResourceRecommender/recommendations/0e061a3a-f921-4216-b1b4-62e16942cd1aprimaryImpact:category: COSTcostProjection:  cost:    currencyCode: USD    nanos: -91533961    units: '-262'  duration: 2592000srecommenderSubtype: STOP_VMstateInfo:state: ACTIVE

Learn more about working with recommendations using gcloud ingcloud examples.

REST

Call therecommendations.list methodand use the following recommendation type:

  • google.compute.instance.IdleResourceRecommender

The API call looks like:

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

Replace the following:

  • PROJECT_ID: the ID of your project.
  • ZONE: the zone that contains instancesto list recommendations for.

The following example shows out to send a request withcurl, andthe associated sample response.

PROJECT_ID=my-projectZONE=us-central1-cRECOMMENDER_ID=google.compute.instance.IdleResourceRecommendercurl -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/$RECOMMENDER_ID/recommendations

Example JSON response for an idle VM recommendation:

{"description" : "Save cost by stopping Idle VM`vm-name`","name": "projects/1574864402/locations/us-central1-c/recommenders/"        "google.compute.instance.IdleResourceRecommender/"        "recommendations/0fd31b24-cc05-4132-8431-ed54a22dd4f1","lastRefreshTime": {  "seconds": 1543912652},"primaryImpact": {  "category": COST,  "costProjection": {    "cost": {"currencyCode": "USD", "units": -50},    "duration": { "seconds": 2592000 }  }},"stateInfo": ACTIVE,"content":  "groups" : [    {      "operations" : [      {        "action": "test",        "resourceType": "compute.googleapis.com/Instance",        "resource": "//compute.googleapis.com/projects/my-project/"                    "zones/us-central1-c/instances/vm-name",        "path": "/status",        "value": "RUNNING"      },      {        "action": "replace",        "resourceType": "compute.googleapis.com/Instance",        "resource": "//compute.googleapis.com/projects/my-project/"                    "zones/us-central1-c/instances/vm-name",        "path": "/status",        "value": "TERMINATED"      }      ]    }  ]},"etag" : "cb0e6ac2cfc0b591"}

You can find more details about each field in theRecommender API documentation.

Interpreting the recommendation response

Each recommendation that you receive through the gcloud CLIor REST contains an operations group, with operations that you canperform in serial to apply the recommendation. Idle VM recommendationoperation groups include two operations:

  1. A test operation to verify the currentstatusof the VM. For example:

     {   "action": "test",   "resourceType": "compute.googleapis.com/Instance",   "resource" : "//compute.googleapis.com/projects/my-project/zones/us-central1-c/instances/vm-name",   "path": "/status",   "value": "RUNNING" }
  2. A replace operation to change thestatus of the VM. For example:

     {   "action": "replace",   "resourceType": "compute.googleapis.com/Instance",   "resource" : "//compute.googleapis.com/projects/my-project/zones/us-central1-c/instances/vm-name",   "path": "/status",   "value": "TERMINATED" }

The first operation is atest, which means that you should test that theresource is stillRUNNING. You can do this bychecking the VM state.

The second operation,replace, means that you should replace the resource'sstatus with a new value,TERMINATED. You can do that by stopping the VM,which is described below.

Applying idle VM recommendations

After you receive an idle VM recommendation and you decide that you no longerneed the instance, use theGoogle Cloud console, thegcloud CLI, orREST to stop and optionally deletethe instance.

If you stop but do not delete an instance and its disks, you still pay for itsdisks.

Warning: Deleting a VM can cause loss of data. Take precautions to protect anydata that you need to keep before you delete a VM, for example, bycreating persistent disk snapshots.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.instances.stop on the instance to stop it.
  • compute.instances.delete on the instance to delete it.

Console

  1. In the Google Cloud console, go to theVM instances page.

    Go to the VM instances page

  2. Select the instance that you want to stop.
  3. ClickStop to stop the VM. If there is noStop option, clickMore actions >Stop.

gcloud

Use theinstances stop commandand specify theVM_NAME that you want to stop.

gcloud compute instances stopVM_NAME --zone=ZONE

Replace the following:

  • VM_NAME: the name of the VM instance you want to stop
  • ZONE: the zone that contains the instance you wantto stop

REST

Construct aPOST request to stop an instance.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/stop

Replace the following:

  • PROJECT_ID: the ID of your project
  • ZONE: the zone that contains the instance you wantto stop
  • VM_NAME: the name of the VM instance you want to stop

If you're sure that the VM instance and its disks can be removed you candelete the instance.

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.