Skip to content

Guide · Agent skill

How to use the Cloud Monitoring PromQL Query Generator agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

This guide explains how to install and use the cloud-monitoring-promql-query agent skill, a set of instructions and scripts that lets an AI agent write PromQL queries for Google Cloud Monitoring metrics. It is aimed at site reliability engineers, developers and teams who need PromQL for Cloud Monitoring but do not know the metric schema well. By the end you will know how to install the skill, how to ask for a query, what the skill needs from you, and where to be careful before using a generated query.

Cloud Monitoring PromQL Query Generatorgoogle/skills · Apache-2.0

Quick start

  1. 1Download the ZIP. Download the cloud-monitoring-promql-query ZIP from this page.
  2. 2Unzip the skill. Unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder.
  3. 3Set up your Google Cloud access. Make sure you have a project ID and the gcloud CLI authenticated, or provide the project ID in your request.
  4. 4Install the validator dependency. Install Python 3 and the promql-parser package if the validator needs it.
  5. 5Ask for a query in plain language. Describe the metric type, project and resource filters you need.
  6. 6Review the generated query. Check the metric name, labels and aggregations, then test it outside production.

What an agent skill is and what this one does

An agent skill is a folder of instructions and supporting files that an AI agent reads when a task matches the skill's description. This one, cloud-monitoring-promql-query, is focused on turning a Cloud Monitoring metric and its resource details into a structured PromQL query.

Once installed, the agent chooses functions such as rate, sum or histogram_quantile based on the metric type. It follows rules from the skill, such as always filtering by monitored resource and not summing ratio metrics like CPU percentage across instances. A validator script then checks generated queries for the required syntax.

  • Works from metric descriptors and resource parameters you provide, or looks them up through the Cloud Monitoring API.
  • Requires a Google Cloud project ID before it generates anything.
  • Checks query structure only, not whether the query returns correct results.

Install the skill from the ZIP download

Download the ZIP for this skill from this page and unzip it. The skill folder should contain SKILL.md, a references folder and a scripts folder.

For a personal install, unzip it into ~/.claude/skills/. For a single project, unzip it into the project's .claude/skills/ folder so it applies only there.

You can also upload the skill in the Claude apps under Settings → Capabilities → Skills.

  • Personal install: ~/.claude/skills/
  • Project install: .claude/skills/ inside your project
  • Claude apps: Settings → Capabilities → Skills, then upload

Set up the requirements

The skill needs a Google Cloud project ID. You can give it in your request, or set a default with gcloud so the agent can read it with gcloud config get-value project.

For descriptor lookups and Cloud Monitoring API calls, the gcloud CLI must be installed and authenticated. The validator script needs Python 3 and the promql-parser package. The skill's instructions show the check it uses: install the package only if it is missing.

The Cloud Monitoring MCP server (google-cloud-monitoring) is optional. If it is not available, the skill falls back to direct Cloud Monitoring API calls.

  • Google Cloud project ID, from your request or gcloud config
  • gcloud CLI with authentication
  • Python 3 with the promql-parser package for the validator
  • Cloud Monitoring MCP server (optional, with direct API fallback)
python3 -c "import promql_parser" || pip install promql-parser

Trigger the skill with natural requests

You do not need a special command. Ask for a PromQL query in plain language and include the details you have. The skill's description covers requests to create, generate, write or format PromQL queries, PromQL strings or PromQL aggregations for Cloud Monitoring metrics and resources.

Give the metric type and project if you know them. If you only know a rough description such as VM CPU usage, the skill first uses the cloud-monitoring-metric-selection skill to identify the metric. The skill does not choose metrics on its own.

  • "Write a PromQL query for compute.googleapis.com/instance/cpu/utilization in project my-project, grouped by instance."
  • "Generate a PromQL aggregation for this latency distribution metric in project my-project."
  • "Format a PromQL string filtering gae_app by version_id in project my-project."

Example workflow and what to check

When a request is clear, the agent resolves the project ID, reads the metric descriptor, applies the resource filter and aggregation rules, then runs the validator on the query before showing it to you. If the project ID is missing and gcloud cannot supply one, the agent stops and asks you for it rather than using a placeholder.

Treat the output as a draft. Read the query, check the metric name and resource labels against your own setup, and test it in a non-production environment before it goes into a dashboard or alert.

  • Confirm the project ID and metric type in the answer.
  • Check that monitored_resource is set to the resource type you expect.
  • Review aggregations, especially on ratio metrics such as CPU or memory percentages.

Safety notes: scripts and network access

This skill runs scripts and uses the network. The validator at scripts/validate_promql.py checks query syntax. Its test file is scripts/validate_promql_test.py. The skill also calls gcloud, the Cloud Monitoring API, and optionally an MCP server.

The skill's attribution rules require gcloud commands run in the terminal to be prefixed with an environment variable that tags usage with the skill name and version. Read references/attribution.md if you want the exact rules. The skill also says these tags must not appear in generated scripts, Terraform or user code.

Review the skill files before installing, and run any command in a sandbox or non-production project if you are unsure.

  • Scripts: validate_promql.py and validate_promql_test.py
  • Network: calls to the Cloud Monitoring API and optional MCP server
  • Attribution: gcloud commands in the terminal are tagged, not configured persistently

Tips for better results

Give exact values. The skill uses the literal resource names, namespaces and IDs you provide and does not replace them with resources it discovers, unless you ask it to find active resources.

If a generated query fails validation, the skill's error recovery reference covers common problems such as range versus instant vector mismatches, misplaced by or without clauses, and histogram_quantile bucket label mismatches. Ask the agent to apply that guidance and validate again.

  • Include the project ID, metric type and any resource filter values in one request.
  • For ratio metrics, ask for per-instance results rather than a total.
  • For Cloud SQL databases, give the instance and project so the composite database_id can be formed correctly.

What people use it for

  • Writing a per-instance CPU utilization query for Compute Engine dashboards.
  • Building a histogram_quantile latency query from a distribution metric for an alert.
  • Creating a PromQL aggregation filtered by a Google Cloud monitored resource such as gae_app.
  • Producing consistent query conventions across several Cloud Monitoring metrics in a team.

Frequently asked questions

How do I install the cloud-monitoring-promql-query skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder. You can also upload it in the Claude apps under Settings → Capabilities → Skills.

What does the cloud-monitoring-promql-query skill require?

It requires a Google Cloud project ID, the gcloud CLI with authentication for descriptor lookups and API calls, and Python 3 with the promql-parser package for the validator. The Cloud Monitoring MCP server is optional, with a direct API fallback.

Is the cloud-monitoring-promql-query skill free?

The skill is published under the Apache-2.0 licence. Check the licence file in the source repository for the full terms. Google Cloud and the tools it calls may have their own costs.

Can it choose which metric I should use?

No. The skill defers metric discovery and selection to the separate cloud-monitoring-metric-selection skill. It can use that skill when your request is vague.

Does it work with Prometheus outside Google Cloud?

No. The skill is specific to Cloud Monitoring naming and labels, so it is not intended for non-Google Cloud Prometheus setups.

Why does the agent ask for my project ID and refuse to continue?

The skill treats the project ID as blocking. If it is not in your request and gcloud config get-value project returns nothing or fails, the agent stops rather than using a placeholder like YOUR_PROJECT_ID.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

This skill suits SREs and developers who need correct PromQL for Google Cloud Monitoring metrics and want consistent conventions across them. It is not the right tool for finding metrics, for non-Google Cloud Prometheus, or for running generated queries against production without review, since the validator checks structure only.

Download the skill