View and apply idle VM recommendations Stay organized with collections Save and categorize content based on your preferences.
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.
- For more information on how Compute Engine generates idle VMrecommendations, seeHow detection of idle VM instances works.
- For more information on how to configure idle VM Recommender to receive moreor fewer recommendations, seeConfigure idle VM recommendations.
Before you begin
- Review thelimitations to check if your VM supports idle VM recommendations.
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
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.liston 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 projectZONE: 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:
operationGroups:groups of operations that you can perform in serial order toapply the recommendationdescription: a human-readable explanation of the 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: ACTIVELearn 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:
A test operation to verify the current
statusof 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" }A replace operation to change the
statusof 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.stopon the instance to stop it.compute.instances.deleteon the instance to delete it.
Console
- In the Google Cloud console, go to theVM instances page.
- Select the instance that you want to stop.
- 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 stopZONE: 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 projectZONE: the zone that contains the instance you wantto stopVM_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
- Learn more about how stopping, resetting, and deleting a VM instanceaffects the instance and its resources.
- Learn how toconfigure idle VM recommendations.
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.