Monitoring Query Language overview

Announcement: Starting on October 22, 2024, Monitoring Query Language (MQL) will no longer be a recommended querylanguage for Cloud Monitoring. Certain usability features will bedisabled, but you can still run MQL queries in Metrics Explorer,and dashboards and alerting policies that use MQL will continue towork. For more information, see thedeprecation notice forMQL.

Monitoring Query Language (MQL) provides an expressive, text-based interface toCloud Monitoring time-series data. By using MQL, you canretrieve, filter, and manipulate time-series data.

Why use MQL?

With MQL, you can manipulate time series to createcharts that you can't create any other way. For example, you can do thefollowing:

  • Compute the ratio of requests resulting in a particular class ofresponse codes
  • Compute the ratio of current values to past values
  • Select by arbitrary, rather than predefined, percentile values
  • Select a random sample of time series
  • Evaluate arbitrary arithmetic expressions over values fromtime series of multiple metric types.
  • Create new labels to aggregate data by, using arbitrary string manipulationsincluding regular expression sub-field capture.
  • Control the time range and period of output data.

MQL uses a set of operations and functions. Operations arelinked together using the common pipe mechanism, where the outputof one operation becomes the input to the next. Linking operationsmakes it possible to build up complex queries incrementally.

Additionally, the code editor provides syntactic help in the formof error messages. For more information, seeUse the code editor for MQL.

What's next?

You can create and submit MQL queries by using the code editoror the Monitoring API.

You can also create alerting policies with MQL by using theMonitoring API. For more information,seeCreating conditions for alerting policies.

For a series of examples of MQL queries, seeExamples.

For some general information about MQL,seeAbout the MQL language.

For a comprehensive reference, seeThe Monitoring Query Language reference.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.