3

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)?

  • I have looked through Google Documentation and not found anything like that which you have described. This may still be something that Google is working on currently. – Derek Fender Jul 14 '20 at 17:00
  • There is a Feature Request for MQL-based alerts in https://issuetracker.google.com/157770220 – c69 Jul 14 '20 at 23:43

3 Answers3

3

Quoting c69:

There is a Feature Request for MQL-based alerts in issuetracker.google.com/157770220

As at the date of this post, MQL-based alerts are not supported.

3

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".

c69
  • 19,951
  • 7
  • 52
  • 82
0

I'm not sure if this is helpful, but you could create a custom service and then define an SLO for it using the ratio of two metrics. You could then create an error budget burn alert.

"requestBased": {
    "goodTotalRatio": {
      "totalServiceFilter": "metric.type=\"appengine.googleapis.com/http/server/response_count\" resource.type=\"gae_app\" resource.label.\"module_id\"=\"default\"",
      "goodServiceFilter": "metric.type=\"appengine.googleapis.com/http/server/response_count\" resource.type=\"gae_app\" resource.label.\"module_id\"=\"default\" metric.label.\"response_code\"=\"200\"",
    }
  }

https://medium.com/google-cloud/slos-with-stackdriver-service-monitoring-62f193147b3f

Yuri Grinshteyn
  • 727
  • 3
  • 13