Create and manage snoozes

This document describes how to create and manage your snoozes. A snooze prevents Cloud Monitoring from creating incidents and issuing notifications during a specific time period. Each snooze specifies the resources to which it applies.

For a conceptual overview, see Snooze notifications and incidents.

To create and manage your snoozes, you use the Google Cloud console or the Cloud Monitoring API.

Before you begin

  1. Ensure that you have the required permissions:

    For more information about Cloud Monitoring roles, see Control access with Identity and Access Management.

  2. If you want to use the Cloud Monitoring API examples in this document, then do the following:

    1. Create an environment variable, PROJECT_ID, to hold the ID of your Google Cloud project:

      PROJECT_ID=PROJECT_ID
      
    2. Authenticate to Google Cloud CLI:

      gcloud auth login
      
    3. Set the default Google Cloud project:

      gcloud config set project ${PROJECT_ID}
      
    4. Create an authorization token:

      ACCESS_TOKEN=`gcloud auth print-access-token`
      

      You have to periodically refresh the access token. If commands that worked suddenly report that you're unauthenticated, re-issue this command.

Create a snooze

To prevent alerting policies from creating incidents and sending notifications, create a snooze.

You can create a snooze by using the Google Cloud console, the gcloud CLI, or the Cloud Monitoring API.

console

  1. In the Google Cloud console, go to the  Alerting page:

    Go to Alerting

    If you use the search bar to find this page, then select the result whose subheading is Monitoring.

  2. To create a snooze from an open incident, do the following:
    1. In the Incidents pane of the Alerting page, find your incident and click its Incident summary.
    2. On the Incident details page, click Snooze, and then select the snooze duration. You can't configure any other fields.
  3. Otherwise, do the following:

    1. On the Alerting page, click Create snooze.
    2. Enter a descriptive name for the snooze. This name is shown on the Alerting page.
    3. Select a Start time. You can enter a specific time or you can start the snooze when the snooze is created.
    4. Enter the Duration. The value of this field determines how long the snooze lasts.
    5. Complete the Snooze criteria section. You can use the Alert policies menu to select the alerting policies to which the snooze applies.

      You can add up to 16 alerting policies to a snooze.

      After you complete the Snooze criteria section, the Create snooze pane lists past incidents that match the criteria.

    6. Click Create.

Cloud Monitoring API

To create a snooze, invoke the snoozes.create method by issuing a POST request to the Snooze endpoint. You must supply a snooze object:

curl -d @my-snooze.json -H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-X POST https://monitoring.googleapis.com/v3/projects/${PROJECT_ID}/snoozes

The method returns a snooze object. The "name" field, which includes the snooze ID that is generated by Monitoring, is the only difference between the returned object and the contents of my-snooze.json:

{
  "name": "projects/my-project/snoozes/2986666341878464512",
  "criteria": {
    "policies": [
      "projects/my-project/alertPolicies/787884840895011889"
    ]
  },
  "interval": {
    "startTime": "2022-11-12T19:00:20Z",
    "endTime": "2022-11-12T19:05:20Z"
  },
  "displayName": "Snooze2"
}

gcloud CLI

To create a snooze, run the gcloud monitoring snoozes create command:

gcloud monitoring snoozes create --criteria-policies=LIST_OF_POLICIES --display-name=DISPLAY_NAME --start-time=START_TIME --end-time=END_TIME

In the previous command, the end-time must be at least one minute later than the start-time. You must follow the ISO 8601 formatting rules; however, you can specify absolute or relative times. The following example specifies absolute times. To start a snooze 30 minutes from the current time, use --start-time="+PTM30M".

If you specify multiple projects, then separate the projects by a comma.

For example, the following command creates a snooze with the display name of "Maintenance Week". The snooze applies to two alerting policies and spans the time interval from March first through March seventh:

gcloud monitoring snoozes create --display-name="Maintenance Week" \
    --criteria-policies="projects/my-project/alertPolicies/12345,projects/my-project/alertPolicies/23451" \
    --start-time="2023-03-01T03:00:00.0-0500" \
    --end-time="2023-03-07T23:59:59.5-0500"

The previous example creates the following snooze in my-project:

{
 "name": "projects/my-project/snoozes/98765",
 "displayName": "Maintenance Week",
 "interval": {
   "startTime": "2023-03-01T08:00:00Z",
   "endTime": "2023-03-08T04:59:59Z"
 },
 "criteria": {
   "policies": [
     "projects/my-project/alertPolicies/12345",
     "projects/my-project/alertPolicies/23451",
   ]
 }
}

