Monitoring Query Language (MQL) provides an expressive, text-based interface to Cloud Monitoring time-series data. By using MQL, you can retrieve, filter, and manipulate time-series data.
Why use MQL?
With MQL, you can manipulate time series to create charts that you can't create any other way. For example, you can do the following:
- Compute the ratio of requests resulting in a particular class of response 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 from time series of multiple metric types.
- Create new labels to aggregate data by, using arbitrary string manipulations including regular expression sub-field capture.
- Control the time range and period of output data.
MQL uses a set of operations and functions. Operations are linked together using the common pipe mechanism, where the output of one operation becomes the input to the next. Linking operations makes it possible to build up complex queries incrementally.
Additionally, the Query Editor provides syntactic help in the form of completion suggestions and error messages. For more information, see Using the Query Editor.
The Quickstart for Monitoring Query Language guides you through creating a simple MQL query by using the Query Editor.
You can create and submit MQL queries by using the Query Editor or the Monitoring API.
- For information about the Query Editor, see Using the Query Editor.
- For information about using MQL queries with the Monitoring API, see Using the API.
You can also create alerting policies with MQL; for more information, see Alerting policies with MQL.
For a series of examples of MQL queries, see Examples.
For some general information about MQL, see About the MQL language.
For a comprehensive reference, see The Monitoring Query Language reference.