[[["易于理解","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-28。"],[],[],null,["# Create PromQL-based alerting policies (Console)\n\nThis page describes how to create PromQL-based alerting policies\nby using the Google Cloud console.\n\nBefore you begin\n----------------\n\n1.\n\n To get the permissions that\n you need to create PromQL-based alerting policies in the Google Cloud console,\n\n ask your administrator to grant you the\n\n\n [Monitoring Editor](/iam/docs/roles-permissions/monitoring#monitoring.editor) (`roles/monitoring.editor`)\n IAM role on your project.\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n\n For more information about Cloud Monitoring roles,\n see [Control access with Identity and Access Management](/monitoring/access-control).\n2. Ensure that you're familiar with the general concepts of alerting policies\n and PromQL in Cloud Monitoring.\n For more information, see the following topics:\n\n - [Alerting overview](/monitoring/alerts)\n - [PromQL in Cloud Monitoring](/monitoring/promql)\n3. Configure the notification channels that you want to use to receive any\n alerts. For redundancy purposes, we recommend that you create multiple\n types of notification channels. For more information, see\n [Create and manage notification channels](/monitoring/support/notification-options).\n\n4. If the PromQL query in your alerting policy references any\n metrics, then the metrics must already exist in Monitoring\n when you create the alerting policy.\n\nCreate PromQL alerting policies\n-------------------------------\n\nTo create a PromQL-based alerting policy from\nthe Google Cloud console, do the following:\n\n1. In the Google Cloud console, go to the\n *notifications* **Alerting** page:\n\n [Go to **Alerting**](https://console.cloud.google.com/monitoring/alerting)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Monitoring**.\n2. On the **Alerting** page, click **Create Policy**.\n\n3. Under **Policy configuration mode** , select\n **Code editor (MQL or PromQL)**.\n\n4. Verify that **PromQL** is selected\n in the **Language** toggle. The language toggle is in the same toolbar that\n lets you format your query.\n\n5. Enter the PromQL query that selects the data you want to monitor.\n If **Auto-run** isn't enabled, then click **Run Query**.\n\n For example, the following query summarizes the rate of\n billing logging data ingested over a 60-second interval\n and determines whether the summarized rate is over 300 bytes: \n\n ```\n sum(rate(logging_googleapis_com:billing_bytes_ingested{monitored_resource=\"global\"}[60s]))\u003e300\n ```\n\n After you run your query, you see a chart. For one\n project, this query produced the following result:\n\n6. Click **Next**, and then do the following:\n\n 1. Select a **Retest window**. This field defines for how long the\n condition must be satisfied before the alerting policy is triggered.\n\n The default value is **0 sec** . With this setting, a single\n measurement can result in a notification. For more information and\n an example, see\n [Alignment period and duration settings](/monitoring/alerts/concepts-indepth#duration).\n 2. To select how often alerting evaluates the PromQL query, choose\n a value for the **Evaluation interval**.\n\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 3. Enter a name for the condition and click **Next**.\n\n7. Click **Next**, and then do the following:\n\n 1. Add [notification channels](/monitoring/support/notification-options).\n\n 2. Choose a severity level for incidents.\n\n 3. Optional: Add [alerting policy labels](/monitoring/alerts/labels) and\n [documentation](/monitoring/alerts/doc-variables).\n\n 4. Enter a name for the alerting policy.\n\n8. Click **Create policy**.\n\nFor complete steps, see [Managing alerting policies](/monitoring/alerts/using-alerting-ui)."]]