If successful, the response to this command is similar to the following:

Created snooze [projects/my-project/snoozes/98765]

The name of an alerting policy isn't displayed in the Google Cloud console. To determine the name of an alerting policy, do one of the following:

  • Run the gcloud alpha monitoring policies list command. The response data of this command includes the name of your alerting policies.
  • View the JSON representation of an alerting policy. You can download the JSON representation to your local system by using an option on the Policy details page.

Create recurring snoozes

To create snoozes that happen over recurring intervals, you can write a script that creates a snooze for an alerting policy. Then, use a job scheduler such as cron or Cloud Scheduler to run the script on your required schedule.

List snoozes

When you create a snooze, it's added to the historical record of snoozes for your project. This record shows the expired, active, and upcoming snoozes. You can't remove entries from this record, that is, you can't delete a snooze. However, from this view, you can display the details about a snooze and you can perform actions like editing or copying the snooze.

console

To view a list of snoozes, do the following:

  1. In the Google Cloud console, go to the  Alerting page:

    Go to Alerting

    If you use the search bar to find this page, then select the result whose subheading is Monitoring.

  2. Click See all snoozes in the Snooze pane.

    The Snooze page displays a list of snoozes and a timeline that graphically displays your past, upcoming, and active snoozes.

    • To edit, copy, cancel, or end a snooze, use the More options menu for the snooze. The snooze state determines which options are available.
    • To list all snoozes, enable Show past snoozes. By default, only active and upcoming snoozes are listed.
    • To change the display period for the Timeline table, use the Time range menu. By default, the table shows data for the next hour; however, you can modify this field to specify past or future time ranges. Expired snoozes are retained for 13 months.
    • To view details about a specific snooze, click View details.
    • To view a summary of active snoozes, place your pointer on the shaded area of the Active row in the Timeline table. The tooltip displays the summary information.
    • To view a graphical representation of active snoozes, expand the Active row of the Timeline table.

Cloud Monitoring API

To list all snoozes that belong to a Google Cloud project, invoke the snoozes.list method:

curl -H "Authorization: Bearer $ACCESS_TOKEN" \
https://monitoring.googleapis.com/v3/projects/${PROJECT_ID}/snoozes

The method returns a list of snooze objects. For example, when a project has one snooze, the response to the snoozes.list command is similar to the following:

{
  "snoozes": [
    {
      "name": "projects/my-project/snoozes/2986663705844383744",
      "criteria": {
        "policies": [
          "projects/my-project/alertPolicies/787884840895011889"
        ]
      },
      "interval": {
        "startTime": "2022-11-08T19:00:20Z",
        "endTime": "2022-11-08T19:05:20Z"
      },
      "displayName": "Snooze1"
    }
  ]
}

To get information about a specific snooze, invoke the snoozes.get method and specify the project ID and the snooze ID. In the previous response, the snooze ID is 2986663705844383744:

curl -H "Authorization: Bearer $ACCESS_TOKEN" \
https://monitoring.googleapis.com/v3/projects/${PROJECT_ID}/snoozes/${SNOOZE_ID}

The method returns a single snooze object:

{
  "name": "projects/my-project/snoozes/2986663705844383744",
  "criteria": {
    "policies": [
      "projects/my-project/alertPolicies/787884840895011889"
    ]
  },
  "interval": {
    "startTime": "2022-11-08T19:00:20Z",
    "endTime": "2022-11-08T19:05:20Z"
  },
  "displayName": "Snooze1"
}

gcloud CLI

To list the snoozes in your current project, run the gcloud monitoring snoozes list command:

gcloud monitoring snoozes list OPTIONAL_FLAGS

For information about the optional flags, see the gcloud monitoring snoozes list reference page.

The response to this command is a list of names of snoozes in the project, formatted as YAML. For example, the response to this command for the Google Cloud project with ID my-project is a single entry:

criteria:
  policies:
  - projects/my-project/alertPolicies/12345
  - projects/my-project/alertPolicies/23451
displayName: Maintenance Week
interval:
  endTime: '2023-03-08T04:59:59Z'
  startTime: '2023-03-01T08:00:00Z'
name: projects/my-project/snoozes/98765

To list details about a specific snooze, run the gcloud monitoring snoozes describe command:

gcloud monitoring snoozes describe NAME

For example, to display the details about the snooze with name projects/my-project/snoozes/98765, run the following command:

gcloud monitoring snoozes describe projects/my-project/snoozes/98765

If you provide an invalid NAME to a describe command, then the response contains an error code of 500 and the following message:

