Create PromQL-based alerting policies (Console)

This page describes how to create PromQL-based alerting policies by using the Google Cloud console.

Before you begin

  1. To get the permissions that you need to create PromQL-based alerting policies in 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.

  2. Ensure that you're familiar with the general concepts of alerting policies and PromQL in Cloud Monitoring. For more information, see the following topics:

  3. Configure the notification channels that you want to use to receive any alerts. For redundancy purposes, we recommend that you create multiple types of notification channels. For more information, see Create and manage notification channels.

  4. If the PromQL query in your alerting policy references any metrics, then the metrics must already exist in Monitoring when you create the alerting policy.

Create PromQL alerting policies

To create a PromQL-based alerting policy from the Google Cloud 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. On the Alerting page, click Create Policy.

  3. Under Policy configuration mode, select Code editor (MQL or PromQL).

  4. Verify that PromQL is selected in the Language toggle. The language toggle is in the same toolbar that lets you format your query.

  5. Enter the PromQL query that selects the data you want to monitor. If Auto-run isn't enabled, then click Run Query.

    For example, the following query summarizes the rate of billing logging data ingested over a 60-second interval and determines whether the summarized rate is over 300 bytes:

    sum(rate(logging_googleapis_com:billing_bytes_ingested{monitored_resource="global"}[60s]))>300
    

    After you run your query, you see a chart. For one project, this query produced the following result:

    Chart from a PromQL alerting condition after specifying the alert.

  6. Click Next, and then do the following:

    1. Select a Retest window. This field defines for how long the condition must be satisfied before the alerting policy is triggered.

      The default value is 0 sec. With this setting, a single measurement can result in a notification. For more information and an example, see Alignment period and duration settings.

    2. To select how often alerting evaluates the PromQL query, choose a value for the Evaluation interval.

    3. Enter a name for the condition and click Next.

  7. Click Next, and then do the following:

    1. Add notification channels.

    2. Choose a severity level for incidents.

    3. Optional: Add alerting policy labels and documentation.

    4. Enter a name for the alerting policy.

  8. Click Create policy.

For complete steps, see Managing alerting policies.