This document describes using Prometheus Query Language (PromQL) in Cloud Monitoring. PromQL provides an alternative to the Metrics Explorer menu-driven and Monitoring Query Language (MQL) interfaces for creating charts and dashboards.
You can use PromQL to query and chart Cloud Monitoring data from the following sources:
- Google Cloud services, like Google Kubernetes Engine or Compute Engine, that write metrics described in the lists of Cloud Monitoring system metrics.
- User-defined metrics, like log-based metrics and Cloud Monitoring user-defined metrics.
- Google Cloud Managed Service for Prometheus, the fully managed multi-cloud solution for Prometheus from Google Cloud. For information about the managed service, including support from PromQL, see Google Cloud Managed Service for Prometheus.
You can also use tools like Grafana to chart metric data ingested into Cloud Monitoring. Available metrics include metrics from Managed Service for Prometheus and Cloud Monitoring metrics documented in the lists of metrics. For information about setting up Grafana and other tools based on the Prometheus API, see the Managed Service for Prometheus documentation about Grafana.
The Prometheus metric model and naming conventions differ from those used by Cloud Monitoring. To use PromQL to query Monitoring metric data, you must convert Cloud Monitoring names into PromQL-compatible equivalents. For information about the naming conventions, see Mapping Cloud Monitoring metrics to PromQL.
Accessing PromQL in Cloud Monitoring
You can use PromQL from the Code tab on the following pages in the Google Cloud console:
- Metrics Explorer
- Add Chart when creating custom dashboards
For information about accessing and using the editor, see Using the PromQL editor.
Prometheus rules and alerts
You can use PromQL to create recording and alerting rules on any metric in Cloud Monitoring by using Prometheus-style alerting in Managed Service for Prometheus. For more information, see Managed rule evaluation and alerting or Self-deployed rule evaluation and alerting.
To learn the basics of using PromQL, we recommend consulting open source documentation. The following resources can help you get started:
PromQL for Cloud Monitoring might function slightly differently than upstream PromQL. For a list of these differences, see PromQL differences.