Internal error encountered. Please retry after a few seconds. If internal errors persist, contact support at https://cloud.google.com/support/docs.

Edit a snooze

You can edit the name and period of an upcoming snooze, and you can edit the name and end time of an active snooze. For example, when a maintenance window is rescheduled, you might need to edit a snooze.

You can't edit a past snooze or the criteria of any snooze. However, if you want to schedule a past snooze for a future time period, then copy the snooze and apply changes to the copy before you select Create.

console

To edit a snooze, do the following:

  1. In the Google Cloud console, go to the  Alerting page:

    Go to Alerting

    If you use the search bar to find this page, then select the result whose subheading is Monitoring.

  2. Click See all snoozes in the Snooze pane.
  3. In the list of snoozes, find the snooze that you want to edit, and then select Edit snooze in the More options menu.
  4. Click Save after you complete your changes.

Cloud Monitoring API

To modify an existing snooze, invoke the snoozes.patch method by issuing a PATCH request to the Snooze endpoint. You must supply the revised snooze object and include query parameters that identify which fields are modified. When using curl, query parameters must be URL-encoded.

For upcoming snoozes, you can modify the name and the period. For active snoozes, you can modify the name and the end time. You can't modify past snoozes.

To update the displayName of a snooze, create a JSON file, my-updated-snooze.json, which describes the snooze object and updates the display name. Then, run the following command:

curl -d @my-updated-snooze.json -H "Authorization: Bearer $ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-X PATCH https://monitoring.googleapis.com/v3/projects/${PROJECT_ID}/snoozes/${SNOOZE_ID}?updateMask=displayName

The method returns a snooze object which is identical to the contents of the file my-updated-snooze.json:

{
  "name": "projects/my-project/snoozes/2986665388391530496",
  "criteria": {
    "policies": [
      "projects/my-project/alertPolicies/7164333552684403347"
    ]
  },
  "interval": {
    "startTime": "2022-11-08T22:26:05Z",
    "endTime": "2022-11-08T22:31:05Z"
  },
  "displayName": "Updated snooze name"
}

gcloud CLI

To edit a snooze, run the gcloud monitoring snoozes update command. You can update the display name, the start time, and the end time:

gcloud monitoring snoozes update NAME OPTIONAL_FLAGS

For a list of options to the update command, see the gcloud monitoring snoozes update reference page.

For example, to change the display name of the snooze with the name projects/my-project/snoozes/98765, run the following command:

gcloud monitoring snoozes update projects/my-project/snoozes/98765  --display-name="March Maintenance"

End or cancel a snooze

If you want to receive notifications for resources that match the criteria specified in an active snooze, then end the snooze. For example, when planned maintenance completes more quickly than anticipated, you might want to end a snooze.

If you have an upcoming snooze that you no longer want, then cancel the snooze. The cancel operation sets the duration to zero and results in the snooze transitioning to the Past state.

console

To end an active snooze or to cancel an upcoming snooze, do the following:

  1. In the Google Cloud console, go to the  Alerting page:

    Go to Alerting

    If you use the search bar to find this page, then select the result whose subheading is Monitoring.

  2. Click See all snoozes in the Snooze pane.
  3. In the list of snoozes, find the snooze that you want to end or cancel, and then do one of the following:

    • To end an active snooze, select End now in the More options menu.
    • To cancel an upcoming snooze, select Cancel snooze in the More options menu.

Cloud Monitoring API

To end an active snooze, edit the snooze and set the end time to the current time. For more information, see Edit a snooze.

To cancel an upcoming snooze, edit the snooze and set the end time to the snooze start time. The start time must be in the future. For more information, see Edit a snooze.

gcloud CLI

To end an active snooze or to cancel an upcoming snooze, run the gcloud monitoring snoozes cancel command:

gcloud monitoring snoozes cancel NAME

For example, to cancel the snooze with the name projects/my-project/snoozes/98765, run the following command:

gcloud monitoring snoozes cancel projects/my-project/snoozes/98765

Copy a snooze

When you want to use an existing snooze as a template for another snooze, make a copy. When you copy a snooze, the snooze editor opens with all fields except for the start time set to the values in the original snooze. You can modify all fields before you click Create.

To copy a snooze by using the console, do the following:

  1. In the Google Cloud console, go to the  Alerting page:

    Go to Alerting

    If you use the search bar to find this page, then select the result whose subheading is Monitoring.

  2. Click See all snoozes in the Snooze pane.
  3. In the list of snoozes, find the snooze that you want to edit, and then select Copy snooze in the More options menu.
  4. Apply your modifications to the copy and then click Create.

What's next