PromQL-based alerting policies

This page explains different methods of creating PromQL-based alerting policies. You can use PromQL queries to create complex conditions with features such as ratios, dynamic thresholds, and combined metrics.

If you use Prometheus in environments outside Google Cloud, or if you use alerting in Managed Service for Prometheus, then you can migrate your Prometheus alerting rules to PromQL-based alerting policies. This way, you can manage all of your alerting policies in Cloud Monitoring.

You can also import Grafana dashboards into Cloud Monitoring.

Overview

You can create PromQL-based alerting policies in the following ways:

  • Create an alerting policy in the Google Cloud console and define a PromQL query in the code editor.

  • Create a PromQL-based alerting policy by using the gcloud CLI or the AlertPolicy construct in the Monitoring API.

  • Migrate your Prometheus alerting rules and notification channels to Cloud Monitoring by using the Google Cloud CLI.

Incidents created by a PromQL-based alerting policy appear in the Google Cloud console with your other incidents. You can interact with these incidents in the Google Cloud console.

The conditions of your PromQL-based alerting policy can reference any metric in Cloud Monitoring, including Google Cloud system metrics, custom and log-based metrics, and Prometheus metrics. You must translate the names of non-Prometheus metrics to PromQL metric syntax. For more information, see Mapping Monitoring metrics to PromQL.

Restrictions

A PromQL-based alerting policy can have a retest window of at most 24 hours and an alignment period of at most 24 hours. The sum of the retest window and alignment period must be at most 25 hours.

If your Prometheus alerting rule references a metric, then you must first have an equivalent metric descriptor in Cloud Monitoring before creating your PromQL-based alerting policy. However, you can override this validation by configuring your PromQL-based alerting policy with the Cloud Monitoring API. For more information, see Disable check for metric existence.

Pricing

In general, Cloud Monitoring system metrics are free, and metrics from external systems, agents, or applications are not. Billable metrics are billed by either the number of bytes or the number of samples ingested.

For more information about Cloud Monitoring pricing, see the following documents:

What's next

For information about using the Google Cloud console to create alerting policies with a PromQL query in the condition, see Create PromQL-based alerting policies (Console).

For information about how to create alerting policies with PromQL directly using the Cloud Monitoring API, see Create PromQL-based alerting policies (API).

For information about how to migrate PromQL alerting rules to PromQL-based alerting policies in Monitoring, see Migrate alerting rules and receivers from Prometheus.

For information about importing Grafana dashboards, see Import Grafana dashboards into Cloud Monitoring.