Manage metric-based alerting policies

This document describes how to edit, list, and view your alerting policies by using the Google Cloud console. It also describes how to view the JSON representation of a policy and how to add alerting policies to a custom dashboard. When you add policies to a custom dashboard, you can view your policies in the same context as your metric data.

This document describe using the Cloud Monitoring API. For more information, see Managing alerting policies by API.

Before you begin

  1. Ensure that your Identity and Access Management role includes the necessary permissions:

    • To view alerts, your role must include the permissions in the role roles/monitoring.alertPolicyViewer.
    • To create and edit alerts, your role must include the permissions in the role roles/monitoring.alertPolicyEditor.
    • To add alerts to a custom dashboard, your role must include the permissions in the role roles/monitoring.dashboardEditor.

    For more information about roles, see Access control.

  2. Ensure that you're familiar with the general concepts of alerting policies. For more information, see Introduction to alerting.

Edit, list, or delete policies

  1. In the console, select Monitoring or click the following button:
    Go to Monitoring

  2. In the navigation pane, select Alerting.

    The Alerting page displays panes that list summary information, incidents, and alerting policies.

  3. Click See all policies in the Policies pane.

    The Policies page lists all policies, includes a filter bar, and for each policy, options to edit, copy, or delete the policy:

    • To filter the list of alerting policies, do one of the following:

      • Enter a name on the filter bar. For example, enter Example to display policies with the string Example in their name. A case-insensitive comparison tests whether a filter is listed.
      • Click Filter policies, select the filter property, and then either enter a value for the filter or select a value from the menu.

      When you have multiple filters, a logical AND joins the filters unless you insert an OR filter. The following screenshot lists all alerting policies that match test or My Uptime Check Alert Policy:

      Sample alerts overview with filters.

  4. Optional: To view the details of a policy, click the name of the policy. For information about the Policy details page, see View an alerting policy.

  5. Optional: To edit or copy a policy, click More options, and select the corresponding option. Editing and copying a policy is similar to Creating an alerting policy. You can change, and sometimes delete, the values in the fields. When done, click Save policy.

  6. Optional: To delete a policy, click More options and select Delete. In the confirmation dialog, select Delete.

    If you delete the alerting policy associated with an alert chart, then the alert chart no longer displays any data. For more information, see Alert chart doesn't display any data.

View an alerting policy

  1. In the console, select Monitoring or click the following button:
    Go to Monitoring

  2. In the navigation pane, select Alerting.

  3. To list all policies, click See all policies in the Policies pane.

  4. Find the policy that you want to view, and then select it.

For example, the following screenshot illustrates the details for the alerting policy named Test staging:

Sample alert-policy details page.

As shown in the previous image, the details page provides you information about the alerting policy:

  • To view incidents created by the policy, see the Incidents section.

  • To view the configured notification channels, see the Notification Channels section.

  • To view the additional information that you specified to be included with a notification, see the Documentation section.

  • To view the user-defined labels, view the Labels section. For examples that illustrate how you can use labels to manage your alerts, see Add severity levels to an alerting policy.

  • To edit, copy, delete, download the JSON representation, or change the enabled state of the policy, use options in the toolbar. For example, to disable an alerting policy that is enabled, click Enabled and then select Disable in the confirmation dialog.

View JSON for an alerting policy

When you create or modify an alerting policy by using the Cloud Monitoring API, you provide a JSON representation of that policy to the API method. You can create the JSON yourself by using the API documentation to guide the content. An alternative is to create a policy by using the Google Cloud console, and then download the policy to your local system. The JSON file that you downloaded can be edited and used as a template for other policies. For examples of policies described by JSON, see Sample policies.

To download the JSON representation of an alerting policy, do the following:

  1. In the console, select Monitoring or click the following button:
    Go to Monitoring
  2. In the navigation pane, select Alerting.
  3. Find the policy that you want to view, and then click the policy name to open the Policy details page.
  4. Click JSON.

To view the JSON representation of an alerting policy when you're editing it, click View code.

Add alerting policy to dashboard

To view your alerting policies in the same context as your metric data, add those policies to a custom dashboard. When you view that dashboard, it shows a chart for each alerting policy that you added. These charts display the monitored metric, the threshold, and the number of open incidents for the policy. These charts also contain links that let you view or edit the policy.

You can add policies with one condition to custom dashboards. Policies that contain multiple conditions can be viewed only from the alerting context.

To display a summary of an alerting policy on a custom dashboard, do the following:

  1. In the console, select Monitoring or click the following button:
    Go to Monitoring
  2. In the navigation pane, select Dashboards, then select the dashboard that you want to view or edit.
  3. If the Edit dashboard button is shown, then click it.

  4. Select Alert chart from the widget library, or click Add chart and then select Alert chart from the menu.

  5. In the configuration pane of the Alert chart, use the Alert policy menu to select an alerting policy. Only single-condition alerting policies can be selected from the Alert policy menu.

The following screenshot illustrates an alert chart:

Example of an alert chart.

In this example, the alerting policy is monitoring the CPU usage of two different virtual machines. The dashed line shows the condition threshold, which is set to 50%. The green chip with the label No incidents indicates that there are no open incidents for the alerting policy. If you place your pointer on the chip that shows the number of open incidents, then a dialog opens that links to the underlying alerting policy.

For more information, see Using dashboards and charts.