Notification options

This page lists the supported notification channel types and explains how to configure them by using the Google Cloud Console. To configure notification channels by using the Cloud Monitoring API, see Managing notification channels.

For information about alerting-policy notifications, see the following pages:

  • For information on the delay between a problem starting and an alert being created, see Notification latency.
  • For information on the number of notifications generated for an alerting policy, see Notifications per incident.

Creating channels

To create a notification channel by using the Cloud Console, do the following:

  1. In the Cloud Console, select Monitoring, or click the following button:

    Go to Monitoring

  2. In the Monitoring navigation pane, click Alerting.

  3. Click Edit notification channels.

  4. To add a new notification channel, locate the channel type, click Add new, and then follow the channel-specific instructions contained in the following table:

Email

To add an email, go to the Email section, click Add new and follow the instructions.

You can create e-mail channels during the creation of an alerting policy. For more information, see Creating a channel on demand.

If you use add a group email address as the notification channel for an alerting policy, then configure the group to accept mail from alerting-noreply@google.com.

An alerting policy sends an email notification when an incident is created and when the incident is resolved. This behavior can't be customized. However, you can set up email rules to filter your email notifications.

Mobile App

Use the Cloud Console Mobile App to monitor your Cloud Console resources and Monitoring information from anywhere.

To configure your mobile device to receive Monitoring notifications, do the following:

  1. Install Cloud Console Mobile App from your mobile device's app store.
  2. In Cloud Console Mobile App: Select the Settings menu to configure the app for your Workspace. You will be able to see your Cloud Console resources.
  3. In the Mobile Devices section, click Add new and follow the instructions.

After a few minutes, your mobile device will be listed under the Mobile Devices.

When you create an alerting policy, select Google Cloud Console (mobile) in the Notifications section, and choose your mobile device from the list.

PagerDuty

Integration with PagerDuty allows for one-way or two-way synchronization with Monitoring. Independent of your configuration, the following are true:

  • If an incident is created in Monitoring, then an incident is opened in PagerDuty.
  • You can't use PagerDuty to close an incident in Monitoring.

If you use one-way synchronization and if you resolve the incident in PagerDuty, then the state of the incident in PagerDuty is decoupled from the state of the incident in Monitoring. In effect, if you resolve an incident in PagerDuty, then the incident is permanently closed in PagerDuty and can't be reopened.

If you use two-way synchronization, then the state of the incident in PagerDuty is driven by the state of the incident in Monitoring. If you resolve the incident in PagerDuty and if Monitoring has the incident open, then the incident is reopened in PagerDuty.

To set up PagerDuty notifications, do the following:

  1. In PagerDuty: Create a PagerDuty account at the PagerDuty site.
  2. Complete the integration between PagerDuty and Monitoring by following the steps outlined in PagerDuty's Stackdriver Integration Guide.
  3. In the Notification channels window of the Google Cloud Console, add a PagerDuty notification channel:
    1. In the PagerDuty section, click Add new.
    2. Enter the Display Name. This name should match the name provided to PagerDuty when you added the integration.
    3. Enter the Integration Service Key generated by PagerDuty into the Service Key field.
    4. Click Save.
  4. (Optional) If you want to configure two-way synchronization, then do the following:
    1. In PagerDuty, select Configuration and then Services and then the service name you entered when configuring the integration.
    2. Click Edit Settings and check Create incidents. The action deselects Create alerts and incidents which is the default setting.

When you create an alerting policy, select PagerDuty in the Notifications section and choose your PagerDuty configuration.

In this document, the screenshots for Stackdriver are from an older version of Stackdriver, but the information is accurate.

SMS

To configure SMS notifications, do the following:

  1. In the SMS section, click Add new and follow the instructions.
  2. Click Save.

When you set up your alerting policy, select the SMS notification type and choose a verified phone number from the list.

Slack

The Monitoring Slack integration allows your alerting policies to post to a Slack channel when a new incident is created. To set up Slack notifications, do the following:

  1. In Slack: Create a Slack channel at the Slack site. Record the channel URL.
  2. In the Cloud Console, select Monitoring:

    Go to Monitoring

  3. Click Alerting and then click Edit notification channels.

  4. In the Slack section, click Add new. This brings you to the Slack sign-in page:

    1. Enter your Slack workspace URL.
    2. Click Allow to enable Google Cloud Monitoring access to your Slack workspace.

    When you create an alerting policy, select Slack in the Notifications section and choose your Slack configuration.

Webhooks

To configure Webhooks notifications, do the following:

  1. The webhook handler: Identify an endpoint URL that will receive webhook data from Monitoring.
  2. In the Webhooks section, click Add new and follow the instructions.
  3. Click Save.

When you create an alerting policy, select Webhook in the Notifications section and choose your webhook configuration.

Sample JSON packet

