This page explains different methods of creating alerting policies with a PromQL query in their condition.
Alerting policies with a PromQL-based condition provide an open source alternative to using Monitoring Query Language (MQL) queries to configure your alerting policy conditions. 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 alerting policies with a PromQL-based condition. This way, you can manage all of your alerting policies in Cloud Monitoring.
You can also import Grafana dashboards into Cloud Monitoring.
- For general information about using PromQL in Monitoring, see PromQL in Cloud Monitoring.
- For general information about alerting policies, see Behavior of metric-based alerting policies.
Overview
You can create alerting policies with a PromQL-based condition in the following ways:
Create an alerting policy in the Google Cloud console and define a PromQL query in the code editor.
Create an alerting policy with a PromQL-based condition 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 an alerting policy with a PromQL-based condition appear in the Google Cloud console with your other incidents. You can interact with these incidents in the Google Cloud console.
Your PromQL alerting policy conditions 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
An alerting policy with a PromQL-based condition 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 custom metric, then you must first have an equivalent custom metric descriptor in Cloud Monitoring.
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 alerting policies with a PromQL-based condition (Console).
For information about how to create alerting policies with PromQL directly using the Cloud Monitoring API, see Create alerting policies with a PromQL-based condition (API).
For information about how to migrate PromQL alerting rules to alerting policies with a PromQL query, see Migrate alerting rules and receivers from Prometheus.
For information about importing Grafana dashboards, see Import Grafana dashboards into Cloud Monitoring.