You can configure Error Reporting to send error notifications to selected Cloud Monitoring notification channels.
Error Reporting sends notifications in the following cases:
-
When an error first occurs in a Google Cloud project, and it can't be grouped with previous errors.
-
If an error that was marked as Resolvedreoccurs.
Manage notification channels
You create, edit, and delete notification channels in Monitoring. After you have created notification channels, you can configure Error Reporting to use them.
Error Reporting lets you select from four types of notification channels: email, mobile, Slack, and Webhooks.
Before you begin
To get the permissions that
you need to view and configure notification channels by using the Google Cloud console,
ask your administrator to grant you the Monitoring Editor
( roles/monitoring.editor
)
IAM role on your 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 .
For more information about Cloud Monitoring roles, see Control access with Identity and Access Management .
Create notification channel
To create a notification channel by using the Google Cloud console, follow the channel-specific instructions contained in the following table:
To add an email notification channel, do the following:
-
In the Google Cloud console, go to the notifications Alerting page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring .
- In the toolbar of the Google Cloud console, select your Google Cloud project. For App Hub configurations, select the App Hub host project or the app-enabled folder's management project.
- Click Edit notification channels .
- In the Email section, click Add new .
- Enter a single email address and a description.
- Click Save .
If you use a group email address as the notification channel for
an alerting policy, then configure the group to accept mail from ErrorReportingNotifications-noreply@google.com
.
Mobile App
Use the Google Cloud console Mobile App to monitor your Google Cloud console resources and Monitoring information from anywhere. Google Cloud console Mobile App notifications are either sent to a specific device or to a specific user:
- Device indicates that notifications are sent only to the specific device that created the notification channel. For device-scoped notification channels, the Display name field includes device information.
- User indicates that the notifications are sent to all of your devices that have the Google Cloud console Mobile App installed.
Cloud Monitoring determines the notification scope when the channel is created. You can't select or change the scope.
To configure a Google Cloud console Mobile App notification channel for a specific Google Cloud project, do the following:
- Install the Google Cloud console Mobile App from your mobile device's app store.
-
Select a project for viewing in the Google Cloud console Mobile App.
After you select a project, a data exchange between the app and the selected Google Cloud project occurs. A notification channel is created when one doesn't exist, and after a few minutes, this channel is listed under the Mobile Devices section of the Notification channels page.
To add your mobile device as a notification channel for an alerting policy, in the alerting Notificationssection, select Google Cloud console (mobile)and then choose your mobile device from the list.
Slack
To set up Slack notifications, do the following:
-
In Slack: Create a Slack workspace and channel at the Slack site . Record the channel URL.
-
In the Google Cloud console, go to the notifications Alerting page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring .
-
In the toolbar of the Google Cloud console, select your Google Cloud project. For App Hub configurations, select the App Hub host project or the app-enabled folder's management project.
-
Click Edit notification channels .
-
In the Slacksection, click Add newto open the Slack sign-in page:
- Select your Slack workspace.
- Click Allowto enable Cloud Monitoring access to your Slack workspace. This action takes you back to the Monitoring configuration page for your notification channel.
- In the Slack Channel Namefield, enter the name of the Slack channel you want to use for notifications.
- In the Cloud Alerting Display Namefield, enter a short descriptive statement. Monitoring displays the value of this field on the Notifications channelpage.
- (Optional) To test the connection between
Cloud Monitoring and your Slack workspace, click Send test notification. If the connection is successful, then
you see a message
This is a test alert notification...
in the Slack notification channel that you specified. Check the notification channel to confirm receipt.
-
If the Slack channel you want to use for notifications is a private channel, then you must manually invite the Monitoring app to the channel:
- Open Slack.
-
Go to the channel you specified as your Monitoring notification channel.
-
Invite the Monitoring app to the channel by entering and sending the following message in the channel:
/invite @Google Cloud Monitoring
Be sure you invite the Monitoring app to the private channel you specified when creating the notification channel in Monitoring. Inviting the Monitoring app to public channels is optional.
Webhooks
Before you configure a Webhook notification channel, consider the following:
- Webhooks only support public endpoints. A public endpoint is fully
accessible from the public internet, such as by HTTP (
port:80
) or HTTPS (port:443
). The notification service must be able to establish a connection to the endpoint and, in the case of HTTPS, verify the server's security certificate. - If a Cloud Run function is configured as webhook endpoint for a notification channel, then make sure the user invoking the function has the required authentication permission. For more information, see Authenticate for invocation and Enabling access to a function .
- Webhook notification channels aren't compatible with Microsoft Teams. To send notification data from Monitoring to Microsoft Teams, create an integration layer to receive the Monitoring webhook and then reroute it to Microsoft Teams.
Configure Webhook notification channels
To configure Webhooks notifications, do the following:
- The webhook handler: Identify the public endpoint URL to receive webhook data from Monitoring.
-
In the Google Cloud console, go to the notifications Alerting page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring .
- In the toolbar of the Google Cloud console, select your Google Cloud project. For App Hub configurations, select the App Hub host project or the app-enabled folder's management project.
- Click Edit notification channels .
- In the Webhook section, click Add new .
- Complete the dialog.
- Click Test Connection to send a test payload to the Webhook endpoint. You can go to the receiving endpoint to verify delivery.
- Click Save .
Webhook schema
To view the Webhook schema structure for Error Reporting, click the following:
Schema structure, version 1.0
{
"version"
: "1.0",
"subject"
:
string, description of the new or reopened error group.
"group_info"
: {
"project_id"
:
string, project that owns the error group.
"detail_link"
:
string, link to the Error Reporting Details
page for the error
group.
},
"exception_info"
: {
"type"
:
string, type of the exception logged in the event.
"message"
:
string, exception message for the event.
},
"event_info"
: {
"log_message"
: string
"request_method"
: string
"request_url"
: string
"referrer"
: string
"user_agent"
: string
"service"
: string
"version"
: string
"response_status"
: string
},
}
Basic authentication
In addition to the webhook request sent by Cloud Monitoring, 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 query string 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 token. This method of authentication is most effective when used with SSL/TLS to encrypt the HTTP request preventing snoopers from learning the token.
For an example server in Python, see this sample server .