PromQL in Cloud Monitoring

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:

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.

You can also import your Grafana dashboards into Cloud Monitoring.

Naming conventions

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.

Learning PromQL

To learn the basics of using PromQL, we recommend consulting open source documentation. The following resources can help you get started:

PromQL differences

PromQL for Cloud Monitoring might function slightly differently than upstream PromQL. For a list of these differences, see PromQL differences.