Monitor consumption of reservations Stay organized with collections Save and categorize content based on your preferences.
This document explains how to monitor the consumption ofreservations of Compute Engine zonal resourcesby using Cloud Monitoring.
Monitoring collects andstores performance information of Google Cloud services such asCompute Engine. The performance information is calledmetrics and time series. Youcan access the metrics and time series of your Compute Enginereservations to do the following:
Display how your reservations are being consumed by usingMonitoring dashboards.
Receive timely notifications when the consumption of your reservations is in aspecific state by usingMonitoring alerting policies.
These methods can, for example, help you verify that your reservations are beingconsumed as you planned or timely act to avoid unnecessary costs from wastedresources or unused reservations.
Before you begin
- Review therequirements andrestrictions for reservations.
Enable the Monitoring API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.- 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.
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.
Required roles
To get the permissions that you need to create Monitoring dashboards or alertingpolicies to monitor the consumption of reservations, ask your administrator to grant you theMonitoring Admin (roles/monitoring.admin) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.
This predefined role contains the permissions required to create Monitoring dashboards or alertingpolicies to monitor the consumption of reservations. To see the exact permissions that are required, expand theRequired permissions section:
Required permissions
The following permissions are required to create Monitoring dashboards or alertingpolicies to monitor the consumption of reservations:
- To create dashboards:
monitoring.dashboards.createon the project - To create policy alerts:
monitoring.alertPolicies.createon the project
You might also be able to get these permissions withcustom roles or otherpredefined roles.
Restrictions
When using Monitoring to access and view thetime series of a reservation, the followingrestrictions apply:
After you create a reservation, its time series becomes available within 30minutes.
After a time series becomes available, Monitoring startsupdating it at least once every 30 minutes.
If you delete a reservation, its time series is also deleted and can't berecovered.
You can only access and view the time series of a reservation that was createdin the current project.
For more information about Monitoring restrictions, seeCloud Monitoring quotas and limits.
Reservations metrics
When creating Monitoring dashboards or alerting policies, youmust first select theGoogle Cloud metric to measurehow the Google Cloud service is performing. For reservations, you canselect the following Compute Engine metrics:
Reserved: The number of reserved virtual machine (VM) instances in eachreservation in the current project.
Used: The number of consumed VMs in each reservation in the currentproject.
After you select a metric, you can further filter or group the measurements ofreservations' metric. For more information about the available filters forreservations, seeReservations filters in this document.
Reservations filters
You can useMonitoring filters togroup or filter the time series data associated with one or more reservations.Specifically, when creating Monitoring dashboards or alertingpolicies, you can limit the time series data that they use by specifying one ormore of the following labels:
| Selector | Label name | Description |
|---|---|---|
metadata.system | machine_type | The machine type specified in the reserved VMs for a reservation. |
metadata.system | name | The name of a reservation. |
metadata.system | state | The state of a reservation. You can only monitor reservations in theACTIVE state, which is when a reservation exists. |
metric | reserved_resource_type | The type of reserved zonal resources by a reservation. You can only monitor theinstance type, which is a VM instance. |
metric | service_name | When you select theUsed metric in the Google Cloud console, you can view which Google Cloud product consumes the reservation. The value can be one of the following:
If you consume reservations both in Compute Engine and Vertex AI, then create a filter for each preceding value. |
resource | location | The zone where a reservation is located. |
resource | reservation_id | The identifier (ID) of a reservation. |
resource | resource_container | The project number of the project where a reservation exists. You can only monitor the reservations that were created in your project. |
When creating a filter, you must specify the selector and the label name,followed by acomparison operator, andthen the value to filter. For example, if you want your query to filter yourreservations by zoneus-central1-a, use the following filter:
resource.location="us-central1-a"To ensure that the value you specify in a filter matches the value of areservation's field,view the details of the reservation.
Note: To view a reservation ID, view the details of the reservation using theGoogle Cloud CLI or REST.Monitor consumption of reservations
To monitor the consumption of your reservations, select one of the followingmethods specified in this document:
Create a dashboard—create Monitoringdashboards and add widgets to the graph areas to display the time series datatied to the consumption of your reservations.
This method is useful when, for example, you want to verify that a VM iscorrectly consuming a reservation or compare the consumption trend of multiplereservations.
Create alerting policies—create alertingpolicies to send alerts when the time series data tied to the consumption ofyour reservations reaches a defined threshold.
This method is useful when, for example, you want to be notified when thenumber of VMs used in the current project is below a specific ratio, or when areservation remains unused for a specific amount time.
Create a dashboard
You can createMonitoring dashboardsand view the time series tied to the consumption of your reservations by usingthe Google Cloud console (recommended) and Monitoring API.
When defining how to display the time series data of a Monitoringfilter, you must use one of the following methods:
Basic Query: this method is useful to quickly configure the time seriesdata for a dashboard widget.
For example, you can use Basic Query to quickly display which one of yourreservations in a specific zone isn't fully consumed yet.
PromQL: this method is useful to retrieve, filter, and manipulate timeseries data to create more complex configurations for a dashboard widget.
For example, you can usePromQL in Cloud Monitoringto display the ratio of consumed VMs to reserved VMs in your reservations.
Basic Query
The following example describes how to create a Monitoringdashboard with a line chart widget to display your consumed reservations intheus-central1-a zone.
Console
To create a Monitoring dashboard using Basic Query, followthese steps:
In the Google Cloud console, go toDashboards.
ClickCreate dashboard.
TheNew dashboard page opens.
ClickAdd widget.
TheAdd widget pane appears.
Click one of the available widgets. For example, click theLinewidget.
TheConfigure widget pane appears.
ClickSelect a metric.
In theSelect a metric window, do the following:
Enter
Important: If you can't see theReservation metric, seeMetric not listed in menu.Reservation, and then selectReservation.In theActive metrics categories list, selectReservationagain.
In theActive metrics list, select one of the available metrics.For example, selectUsed.
ClickApply.
To filter your reservations by a specific zone, do the following:
In theAdd filter list, select one of the availablefilters for reservations. For this example,selectlocation.
In theComparator list, select one of the available operators.For this example, select= (equals) (default).
In theValue list, select the zone you want to use to filteryour reservations. For this example, selectus-central1-a.
ClickApply.
For more options to customize Monitoring dashboards usingthe Google Cloud console, seeCreate and manage custom dashboards.
REST
Note: After creating a dashboard using the Monitoring API,you can onlymanage it using the Google Cloud console.To create a Monitoring dashboard using Basic Query, make aPOST request to thedashboards.create method.
POST https://monitoring.googleapis.com/v1/projects/PROJECT_ID/dashboards{ "displayName": "Consumed reservations in zone us-central1-a", "mosaicLayout": { "columns": 12, "tiles": [ { "height": 4, "widget": { "title": "Reservation - Used for us-central1-a [MEAN]", "xyChart": { "chartOptions": { "mode": "COLOR" }, "dataSets": [ { "minAlignmentPeriod": "60s", "plotType": "LINE", "targetAxis": "Y1", "timeSeriesQuery": { "timeSeriesFilter": { "aggregation": { "alignmentPeriod": "60s", "perSeriesAligner": "ALIGN_MEAN" }, "filter": "FILTER", "secondaryAggregation": { "alignmentPeriod": "60s", "perSeriesAligner": "ALIGN_NONE" } } } } ], "timeshiftDuration": "0s", "yAxis": { "scale": "LINEAR" } } }, "width": 6 } ] }}Replace the following:
PROJECT_ID: the project ID of the currentproject.FILTER: the Monitoring filterto use for your dashboard. For example, to monitor the consumedreservations in zoneus-central1-a, specify the following:resource.type='compute.googleapis.com/Reservation'ANDmetric.type='compute.googleapis.com/reservation/used'ANDresource.location='us-central1-a'
For more options to customize Monitoring dashboards usingthe Monitoring API, seeCreate and manage dashboards by using the API.
PromQL
The following example describes how to create a Monitoringdashboard with a line chart widget to display the ratio of used VMs toreserved VMs in your reservations.
Console
To create a Monitoring dashboard and add a widgetconfigured with a query using PromQL, follow these steps:
In the Google Cloud console, go to the
Dashboards page:If you use the search bar to find this page, then select the result whose subheading isMonitoring.
ClickCreate dashboard.
TheNew dashboard page opens.
ClickAdd widget.
TheAdd widget pane appears.
Click one of the available widgets. For example, click theLinewidget.
TheConfigure widget pane appears.
If you don't see the code editor, then clickPromQL orMQL. ForLanguage,selectPromQL.
In the Query editor, enter a PromQL query. For example, to view theratio of used VMs to reserved VMs in your reservations, specify thefollowing:
(maxby(metadata_system_name)({"compute.googleapis.com/reservation/used"})/maxby(metadata_system_name)({"compute.googleapis.com/reservation/reserved"}))ClickRun query.
ClickApply.
For more options to customize Monitoring dashboards usingthe Google Cloud console, seeCreate and manage custom dashboards.
REST
Note: After creating a dashboard using the Monitoring API,you can onlymanage it using the Google Cloud console.To create a Monitoring dashboard and add a widgetconfigured with a query using PromQL, make aPOST request to thedashboards.create method.
POST https://monitoring.googleapis.com/v1/projects/PROJECT_ID/dashboards{ "displayName": "Consumed reservations in zone us-central1-a", "mosaicLayout": { "columns": 12, "tiles": [ { "height": 4, "widget": { "title": "Reservation - Used for us-central1-a [MEAN]", "xyChart": { "chartOptions": { "mode": "COLOR" }, "dataSets": [ { "plotType": "LINE", "targetAxis": "Y1", "timeSeriesQuery": { "timeSeriesQueryLanguage": "PROMQL_QUERY" } } ], "timeshiftDuration": "0s", "yAxis": { "scale": "LINEAR" } } }, "width": 6, "xPos": 6 } ] }}Replace the following:
PROJECT_ID: the project ID of the currentproject.PROMQL_QUERY: the PromQL query to use for theline chart widget. For example, to view the ratio of used VMs toreserved VMs in your reservations, specify the following: Important: To specify a PromQL query spanning multiple lines in the(maxby(metadata_system_name)({"compute.googleapis.com/reservation/used"})/maxby(metadata_system_name)({"compute.googleapis.com/reservation/reserved"}))
timeSeriesQueryLanguagefield, make sure to include the\ncharacter at the end of each line.
For more options to customize Monitoring dashboards usingthe Monitoring API, seeCreate and manage dashboards by using the API.
Create alerting policies
You can createMonitoring alerting policiesto receive notifications about the reservations consumption in the currentproject by using the Google Cloud console and Monitoring API.
When defining an alert condition for an alerting policy, you must use one of thefollowing methods:
Basic Query: this method is useful to create simple alert conditions.
For example, you can use Basic Query to create an alert condition that getstriggered whenever a reservation is consumed for the first time.
PromQL: this method is useful to retrieve, filter, and manipulate time seriesdata to create more complex alert conditions.
For example, you can usePrometheus Query Language (PromQL) to create an alertcondition that gets triggered when the ratio of reserved VMs to consumed VMsreaches a specific threshold.
Basic Query
The following example creates an alerting policy that sends an alertnotification when a reservation is consumed for the first time. Specifically,the alert triggers whenever the number of consumed VMs in a reservation isgreater than0.
Console
To create a Monitoring alerting policy using Basic Query,follow these steps:
In the Google Cloud console, go toAlerting.
ClickCreate policy.
TheCreate alerting policy page opens.
ClickSelect a metric.
TheSelect a metric window appears.
In theSelect a metric window, do the following:
In theFilter by resource or metric name field, enter
Reservation.If theReservation metric appears in theActive resourceslist, select it. Otherwise, do the following:
ClearShow only active resources & metrics.
TheInactive resources list appears.
In theInactive resources list, selectReservation.
Important: If you still can't see theReservation metric,seeMetric not listed in menu.
In theActive metrics categories list, selectReservationagain.
TheActive metrics list appears.
In theActive metrics list, select one of the available metrics.
For example, selectUsed.
ClickApply.
ClickAdd filter.
TheAdd filter section appears.
In theAdd filter section, do the following:
In theLabel list, select one of the availablefilters for reservations specified in thisdocument.
For example, to filter your reservations by name, selectname.
In theComparison list, select one of the available operators.
For example, select= (equals) (default).
In theValue list, select the name of the reservation that youwant to monitor.
ClickDone.
ClickNext.
TheConfigure alert trigger pane appears.
In theCondition types section, select one of the followingoptions:
To trigger the condition if a time series falls above or below aspecific value, selectThreshold.
To trigger the condition if a time series doesn't have data for aspecific time, selectMetric absence.
To trigger the condition if a time series is projected to cross thethreshold in the near future, selectForecast.
For example, selectThreshold (default).
In theAlert trigger list, select the condition that triggers thealert.
For example, selectAny time series violation (default).
In theThreshold position list, select when the condition triggers.
For example, selectAbove threshold.
In theThreshold value field, enter a value for the condition.
For example, enter
0.In theCondition name field, enter a name for your condition.
For example, enter
ReservationRESERVATION_NAME consumed.WhereRESERVATION_NAME is the name of thereservation that you specified in the previous steps.
ClickNext.
TheConfigure notifications and finalize alert pane appears.
ClickUse notification channels.
In theNotification channels field, select the channels on whichyou want to be notified about the incident.
If you have no notification channels available, clickManage notification channels, and then follow the steps to createnotification channels. For more information, seeCreate and manage notification channels.
In theIncident autoclose duration field, select a duration afterwhich an incident is automatically closed.
For example, select3 days.
In theAlert policy name field, enter a name for the alertingpolicy.
For example, enter
Alert: you started consuming reservationRESERVATION_NAME!WhereRESERVATION_NAME is the name of thereservation that you specified in the previous steps.
ClickNext.
The review page of your alerting condition opens.
ClickCreate policy.
Creating the alerting policy might take a few seconds to complete. Thisaction redirects you to theCreate alerting policy page.
For more information about the options you have when creating alertingpolicies using the Google Cloud console and Basic Query, seeCreate metric-based alert policies.
REST
To create a Monitoring alerting policy using Basic Query,make aPOST request to theprojects.alertPolicies.create method.
POST https://monitoring.googleapis.com/v3/projects/PROJECT_ID/alertPolicies{ "displayName": "Alert: you started consuming reservationRESERVATION_NAME!", "conditions": [ { "displayName": "ReservationRESERVATION_NAME consumed.", "conditionThreshold": { "filter": "FILTER", "aggregations": [ { "alignmentPeriod": "300s", "crossSeriesReducer": "REDUCE_NONE", "perSeriesAligner": "ALIGN_MEAN" } ], "comparison": "COMPARISON_GT", "duration": "0s", "trigger": { "count": 1 }, "thresholdValue": 0 } } ], "alertStrategy": { "autoClose": "AUTO_CLOSE_TIME" }, "combiner": "OR", "enabled": true, "notificationChannels": [ "projects/PROJECT_ID/notificationChannels/NOTIFICATION_CHANNEL" ]}Replace the following:
PROJECT_ID: the project ID of the currentproject.RESERVATION_NAME: the name of an existingreservation which is located in the current project.FILTER: the Monitoring filterto use for your alerting policy. For example, to monitor theusedmetric for theRESERVATION_NAMEreservation, specify the following:resource.type='compute.googleapis.com/Reservation'ANDmetric.type='compute.googleapis.com/reservation/used'ANDmetadata.system.name='RESERVATION_NAME'
AUTO_CLOSE_TIME: the time in seconds before anincident is automatically closed. The value must be between0sand604800s(7 days). For example, enter259200s(3 days).NOTIFICATION_CHANNEL: the name of an existingnotification channel. To set up a notification channel, seeCreate and manage notification channels.
For more information about the options you have when creating alertingpolicies using the Monitoring API and Basic Query, seeCreate alerting policies by using the API.
PromQL
The following example creates an alerting policy that sends an alertnotification whenever the percentage of used VMs to reserved VMs in yourreservations is above 90%.
Console
To create a Monitoring alerting policy using PromQL, followthese steps:
In the Google Cloud console, go toAlerting.
ClickCreate policy.
TheCreate alerting policy page opens.
ForPolicy configuration mode, selectCode editor (MQL or PromQL).
TheQuery editor pane appears.
SelectPromQL as the language, and enter a PromQL query.
For example, to create a query that groups your reservations by nameand triggers an alert condition when over 90% of your reservations areconsumed, enter the following query:
(maxby(metadata_system_name)({"compute.googleapis.com/reservation/used"})/maxby(metadata_system_name)({"compute.googleapis.com/reservation/reserved"})) >0.9ClickNext.
TheConfigure alert trigger pane appears.
If theCondition name, enter a name for your condition.
For example, enter
Over 90% of your reservations are consumed.ClickNext again.
TheConfigure notifications and finalize alert pane appears.
ClickUse notification channels.
In theNotification channels field, select the channels on whichyou want to be notified about the incident.
If you have no notification channels available, clickManage notification channels, and then follow the steps to createnotification channels. For more information, seeCreate and manage notification channels.
In theIncident autoclose duration field, select a duration afterwhich an incident is automatically closed.
For example, select3 days.
In theAlert policy name field, enter a name for the alertingpolicy.
For example, enter
Alert: over 90% of your reservations are consumed.ClickNext.
The review page of your alerting condition opens.
ClickCreate policy.
Creating the alerting policy might take a few seconds to complete. Thisaction redirects you to theCreate alerting policy page.
For more information about creating alerting policies using theGoogle Cloud console and PromQL, seeCreate PromQL-based alerting policies (Console).
REST
To create a Monitoring alerting policy using PromQL, make aPOST request to theprojects.alertPolicies.create method.
POST https://monitoring.googleapis.com/v3/projects/PROJECT_ID/alertPolicies{ "displayName": "Alert: over 90% of your reservations are consumed.", "conditions": [ { "displayName": "Over 90% of your reservations are consumed.", "conditionMonitoringQueryLanguage": { "duration": "0s", "trigger": { "count": 1 }, "query": "PROMQL_QUERY" } } ], "alertStrategy": { "autoClose": "AUTO_CLOSE_TIME" }, "combiner": "OR", "enabled": true, "notificationChannels": [ "projects/PROJECT_ID/notificationChannels/NOTIFICATION_CHANNEL" ]}Replace the following:
PROJECT_ID: the project ID of the currentproject.PROMQL_QUERY: a PromQL query to use for thealerting policy. For example, to create a query that tracks when thepercentage of used VMs to reserved VMs is above 90% in the currentproject's reservations, specify the following: Important: To specify a PromQL query spanning multiple lines in the(maxby(metadata_system_name)({"compute.googleapis.com/reservation/used"})/maxby(metadata_system_name)({"compute.googleapis.com/reservation/reserved"}))>0.9
queryfield, make sure to include the\ncharacter at the end ofeach line.AUTO_CLOSE_TIME: the time in seconds before anincident is automatically closed. The value must be between0sand604800s(7 days). For example, enter259200s(3 days).NOTIFICATION_CHANNEL: the name of an existingnotification channel. To set up a notification channel, seeCreate and manage notification channels.
For more information about creating alerting policies using theMonitoring API and PromQL, seeCreate PromQL-based alerting policies (API).
Troubleshoot
Learn how totroubleshoot issues with reservation monitoring.
What's next
Learn how toconsume reservations.
Learn how toattach reservations to commitments.
Learn how tomodify reservations.
Learn how todelete reservations.
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 2025-12-15 UTC.