Configure alerts for scheduled snapshots Stay organized with collections Save and categorize content based on your preferences.
You cancreate a custom metricto raise alerts or provide information to troubleshoot problems with scheduledsnapshots.
For example, to set up an alert for scheduled snapshot failures, use thefollowing procedure:
- Create a custom query to capture scheduled snapshotevents.
- Create a metric based off of the query thatcounts scheduled snapshot failures.
- Create an alert policy to send an alert when there isa scheduled snapshot failure.
Before you begin
- 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.
Required roles and permissions
To get the permissions that you need to create a snapshot schedule, ask your administrator to grant you the following IAM roles on the project:
- Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1) - To connect to a VM that can run as a service account:Service Account User (v1) (
roles/iam.serviceAccountUser)
For more information about granting roles, seeManage access to projects, folders, and organizations.
You might also be able to get the required permissions throughcustom roles or otherpredefined roles.
Create a custom query
To capture scheduled snapshot events, create a custom query inLogs explorer.
In the Google Cloud console, go to theLogging > Logs Explorer page.
If the query editor isn't visible at the top of the page, click theShow query toggle.
Enter the following text in the query editor, replacing
PROJECT_IDwith your project ID:resource.type="gce_disk"logName="projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event"protoPayload.methodName="ScheduledSnapshots"severity>"INFO"ClickRun query.
Create a metric
After you create the custom query, create a metric thatcounts scheduled snapshot failures.
- At the top of the results table on theLogs Explorer page, click theActions drop-down.
- SelectCreate metric.
In theCreate log-based metric window, provide the following details:
- Metric type:
Counter - Log-based metric name:
scheduled_snapshot_failure_count - Description:
count of scheduled snapshot failures
TheFilter selection section is automatically populated with thequery from the previous step.
- Metric type:
UnderLabels, clickAdd label and enter the following:
- Label name:
status - Description:
status of scheduled snapshot request - Label type:
STRING - Field name:
protoPayload.response.status
- Label name:
ClickDone.
ClickCreate Metric.
Create an alert policy
After you create the metric, create an alert policy to send an alert whenthere's a scheduled snapshot failure.
In the Google Cloud console, go to theCloud Logging > Log-based metrics page.
In theUser-defined Metrics section, find your new metric named
scheduled_snapshot_failure_count.Click theMoremenu button in this row and selectCreate alert from metric.
TheCreate alerting policy page opens.
In theNew condition tab, configure your alert signal:
Set theRolling window to
5 minutesor your preferredinterval.ForRolling window function, select
Sum.ClickNext.
In theConfigure trigger tab, enter the following:
- Condition type:
Threshold - Alert trigger:
Any time series violates - Threshold position:
Above threshold Threshold value:
0SettingThreshold value to
0triggers an alert ifany snapshotfailure occurs. You can modify this value as your workload requires.Condition name:
Snapshot failure threshold exceeded
ClickNext.
- Condition type:
In theNotifications and name tab, set yourAlert policy name.Optionally, you can add notification channels and documentation forthis policy.
ClickNext.
Review your alert.
ClickCreate Policy.
To learn more about creating alert policies, seeCreate metric-threshold alerting policies.
What's next
- Learn about snapshot schedule frequencies, retention policies, and namingrules inAbout snapshot schedules for disks.
- Learn aboutdisk snapshots.
- Learn how tocreate scheduled snapshots for disks.
- Learn how toview logs.
- Learn more aboutalerting
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.