The form of the JSON packet to create an event is:

  {
    "incident": {
      "incident_id": "f2e08c333dc64cb09f75eaab355393bz",
      "resource_id": "i-4a266a2d",
      "resource_name": "webserver-85",
      "state": "open",
      "started_at": 1385085727,
      "ended_at": null,
      "policy_name": "Webserver Health",
      "condition_name": "CPU usage",
      "url": "https://console.cloud.google.com/monitoring/alerting/incidents?project=PROJECT_ID",
      "summary": "CPU for webserver-85 is above the threshold of 1% with a value of 28.5%"
    },
    "version": 1.1
  }

Basic authentication

In addition to the webhook request sent by Cloud Monitoring, basic basic authentication utilizes the HTTP specification for the username and password. Cloud Monitoring requires your server to return a 401 response with the proper WWW-Authenticate header. For more information about basic authentication, see the following:

Token authentication

Token Authentication requires a querystring parameter in the endpoint URL and a key that the server expects to be secret between itself and Monitoring. The following is a sample URL that includes a token:

https://www.myserver.com/stackdriver-hook?auth_token=1234-abcd

If Monitoring posts an incident to the endpoint URL, your server can validate the attached parameter. This method of authentication is most effective when used in conjunction with SSL/TLS to encrypt the HTTP request preventing snoopers from learning the token.

For an example server in Python, see this sample server.

Pub/Sub

To send notifications to a Pub/Sub topic, do the following:

  1. Create a Pub/Sub topic, as described in Creating a topic, if you don't already have one. The topic must exist before you can use it as a notification channel. The following command creates a topic called notificationTopic.

    gcloud pubsub topics create notificationTopic
  2. Create a notification channel that uses the topic. You can use the Monitoring API, the gcloud command-line tool, or the Cloud Console.

    To use the Cloud Console to create the notification channel, go to the Edit notification channels window and then do the following:

    1. In the Cloud Pub/Sub section, click Add new.
    2. Enter a display name for your channel, enter the Pub/Sub topic name, and then click Add channel.

    To use the Monitoring API or the gcloud command-line tool to create the notification channel, see Creating channels for information and examples.

  3. Authorize the notifications service account to publish to each Pub/Sub topic that you are using as a notification channel.

    When you create the first Pub/Sub channel, Cloud Monitoring creates a service account for the Monitoring Notification Service Agent, for the project in which the channel was created. This service account manages the sending of notifications to Pub/Sub-based notification channels in this project.

    This service account has an ID with the following structure:

    service-[PROJECT_NUMBER]@gcp-sa-monitoring-notification.iam.gserviceaccount.com

    You can see this account on the IAM page, not the Service accounts page, of the Cloud Console.

    To authorize this account to publish to a topic, you must give the service account the pubsub.publisher IAM role for the topic. The following command does this for the notificationTopic topic:

    gcloud pubsub topics add-iam-policy-binding \
    projects/[PROJECT_NUMBER]/topics/notificationTopic --role=roles/pubsub.publisher \
    --member=serviceAccount:service-[PROJECT_NUMBER]@gcp-sa-monitoring-notification.iam.gserviceaccount.com
    

    If the command succeeds, it returns output like the following:

    Updated IAM policy for topic [notificationTopic].
    bindings:
    ‐ members:
      ‐ serviceAccount:service-[PROJECT_NUMBER]@gcp-sa-monitoring-notification.iam.gserviceaccount.com
      role: roles/pubsub.publisher
    etag: BwWcDOIw1Pc=
    version: 1
    

    For more information, see the pubsub topics add-iam-policy-binding reference page.

    Note that the project number is not the same as the project ID. Project IDs are typically strings that reflect the project name, like my-test-project. Project numbers are unique numerical identifiers. You can find the project name, ID, and number on the project's landing page in the Cloud Console, or you can retrieve it with the following command:

    gcloud projects describe [PROJECT_ID] --format="value(project_number)"
    
  4. Add the Pub/Sub channel to an alerting policy by selecting Pub/Sub as the channel type and a named topic as the notification channel.

Creating a channel on demand

In the classic notification channel dialogs, you select the channel type and then select from a list a specific notification option. The one exception to this rule is email notifications; in this case, you can enter an email address.

In the newer notification dialogs, you must select a notification channel from a list. If the list doesn't contain a notification channel that you want to use, then you have the option to update the configured notification channels using the following process:

  1. In the notification dialog, click Manage Notification Channels. You are taken to the Notification channels window in a new browser tab.
  2. To add a new notification channel, locate the channel type, click Add new, and then follow the channel-specific instructions contained in the previous table.
  3. Return to the original tab, and in the notification dialog, click Refresh .

    Notification dialog displaying the refresh and manage channels buttons.

  4. Select the notification channel from the updated list.

Editing and deleting channels

To edit or delete a notification channel by using the Cloud Console, do the following:

  1. In the Cloud Console, select Monitoring, or click the following button:

    Go to Monitoring

  2. In the Monitoring navigation pane, click Alerting.

  3. Click Edit notification channels.

    The Notification channels dashboard contains a section for each type of notification channel. Below the section header is a list of all configurations for that type:

    • To modify an entry, click Edit . Click Save after your changes are complete.
    • To delete an entry, click Delete . Click Delete in the confirmation dialog.