cloud-monitoring-promql-query

Generates and validates PromQL queries from Cloud Monitoring metric descriptors.

19.1k|1.5k|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/google/skills --skill cloud-monitoring-promql-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloud-monitoring-promql-query
Source: https://github.com/google/skills/tree/main/skills/cloud/cloud-monitoring-promql-query
Command: npx skills add https://github.com/google/skills --skill cloud-monitoring-promql-query

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires promql-parser, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Writing correct PromQL queries for Google Cloud Monitoring metrics requires translating metric descriptors (metricKind, valueType, monitored resource types) into valid PromQL syntax, which is error-prone and often produces queries that fail validation or return misleading aggregations.

Core Features & Use Cases

  • Descriptor-Driven Query Generation: Maps Cloud Monitoring metric types, metric kinds, and value types to correct PromQL structures including rate, histogram_quantile, and aggregation operators.
  • Built-In Validation Linter: Runs a Python-based PromQL validator that enforces Cloud Monitoring semantics such as monitored_resource filters, counter rate wrapping, and histogram bucket handling.
  • Error Recovery Guidance: Diagnoses common PromQL failures like range vector mismatches, invalid grouping clauses, and vector matching collisions with concrete fixes.
  • Use Case: When asked to chart p95 latency for a Cloud Function, the skill resolves the metric descriptor, appends the _bucket suffix, groups by the le label, and returns a validated single-line PromQL query.

Quick Start

Ask the agent to generate a PromQL query for CPU utilization of your GCE instances in your Google Cloud project.

Frequently Asked Questions about cloud-monitoring-promql-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a PromQL query for Google Cloud Monitoring metrics?

Convert the Cloud Monitoring metric type by replacing periods and slashes with underscores and joining domain and path with a colon, then apply aggregation based on the metric's kind and value type. Always include a monitored_resource filter and validate the query with a PromQL linter before use.

How to calculate p95 latency in PromQL for Cloud Monitoring distribution metrics?

Append _bucket to the normalized metric name, wrap it in rate over a time window, sum while grouping by the le label, and pass the result to histogram_quantile(0.95, ...). Omitting the le label or the _bucket suffix causes the query to fail or return empty results.

Why does my PromQL query fail with a range vector vs instant vector error?

This error occurs when rate(), irate(), or increase() is called without a duration window or wraps an aggregation like sum(). Place the aggregation outside the rate function, for example sum(rate(metric[5m])) instead of rate(sum(metric)[5m]).

Should I sum or average CPU utilization metrics across instances?

No, summing or averaging ratio and percentage utilization metrics produces mathematically invalid or misleading values. Keep them unaggregated, group by instance, or use topk with avg_over_time to surface outliers instead.

What dependencies are needed to validate PromQL queries locally?

The validation script requires Python 3 and the promql-parser package, installed via pip install promql-parser. The script checks syntax plus Cloud Monitoring semantics like monitored_resource filters and counter rate wrapping.