This page describes how to create PromQL-based alerting policies by using the Google Cloud console.
Before you begin
-
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.
Ensure that you're familiar with the general concepts of alerting policies and PromQL in Cloud Monitoring. For more information, see the following topics:
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.
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:
-
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.
On the Alerting page, click Create Policy.
Under Policy configuration mode, select Code editor (MQL or PromQL).
Verify that PromQL is selected in the Language toggle. The language toggle is in the same toolbar that lets you format your query.
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:
Click Next, and then do the following:
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.
To select how often alerting evaluates the PromQL query, choose a value for the Evaluation interval.
Enter a name for the condition and click Next.
Click Next, and then do the following:
Choose a severity level for incidents.
Optional: Add alerting policy labels and documentation.
Enter a name for the alerting policy.
Click Create policy.
For complete steps, see Managing alerting policies.