An alerting policy describes a set of conditions that you want to monitor. These conditions might relate to the state of an unhealthy system or to resource consumption. For example, you might want to create a policy to monitor an uptime check, or to create a policy that monitors your Stackdriver Monitoring API usage. In addition to conditions, in an alerting policy, you can specify how you want to be notified and what documentation is included in that notification.
This page illustrates how to use the Stackdriver Monitoring console to create and manage an alerting policy. You can also use the Stackdriver Monitoring API to perform these tasks; see Managing alerting policies by API for information on that approach. To see policies represented in JSON, see Sample policies.
Before you begin
Before creating alerting policies, you should be familiar with the general concepts and terminology in alerting policies. This includes understanding the components of a policy, the concept of an incident, and pricing and limitations. See Introduction to alerting for more information.
Setting up notification channels
Notification channels let you specify how you want to be informed of alerts. If a type of notification channel is configured, you have the option to select it when setting up notifications for your alerting policy. See Notification options for a list of available notification channel types and their configuration.
Alert policies on uptime checks
By creating an alerting policy for an uptime check from the Uptime checks window, the conditions field of the alerting policy are pre-populated for you.
To create an alerting policy for a new uptime check, see Creating uptime checks for information.
To create an alerting policy for an existing uptime check, see Alerting on uptime checks for more information.
Creating an alerting policy
In the Google Cloud Platform Console, choose your project from the drop-down list.
Go to Stackdriver > Monitoring. If this is the first time you've used the project in Stackdriver, you must create a Workspace. See Getting a Workspace quickly for details.
Go to Alerting > Create a Policy. The following sections describe the four options to customize your alerting policy.
Now that you have opened the Create New Alering Policy window, the first step in defining your alerting policy is to add a condition. Conditions describe what is being monitored and when an alert is triggered. A policy can have up to 6 conditions.
To add an alerting condition to a policy, in the Create New Alerting Policy window, click Add Condition. For information on defining conditions, see Specifying Conditions.
You have the option to add one or more notification channels to your alerting policy. Notification channels let you specify how you want to be informed of alerts. For details on your choices of notification channels see Notification options.
Adding a notification channel to an alerting policy is optional. If you don't configure a notification channel for an alert policy, then you won't be notified when an incident occurs. However, you can monitor the Stackdriver Monitoring dashboard for alert conditions.
In the Notification Channel Type drop-down list, select a notification channel, such as Google Cloud Console (mobile) or Email:
Depending on the Notification Channel Type, you might need to complete additional fields. For example, if you select Email, you are prompted for your email address.
Click Add Notification Channel.
To add an additional notification channel to your policy, repeat the previous steps. Having at least two different types of notification channel increases reliability in case one is unavailable.
You also have the option to add documentation to your alerting policy. Documentation is sent along with notifications to help the recipients handle the condition. You can use Markdown to format your documentation, or use plain text.
For example, documentation might include a title such as "Addressing High CPU Usage" and details that identify the project:
In addition to Markdown, you can use variables to pull information out of the policy itself, to tailor the content of your documentation. See Using variables for more information. You can also include channel-specific tagging to control notifications. See Using channel controls for more information.
Finish creating the policy
In the Create New Alerting Policy window, enter a policy name. The policy name is included in notifications, and it is displayed in the Policy overview pane.
You can view a summary of all alerting policies in the Alerting > Policies overview window:
The following screenshot shows a single policy from the overview page:
From this view, you can edit, delete, copy, enable, or disable an alerting policy.
To edit or copy a policy, click More, Creating an alerting policy. You can change, and in some cases, delete the values in the fields. When done, click Save., and select the corresponding option. Editing and copying a policy is similar to
To delete a policy, click More,, and select Delete. In the confirmation window, select Delete.
To turn on or off an alerting policy, click its toggle button. You can enable or disable a policy from the Policies overview pane or from its dashboard.