[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-05。"],[],[],null,["# PromQL-based alerting policies\n\nThis page describes how you can create PromQL-based alerting policies in\nCloud Monitoring. You can use PromQL queries to create\ncomplex conditions with features such as ratios, dynamic thresholds, and\ncombined metrics.\n\nIf you use Prometheus in environments outside Google Cloud,\nor if you use alerting in Managed Service for Prometheus,\nthen you can migrate your Prometheus alerting rules to PromQL-based alerting\npolicies. This way, you can manage all of your alerting\npolicies in Cloud Monitoring.\n\nYou can also [import Grafana dashboards into\nCloud Monitoring](/monitoring/dashboards/import-grafana-dashboards).\n\n- For general information about using PromQL in Monitoring, see [PromQL in Cloud Monitoring](/monitoring/promql).\n- For general information about alerting policies, see [Behavior of metric-based alerting policies](/monitoring/alerts/concepts-indepth).\n\nUse PromQL in Cloud Monitoring alerting policies\n------------------------------------------------\n\nYou can create PromQL-based alerting policies in the following ways:\n\n- To create an alerting policy in the Google Cloud console and define a PromQL\n query in the code editor, see [Create PromQL-based alerting\n policies (Console)](/monitoring/promql/create-promql-alerts-console).\n\n- To create a PromQL-based alerting policy\n by using the gcloud CLI or the [`AlertPolicy`](/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#AlertPolicy)\n construct in the Monitoring API, see\n [Create PromQL-based alerting policies (API)](/monitoring/promql/create-promql-alerts).\n\n- To migrate your Prometheus alerting rules and notification channels to\n Cloud Monitoring by using the Google Cloud CLI, see\n [Migrate alerting rules and receivers from Prometheus](/monitoring/promql/promql-migrate).\n\nIncidents created by a PromQL-based alerting policy\nappear in the Google Cloud console with your other incidents.\nYou can interact with these incidents in the Google Cloud console.\n| **Note:** Incidents created by a PromQL-based alerting policy don't follow the alerting policy autoclose duration. Instead, the incident is automatically closed when it reaches a set time after the last time the condition was met. This time is the larger of 270 seconds and twice the condition's evaluation interval.\n\nThe conditions of your PromQL-based alerting policy can reference any metric\nin Cloud Monitoring, including Google Cloud system metrics, custom and\nlog-based metrics, and Prometheus metrics. You must\ntranslate the names of non-Prometheus metrics\nto PromQL metric syntax. For more information, see\n[Mapping Monitoring metrics to PromQL](/monitoring/promql/promql-mapping).\n\nRestrictions\n------------\n\nA PromQL-based alerting policy can have a retest window of\nat most 24 hours and an alignment period of at most 24 hours. The sum of the\nretest window and alignment period must be at most 25 hours.\n\nIf your Prometheus alerting rule references a metric, then you must first have\nan equivalent metric descriptor in Cloud Monitoring before creating\nyour PromQL-based alerting policy. However, you can\noverride this validation by configuring your PromQL-based alerting policy\nwith the Cloud Monitoring API. For more information, see\n[Disable check for metric existence](/monitoring/promql/create-promql-alerts#disable-validatoin).\n\nPricing\n-------\n\nIn general, Cloud Monitoring system metrics are free, and metrics\nfrom external systems, agents, or applications are not. Billable metrics are\nbilled by either the number of bytes or the number of samples ingested.\n\nFor more information, see the Cloud Monitoring sections of the [Google Cloud Observability pricing](https://cloud.google.com/stackdriver/pricing) page."]]