Create alerting policies with a PromQL-based condition (Console)

This page describes how to create an alerting policy with a PromQL-based condition by using the Google Cloud console.

Before you begin

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

    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 uses a custom metric, then the metric must already exist.

Create PromQL alerting policies

To create an alerting policy with a PromQL-based condition 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:


    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 configure the alert trigger.

    1. Select a value for the Alert trigger. This value specifies how many time series returned by the query must satisfy the alerting operation before the alerting policy can be triggered. You can select from the following criteria:

      • Any time series.
      • A percentage of the time series.
      • A specific number of time series.
      • All of the time series.
    2. 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.

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

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

  7. Add notification channels.

  8. Optional: Add alerting policy labels and documentation.

  9. Click Alert name and enter a name for the alerting policy.

  10. Click Create policy.

For complete steps, see Managing alerting policies.