Search code examples
google-cloud-platformdevopsstackdrivergoogle-cloud-monitoringmonitoring-query-language

Using MQL with Google Cloud Monitoring (Stackdriver) Alerting Policy


I have used MQL to create charts in Google Cloud Monitoring that are a ratio of two metrics.

I would like to create an alerting policy based on the MQL, but the UI in Cloud Console does not have a query editor, like it does in Metrics Explorer.

Is there a way to use MQL when defining conditions for alerting policies using Google Cloud Monitoring (Stackdriver)?


Solution

  • Creating alerts with MQL is now supported :) Both in UI and API.


    1. To create a valid alert - pipe either condition or absent_for keyword* at the end of your query. See https://cloud.google.com/monitoring/mql/alerts for documentation.

    2. For ratio alerts, follow the tips from regular ratio queries https://cloud.google.com/monitoring/mql/examples#qlx-ratio-ratio

    3. There are two major difference compared to dashboards - all MQL alerts must be saved in strict-form, and most of the conditions will need to have units-of-measure specified. See https://cloud.google.com/monitoring/mql/qn-from-api#ql-alert-condition


    ) * - they are technically "table operators", not "keywords".