This page describes how you can use reservation recommendations to identify and delete underutilized on-demand reservations, so you can avoid charges for resources that you're not using.
- For more information on how to configure the reservations recommender to
receive more or fewer recommendations, see
Configure underutilized reservation recommendations
or Configure idle reservation recommendations.
Before you begin
- Review the limitations to check if your reservation supports underutilized 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 underutilized reservation recommendations
To view recommendations about underutilized 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.
Under the Top Recommendations section, you can view underutilized reservation recommendations.
In the Top Recommendations section, click the recommendation tied to your underutilized reservations.
When you click the recommendation, it shows extent of underutilization in the Insight section.
The page with the details of the recommendation opens. In the Insight section, you can view the extent of the underutilization.
To view the details of the reservation, click View reservations.
Clicking View Reservation Details shows the Utilization section, which displays the reservation size and your actual utilization.
Clicking Edit enables the Configuration section, where you can set a new value for the number of VMs that better matches your intended usage.
If you don't need the reservation anymore, then delete the reservation.
gcloud
To view recommendations about underutilized reservations, use the
gcloud recommender recommendations list
command with the--recommender=google.compute.RightSizeResourceRecommender
flag:gcloud recommender recommendations list \ --location=ZONE \ --recommender=google.compute.RightSizeResourceRecommender \ --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.RightSizeResourceRecommender \ --format=yaml \ --project=my-project
If there are no underutilized 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.RightSizeResourceRecommender/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 underutilized reservation test-reservation etag: '"aff724ab8e40e1ef"' lastRefreshTime: '2024-06-10T07:00:00Z' name: projects/953727763714/locations/us-central1-f/recommenders/google.compute.RightSizeResourceRecommender/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 underutilized reservations, make a
GET
request to therecommendations.list
method and use the following recommendation type:- google.compute.RightSizeResourceRecommender
The API call looks like:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/recommenders/google.compute.RightSizeResourceRecommender/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.RightSizeResourceRecommender 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 underutilized reservation recommendation:
{ "associatedInsights": [ { "insight": "projects/9531234763714/locations/us-central1-f/insightTypes/google.compute.RightSizeResourceRecommender/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 underutilized reservation test-reservation", "etag": "\"8d5603cac8fa9342\"", "lastRefreshTime": "2024-06-11T07:00:00Z", "name": "projects/9531234763714/locations/us-central1-f/recommenders/google.compute.RightSizeResourceRecommender/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 underutilized 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 underutilized reservation recommendations
Based on underutilized 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 underutilized reservation recommendations.
- Learn how to configure idle reservation recommendations.