To set up an alert policy in GCP Monitoring using MQL Query, follow the steps below:
- Navigate to the Monitoring console in your GCP project.
- Click on "Alerting" in the left-hand menu and then click on "Create Policy".
- In the "Conditions" tab, select the resource type for which you want to create the alert policy.
- In the "Add Condition" section, select "Metric Query" as the condition type.
- In the "Metric" section, click on "Select Metric" and choose the metric you want to use for the alert.
- In the "Filter" section, enter your MQL Query in the "Query" field. This query should evaluate to a boolean value of true or false.
- On the right-hand side of the "Filter" section, you can set the threshold and duration for the alert condition.
- In the "Notifications" tab, select the notification channels that you want to use to receive alerts when the condition is met.
- Once you have configured the alert policy, click on "Save" to create the policy.
Note that you can also preview the results of your MQL Query by clicking on the "Preview" button in the "Filter" section. This will show you the metric values that match your query, which can be helpful in fine-tuning your alert policy.