This page describes how you can use reservation recommendations to identify and delete idle on-demand reservations, so you can avoid charges for resources that you're not using.
- For more information on how Compute Engine generates reservation recommendations, see How detection of idle and underutilized reservations works.
- For more information on how to configure reservations recommender to receive more or fewer recommendations, see Configure idle reservation recommendations or Configure underutilized reservation recommendations.
Before you begin
- Review the limitations to check if your reservation supports idle reservation recommendations.
-
If you haven't already, then set up authentication.
Authentication is
the process by which your identity is verified 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, then initialize it by running the following command:
gcloud init
- 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, then initialize it by running the following command:
gcloud init
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
View idle reservation recommendations
To view recommendations about idle reservations, use one of the following options.
Complete this task using one of the following methods.
Console
In the Google Cloud console, go to the FinOps hub.
gcloud
To view recommendations about idle reservations, use the
gcloud recommender recommendations list
command
with the --recommender=google.compute.IdleResourceRecommender
flag:
gcloud recommender recommendations list \ --location=ZONE \ --recommender=google.compute.IdleResourceRecommender \ --format=yaml \ --project=PROJECT_ID
Replace the following:
ZONE
with the zone that contains reservations to list recommendations for.PROJECT_ID
with the ID of your project.
For example:
gcloud recommender recommendations list \ --location=us-central1-c \ --recommender=google.compute.IdleResourceRecommender \ --format=yaml \ --project=my-project
If there are no idle reservations 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 to apply the recommendationdescription
: an explanation of the recommendation
---
associatedInsights:
- insight: projects/953727763714/locations/us-central1-f/insightTypes/google.compute.IdleResourceInsight/insights/ecf77776-4a2a-4e6e-aad2-b7f9c632e5f9
content:
operationGroups:
- operations:
- action: remove
path: /
resource: //compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation
resourceType: compute.googleapis.com/Reservation
overview:
currentReservation:
machineType: n1-standard-1
reservationName: test-reservation
reservedMachineCount: '1'
zone: us-central1-f
description: Save cost by deleting the idle reservation test-reservation
etag: '"aff724ab8e40e1ef"'
lastRefreshTime: '2024-06-10T07:00:00Z'
name: projects/953727763714/locations/us-central1-f/recommenders/google.compute.IdleResourceRecommender/recommendations/56f8ac5d-8380-4cb8-a76f-bbc270fb4b8e
primaryImpact:
category: COST
costProjection:
cost:
currencyCode: USD
nanos: -199820000
units: '-1072'
costInLocalCurrency:
currencyCode: USD
nanos: -199820000
units: '-1072'
duration: 2592000s
priority: P2
recommenderSubtype: DELETE_RESERVATION
stateInfo:
state: ACTIVE
targetResources:
- //compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation
Learn more about working with recommendations using Google Cloud CLI in gcloud examples.
REST
To view recommendations about idle reservations, make a GET
request to the
recommendations.list
method
and use the following recommendation type:
- google.compute.IdleResourceRecommender
The API call looks like:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.IdleResourceRecommender/recommendations
Replace the following:
- PROJECT_ID
: the ID of your project.
- ZONE
: the zone that contains instances
to list recommendations for.
The following example shows out to send a request with curl
, and
the associated sample response.
PROJECT_ID=my-project ZONE=us-central1-c RECOMMENDER_ID=google.compute.IdleResourceRecommender curl -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 reservation recommendation:
{
"associatedInsights": [
{
"insight": "projects/9531234763714/locations/us-central1-f/insightTypes/google.compute.IdleResourceInsight/insights/ecf77776-4a2a-4e6e-aad2-b7f9c632e5f9"
}
],
"content": {
"operationGroups": [
{
"operations": [
{
"action": "remove",
"path": "/",
"resource": "//compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation",
"resourceType": "compute.googleapis.com/Reservation"
}
]
}
],
"overview": {
"currentReservation": {
"machineType": "n1-standard-1",
"reservationName": "test-reservation",
"reservedMachineCount": "1",
"zone": "us-central1-f"
}
}
},
"description": "Save cost by deleting the idle reservation test-reservation",
"etag": "\"8d5603cac8fa9342\"",
"lastRefreshTime": "2024-06-11T07:00:00Z",
"name": "projects/9531234763714/locations/us-central1-f/recommenders/google.compute.IdleResourceRecommender/recommendations/56f8ac5d-8380-4cb8-a76f-bbc270fb4b8e",
"primaryImpact": {
"category": "COST",
"costProjection": {
"cost": {
"currencyCode": "USD",
"nanos": -199820000,
"units": "-1072"
},
"costInLocalCurrency": {
"currencyCode": "USD",
"nanos": -199820000,
"units": "-1072"
},
"duration": "2592000s"
}
},
"priority": "P2",
"recommenderSubtype": "DELETE_RESERVATION",
"stateInfo": {
"state": "ACTIVE"
},
"targetResources": [
"//compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation"
]
}
You can find more details about each field in the Recommender API documentation.
Interpreting the recommendation response
Each recommendation that you receive through the gcloud CLI
or REST contains an operations group, with operations that you can
perform in serial to apply the recommendation. For idle reservations, the
operation groups include a remove
operation to delete the reservation:
{
"action": "remove",
"path": "/",
"resource": "//compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation",
"resourceType": "compute.googleapis.com/Reservation"
}
Apply idle reservation recommendations
Based on idle reservation recommendations, either adjust the reservation size or delete the reservation if you no longer need it.
What's next
- Learn more about how Compute Engine reservations work.
- Learn how to configure idle reservation recommendations.
- Learn how to configure underutilized reservation recommendations.