Configure alerts for snapshot schedules
You can create a custom metric
to raise alerts or provide information to troubleshoot problems with scheduled
snapshots.
For example, to set up an alert for scheduled snapshot failures, use the
following procedure:
- Create a log filter to capture scheduled snapshot
events.
- Create a metric based off of the log filter that
counts scheduled snapshot failures.
- Create an alert policy to send an alert when there is
a scheduled snapshot failure.
Before you begin
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:
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get
the required permissions through custom
roles or other predefined
roles.
Create a log filter
Create a log filter to capture scheduled snapshot events.
Console
In the Trusted Cloud console, go to the
Logging > Logs Explorer page.
Go to the Logs Explorer page
In the Filter by label or text search list, select Convert to advanced filter.
Replace the filter field by entering the following text, replacing
PROJECT_ID
with your project ID:
resource.type="gce_disk"
logName="projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event"
protoPayload.methodName="ScheduledSnapshots"
severity>"INFO"
Click Submit Filter.
Create a metric
After you create the log filter, create a metric that
counts scheduled snapshot failures.
Console
On the Logs Explorer page, click Create metric.
In the Metric Editor, enter the following:
- Name:
scheduled_snapshot_failure_count
.
- Description:
count of scheduled snapshot failures
.
- Type:
Counter
Under Labels, click Add item and enter the following:
- Name:
status
- Description:
status of scheduled snapshot request
- Label type:
String
- Field name:
protoPayload.response.status
Click Done.
Click Create Metric.
Create an alert policy
After you create the metric, create an alert policy to send an alert when
there is a scheduled snapshot failure.
Console
In the Trusted Cloud console, go to the
Cloud Logging > Logs-based metrics page.
Go to the Logs-based metrics page
Under User-defined Metrics, find your new metric named
user/scheduled_snapshot_failure_count
.
Click the more_vert More
menu button in this row and select Create alert from metric. The
alert policy condition creation page opens.
In the Target panel, under Aggregator, select none.
Under Filter:
- Click Add a filter.
- Select status from the list.
- In the Value field, type DONE.
- Click Apply.
Click Show advanced options.
In the Advanced aggregation pane, click the Aligner list and select
sum.
In the Configuration panel, select the following values:
- Condition triggers if:
Any time series violates
- Condition:
is above
- Threshold:
1
- For:
most recent value
Click Save.
On the Create new alerting policy page, enter a policy name.
Optionally, you can add notification channels and documentation for
this policy.
Click Save.
What's next
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eYou can create custom metrics to monitor and troubleshoot scheduled snapshot issues, such as failures.\u003c/p\u003e\n"],["\u003cp\u003eTo set up alerts for scheduled snapshot failures, you must create a log filter, a metric based on the log filter, and finally an alert policy.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication is required to access Google Cloud services and APIs, which can be set up through the gcloud CLI or the console.\u003c/p\u003e\n"],["\u003cp\u003eTo create a snapshot schedule, you need specific IAM roles, including Compute Instance Admin (v1) and Service Account User (v1).\u003c/p\u003e\n"],["\u003cp\u003eAfter creating the user metric you can set an alert policy to trigger any time the metric exceeds the threshold, which in this case is one failure.\u003c/p\u003e\n"]]],[],null,["# Configure alerts for snapshot schedules\n\nLinux Windows\n\n*** ** * ** ***\n\nYou can [create a custom metric](/monitoring/custom-metrics)\nto raise alerts or provide information to troubleshoot problems with scheduled\nsnapshots.\n\nFor example, to set up an alert for scheduled snapshot failures, use the\nfollowing procedure:\n\n1. [Create a log filter](#ss_alert_filter) to capture scheduled snapshot events.\n2. [Create a metric](#ss_alert_metric) based off of the log filter that counts scheduled snapshot failures.\n3. [Create an alert policy](#ss_alert_policy) to send an alert when there is a scheduled snapshot failure.\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). 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:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\n### Required roles and permissions\n\n\nTo get the permissions that\nyou need to create a snapshot schedule,\n\nask your administrator to grant you the\nfollowing IAM roles on the project:\n\n- [Compute Instance Admin (v1)](/iam/docs/roles-permissions/compute#compute.instanceAdmin.v1) (`roles/compute.instanceAdmin.v1`)\n- To connect to a VM that can run as a service account: [Service Account User (v1)](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`)\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nCreate a log filter\n-------------------\n\nCreate a log filter to capture scheduled snapshot events. \n\n### Console\n\n1. In the Google Cloud console, go to the\n **Logging \\\u003e Logs Explorer** page.\n\n [Go to the Logs Explorer page](https://console.cloud.google.com/logs/query)\n2. In the **Filter by label or text search** list, select **Convert to advanced filter**.\n\n1. Replace the filter field by entering the following text, replacing\n \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID:\n\n resource.type=\"gce_disk\"\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/cloudaudit.googleapis.com%2Fsystem_event\"\n protoPayload.methodName=\"ScheduledSnapshots\"\n severity\u003e\"INFO\"\n\n2. Click **Submit Filter**.\n\nCreate a metric\n---------------\n\nAfter you create the log filter, create a metric that\ncounts scheduled snapshot failures. \n\n### Console\n\n1. On the **Logs Explorer** page, click **Create metric**.\n\n2. In the **Metric Editor**, enter the following:\n\n - **Name** : `scheduled_snapshot_failure_count`.\n - **Description** : `count of scheduled snapshot failures`.\n - **Type** : `Counter`\n3. Under **Labels** , click **Add item** and enter the following:\n\n - **Name** : `status`\n - **Description** : `status of scheduled snapshot request`\n - **Label type** : `String`\n - **Field name** : `protoPayload.response.status`\n4. Click **Done**.\n\n5. Click **Create Metric**.\n\nCreate an alert policy\n----------------------\n\nAfter you create the metric, create an alert policy to send an alert when\nthere is a scheduled snapshot failure. \n\n### Console\n\n1. In the Google Cloud console, go to the\n **Cloud Logging \\\u003e Logs-based metrics** page.\n\n [Go to the Logs-based metrics page](https://console.cloud.google.com/logs/metrics)\n2. Under **User-defined Metrics** , find your new metric named\n `user/scheduled_snapshot_failure_count`.\n\n3. Click the more_vert **More**\n menu button in this row and select **Create alert from metric**. The\n alert policy condition creation page opens.\n\n4. In the **Target** panel, under **Aggregator** , select **none**.\n\n5. Under **Filter**:\n\n 1. Click **Add a filter**.\n 2. Select **status** from the list.\n 3. In the **Value** field, type DONE.\n 4. Click **Apply**.\n\n6. Click **Show advanced options**.\n\n7. In the **Advanced aggregation** pane, click the **Aligner** list and select\n **sum**.\n\n8. In the **Configuration** panel, select the following values:\n\n - **Condition triggers if** : `Any time series violates`\n - **Condition** : `is above`\n - **Threshold** : `1`\n - **For** : `most recent value`\n\n9. Click **Save**.\n\n10. On the **Create new alerting policy** page, enter a policy name.\n Optionally, you can add notification channels and documentation for\n this policy.\n\n11. Click **Save**.\n\nWhat's next\n-----------\n\n- Learn about snapshot schedule frequencies, retention policies, and naming rules in [About snapshot schedules for disks](/compute/docs/disks/about-snapshot-schedules).\n- Learn about [disk snapshots](/compute/docs/disks/snapshots).\n- Learn how to [create scheduled snapshots for disks](/compute/docs/disks/scheduled-snapshots).\n- Learn how to [view logs](/logging/docs/view/logs-explorer-interface)."]]