Official agent skill

Cloud Monitoring PromQL Generator

by google in google/skills

Generates valid PromQL queries for Cloud Monitoring metrics from metric descriptors and resource parameters, with a validator script and error-recovery notes.

OfficialApache-2.0Auto-check passedDevOps & Cloud

Install Cloud Monitoring PromQL Generator

skills CLI
$ npx skills add google/skills --skill cloud-monitoring-promql-query -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install google/skills cloud-monitoring-promql-query --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/google/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/cloud/cloud-monitoring-promql-query .claude/skills/cloud-monitoring-promql-query && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cloud-monitoring-promql-query
GitHub stars
21k
Token cost
~2.6k tokens
SKILL.md length
1,058 words
Files
5 (incl. scripts, references)
Skills in repo
150
Repo updated
First seen
Licence
Apache-2.0

At a glance

Generates valid PromQL queries for Cloud Monitoring metrics from metric descriptors and resource parameters, with a validator script and error-recovery notes.

  • Works in 3 steps: Check Prompt/Payload: Look for the… → Check Environment: If the Project ID is… → Ask for Clarification (BLOCKING): If the…
  • Writing a PromQL query for a Cloud Monitoring metric type
  • SKILL.md covers Workflow and References
  • Runs Python scripts from its folder; calls python3, pip and gcloud

What it does

Before anything else, the agent must know the Google Cloud project ID. It looks in your prompt, then tries `gcloud config get-value project`, and if both fail it stops and asks you rather than writing a query with a made-up value. Next it needs the metric's descriptor fields, such as `metric.type`, `metricKind`, `valueType` and the monitored resource types.

Descriptors you supply are used directly. For a vague request like VM CPU usage, the agent turns to the `cloud-monitoring-metric-selection` skill. For a known metric type it calls the `google-cloud-monitoring:list_metric_descriptors` MCP tool, falling back to a direct Cloud Monitoring API call. The skill ships `scripts/validate_promql.py` with a test file, plus references on basic aggregations and error recovery. It is not meant for raw metric discovery.

When your agent uses it

  • Writing a PromQL query for a Cloud Monitoring metric type
  • Building a PromQL aggregation that filters on Cloud Monitoring resource parameters
  • Recovering from a PromQL error returned for a Cloud Monitoring query

Example prompts

  • “Write a PromQL query for compute.googleapis.com/instance/cpu/utilization in project my-prod-project.”
  • “Generate a PromQL aggregation of average CPU utilization per instance for the last hour.”
  • “This PromQL against Cloud Monitoring returns an error, so fix it and validate it.”

Requirements

  • A Google Cloud project ID, given in the prompt or set in `gcloud`
  • Python 3 for `scripts/validate_promql.py`
  • The Cloud Monitoring MCP server or API access to fetch descriptors

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Check Prompt/Payload: Look for the Project ID in the user's prompt or
  2. Check Environment: If the Project ID is not present in the prompt, you
  3. Ask for Clarification (BLOCKING): If the Project ID is not in the prompt

What it can do on your machine

Read from SKILL.md and the folder at commit 4b940dd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python3
    • pip
    • gcloud

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.cloud.google.com
    • monitoring.googleapis.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cloud Monitoring PromQL Generator loads about 2.6k tokens when it runs, and up to ~7.2k if it reads all its reference files. Until then it costs about 84 tokens; SKILL.md has 1,058 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~84
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from google/skills at commit 4b940dd, republished under its Apache-2.0 licence (© google). 1,058 words, ~2,586 tokens.

Download SKILL.mdSave it as .claude/skills/cloud-monitoring-promql-query/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
cloud-monitoring-promql-query
description
Generates valid PromQL queries from Cloud Monitoring metric descriptors and resource parameters. Use when asked to create, generate, write, or format PromQL queries, PromQL strings, or PromQL aggregations for Cloud Monitoring metrics and resources. Don't use for raw metric discovery or metric selection.
metadata.version
1.0.0
metadata.category
CloudObservabilityAndMonitoring

Cloud Monitoring PromQL Generator

Use this skill to generate a valid PromQL query from any Cloud Monitoring metric type. This guide applies to all Cloud Monitoring metric types by mapping Cloud Monitoring metric and resource descriptors to PromQL structures.

Workflow

Resolve Project ID (CRITICAL & BLOCKING)

Before performing any other actions (such as searching code, reading references, or running validation), you MUST verify whether the Google Cloud Project ID is available:

  1. Check Prompt/Payload: Look for the Project ID in the user's prompt or input.
  2. Check Environment: If the Project ID is not present in the prompt, you MUST run gcloud config get-value project to attempt to resolve it from the environment.
  3. Ask for Clarification (BLOCKING): If the Project ID is not in the prompt AND the gcloud command fails, returns an empty string, or is unavailable, you MUST immediately stop. Do NOT generate a PromQL query, do not run the validation script, and do not use placeholders (like YOUR_PROJECT_ID). You must refuse to proceed and ask the user to provide the Project ID.
Inspect Metric and Resource Descriptors
  1. Use Provided Descriptors First: If the user's prompt already includes metric descriptor details (such as metric.type, metricKind, valueType, or monitoredResourceTypes) or specific resource filter values, use those values directly instead of calling the Cloud Monitoring API.
  2. Discover Missing Descriptors: If exact metric descriptors (metric.type, metricKind, valueType) are missing or underspecified, resolve the target metric type's descriptor using one of these paths:
    • Vague Query: If the prompt is vague (for example, "VM CPU usage"), use the cloud-monitoring-metric-selection skill first to identify the specific metric type.
    • Known Metric Type: If you already have the specific metric type name (for example, compute.googleapis.com/instance/cpu/utilization) but need its descriptor, call the google-cloud-monitoring:list_metric_descriptors MCP tool. If the tool is missing, refer to the cloud-monitoring-metric-selection skill to configure the Cloud Monitoring MCP server.
    • Fallback: If the MCP tool cannot be configured, fall back to making a direct Cloud Monitoring API call.
  3. Identify Key Fields: From the retrieved descriptor, identify four key schema attributes:
    • type: The Cloud Monitoring metric type string.
    • metricKind: GAUGE, DELTA, or CUMULATIVE.
    • valueType: INT64, DOUBLE, DISTRIBUTION, or BOOL.
    • monitoredResourceTypes: Compatible resource.type strings required for resource scoping and grouping.
Resolve Resource Filters & Discovery Protocol

To filter data by a specific resource instance, apply these resource rules and discovery protocols:

  1. Monitored Resource Filter: Always include the monitored_resource="<type>" filter in your query to prevent collisions across services that share metric names.

    • Example: monitored_resource="gae_app"
  2. Preserve User Literals (CRITICAL): ALWAYS use the literal resource names, namespaces, and IDs provided in the user's prompt. Do NOT override or replace these values with active resource names found during Cloud Monitoring discovery unless the user explicitly asked you to find active resources. Telemetry discovery must only be used to identify metric type names and label keys, not to override user input.

  3. Resource Identifier Mapping:

    • Direct & Specific Keys: Use the most specific resource identifier available. Example: version_id, cluster_name.
    • Name-to-ID Resolution: If the user filters by a resource name (such as "instance-1"), but the resource schema uses numeric IDs (like instance_id), use PromQL string name labels instead of numeric ID labels. Example: instance_name, metadata_system_name.
    • Composite Identifiers: For resources with hierarchical identifiers (such as Cloud SQL databases), format the filter as a single composite key. Do NOT split them into separate project_id and sub-resource labels. Example: database_id="{project_id}:{instance_name}".
  4. Resource Label Discovery: The google-cloud-monitoring:list_metric_descriptors tool only returns metric-specific labels. If the label schema for a monitored resource is unknown, fetch the resource descriptor directly from the Cloud Monitoring v3 REST API (projects.monitoredResourceDescriptors.get):

    bash
    TOKEN=$(gcloud auth application-default print-access-token 2>/dev/null || gcloud auth print-access-token)
    curl -s -H "Authorization: Bearer ${TOKEN}" \
    "https://monitoring.googleapis.com/v3/projects/{project_id}/monitoredResourceDescriptors/{monitored_resource_type}"

    An HTTP 200 OK response returns the MonitoredResourceDescriptor object containing the labels array with the exact resource label keys for that resource.

Show full SKILL.md (429 more words)Show less
Choose Aggregation Structure & Defaults

The query structure and aggregation functions (such as rate, histogram_quantile, sum, or avg) depend on the metric type and how it is visualized.

  1. Consult the Reference: Consult the Cloud Monitoring to PromQL Basic Aggregations Reference as the single source of truth to map Cloud Monitoring properties (Metric Kind, Value Type, Aligner, Reducer) to their PromQL structures.
  2. SRE Aggregation & Visualization Rules:
    • Do NOT sum or average ratio/percentage utilization metrics (like CPU % or Memory limit utilization) across resource instances. Instead, keep them unaggregated (raw metric), group by instance, or wrap in topk(30, avg_over_time(...)).
    • State Label Filtering (CRITICAL): Only the metrics agent.googleapis.com/memory/percent_used and agent.googleapis.com/disk/percent_used require {state!="free"}. Do NOT filter by {state="used"}.
Format & Validate Query

Before presenting any PromQL queries, validate them using the linter:

Python Dependencies

Before executing the validation script (scripts/validate_promql.py), install the required Python dependencies:

bash
python3 -c "import promql_parser" || pip install promql-parser
Validation Procedure
  1. Format Constraints:
    • Metric Name Normalization: Convert Cloud Monitoring metric types to PromQL metric names using this recipe:
      1. Split Domain and Path: Split the Cloud Monitoring metric type by the first slash (/) to separate the domain from the path.
        • Example: storage.googleapis.com/network/received_bytes_count -> domain storage.googleapis.com, path network/received_bytes_count
      2. Normalize Domain: Replace all periods (.) in the domain with underscores (_).
        • Example: storage.googleapis.com -> storage_googleapis_com
      3. Normalize Path: Replace all periods (.) and slashes (/) in the path with underscores (_).
        • Example: network/received_bytes_count -> network_received_bytes_count
      4. Join with Colon: Join the normalized domain and normalized path with a colon (:).
        • Example: storage_googleapis_com:network_received_bytes_count
      5. Native Prometheus Metrics: If the metric type has no slash, keep it as-is.
        • Example: up -> up, http_requests_total -> http_requests_total
      6. Distribution Suffix: If the metric's valueType is DISTRIBUTION, append _bucket to the end of the normalized name.
        • Example: cloudfunctions.googleapis.com/function/execution_times -> cloudfunctions_googleapis_com:function_execution_times_bucket
    • Ensure the final query is a single line with no comments (no # or //). Cloud Monitoring query translation collapses whitespace and can cause code trailing a comment to be ignored or throw parsing errors.
    • Grouping Clause Syntax: Ensure grouping clauses (such as by (label)) only follow aggregation operators (such as sum, avg, min, max, or count). Never place a grouping clause directly after a metric selector.
      • Incorrect: metric{...} by (label)
      • Correct: sum(rate(metric{...}[5m])) by (label)
    • Fenced Output Code Block: ALWAYS wrap the final verified PromQL query in a fenced promql code block in your final response.
  2. Linter Verification:
    • Validate all generated queries in a single batch: python3 <path_to_skill>/scripts/validate_promql.py --query '<q1>' '<q2>'
    • If validation fails, read PromQL Error Recovery Guide to diagnose and fix common type mismatches and syntax errors before repeating the loop.

References

© google, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/cloud/cloud-monitoring-promql-query of google/skills.

  • SKILL.md
  • references/basic_aggregations.md
  • references/promql_error_recovery.md
  • scripts/validate_promql.py
  • scripts/validate_promql_test.py

Open the folder on GitHubat commit 4b940dd

Compare with similar skills

Cloud Monitoring PromQL Generator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cloud Monitoring PromQL Generator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cloud Monitoring PromQL Generator this skillgoogle/skills21k—~2.6kAutomated safety check: PassApache-2.0
Happy Infra Metrics and Grafanaslopus/happy24k—~2kAutomated safety check: NotesMIT
WizTelemetry Platform Servicekubesphere/kubesphere17k—~1.8kAutomated safety check: PassCustom licence
Redis Observabilityredis/agent-skills1662 repos~911Automated safety check: PassMIT
Developing Funboost Mixinydf0509/funboost895—~2.1kAutomated safety check: PassNone
Prometheus System Health Checkprometheus/prometheus-mcp121—~584Automated safety check: PassApache-2.0

Similar skills

  • Queries live Prometheus metrics and manages Grafana dashboards as code for Happy's infrastructure, using the grafanactl CLI and the Grafana datasource proxy API.

    24k GitHub stars~2k tokensUpdated today
    DevOps & CloudAuto-check: notes
  • WizTelemetry Platform Service

    kubesphere/kubesphere

    Installs and configures the WizTelemetry Platform Service extension for KubeSphere, the shared API server behind its observability extensions.

    17k GitHub stars~1.8k tokensUpdated 2 mo ago
    DevOps & CloudAuto-check passed
  • Redis Observability

    redis/agent-skills

    Official

    Redis observability guidance — which metrics to monitor (memory, connections, hit ratio, ops/sec, rejected connections), which built-in commands to reach for during incident triage (SLOWLOG, INFO…

    166 GitHub starsUsed in 2 repos~911 tokens
    DevOps & CloudAuto-check passed
  • 当需要为 funboost 创建 Consumer 或 Publisher 的 Mixin 扩展类时使用。触发场景:添加监控、熔断、限流、链路追踪等横切关注点,编写自定义前置/后置处理钩子。关键词:mixin, consumeroverridecls, publisheroverridecls, ConsumerMixin, 自定义消费者, hook, 拦截器, 熔断器, 监控…

    895 GitHub stars~2.1k tokensUpdated 2 mo ago
    DevOps & CloudAuto-check passed
  • Prometheus System Health Check

    prometheus/prometheus-mcp

    Builds a picture of whether Prometheus itself is healthy and successfully monitoring its targets, covering readiness, firing alerts, target health and TSDB load.

    121 GitHub stars~584 tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • Archestra Dev Observability

    archestra-ai/archestra

    A skill your agent uses when changing Archestra tracing, metrics, OpenTelemetry, Tempo, Grafana, Prometheus, LLM/MCP spans, observability labels, or local observability setup.

    4.4k GitHub stars~1.2k tokensUpdated today
    DevOps & CloudAuto-check passed

More from google/skills

All 150 skills in this repo
  • Official

    Query Cloud Trace spans, filter by latency thresholds or error status, correlate distributed traces with Cloud Logging, and diagnose latency bottlenecks across Google Cloud services.

    21k GitHub stars~1.7k tokensUpdated yesterday
    Auto-check passed
  • Official

    Manages Google Cloud Privileged Access Manager entitlements and grants: create and edit entitlements, request temporary access, and approve or deny pending grants.

    21k GitHub stars~3.2k tokensUpdated yesterday
    Auto-check passed
  • Official

    Writes Terraform alerting policies for AI agents that emit OpenTelemetry metrics, covering reliability, cost, safety, security and quality signals on Google Cloud.

    21k GitHub stars~4.2k tokensUpdated yesterday
    Auto-check passed
  • Official

    Deploys open models or custom weights from Model Garden to Agent Platform endpoints, checks deployment status and cleans up endpoints, confirming before any change.

    21k GitHub stars~5k tokensUpdated yesterday
    Auto-check passed
  • Official

    Searches, manages and scaffolds skills in the Gemini Enterprise Agent Platform Skill Registry using bundled Python scripts and Google Cloud credentials.

    21k GitHub stars~584 tokensUpdated yesterday
    Auto-check passed
  • Designs GCP infrastructure as local Terraform, validates and scans it against best practices, then imports it to Application Design Center for deployment and troubleshooting.

    21k GitHub stars~4.4k tokensUpdated yesterday
    Auto-check passed

Categories

Questions about Cloud Monitoring PromQL Generator

What does Cloud Monitoring PromQL Generator do?

Generates valid PromQL queries for Cloud Monitoring metrics from metric descriptors and resource parameters, with a validator script and error-recovery notes. Before anything else, the agent must know the Google Cloud project ID. It looks in your prompt, then tries `gcloud config get-value project`, and if both fail it stops and asks you rather than writing a query with a made-up value.

When should I use Cloud Monitoring PromQL Generator?

Cloud Monitoring PromQL Generator fits situations like: writing a PromQL query for a Cloud Monitoring metric type; building a PromQL aggregation that filters on Cloud Monitoring resource parameters; recovering from a PromQL error returned for a Cloud Monitoring query.

How do I install Cloud Monitoring PromQL Generator in Claude Code?

Run `npx skills add google/skills --skill cloud-monitoring-promql-query -a claude-code`. Or copy the skill folder (skills/cloud/cloud-monitoring-promql-query in google/skills) into .claude/skills/cloud-monitoring-promql-query in your project. Claude Code loads it when a task matches its description.

How do I install Cloud Monitoring PromQL Generator in Codex?

Run `npx skills add google/skills --skill cloud-monitoring-promql-query -a codex`. Or copy the skill folder (skills/cloud/cloud-monitoring-promql-query in google/skills) into .agents/skills/cloud-monitoring-promql-query in your project. Codex loads it when a task matches its description.

Can I use Cloud Monitoring PromQL Generator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add google/skills --skill cloud-monitoring-promql-query -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cloud-monitoring-promql-query, .gemini/skills/cloud-monitoring-promql-query, .github/skills/cloud-monitoring-promql-query and .opencode/skills/cloud-monitoring-promql-query in your project.

What does Cloud Monitoring PromQL Generator need to run?

Going by SKILL.md and its folder, Cloud Monitoring PromQL Generator needs Python for the scripts in its folder and the command-line tools its instructions call (python3, pip and gcloud). Our summary lists: A Google Cloud project ID, given in the prompt or set in `gcloud`; Python 3 for `scripts/validate_promql.py`; The Cloud Monitoring MCP server or API access to fetch descriptors.

Does Cloud Monitoring PromQL Generator access the network?

SKILL.md names 2 domains. As links in the text: docs.cloud.google.com and monitoring.googleapis.com. This is read from the text; nothing was executed.

Is Cloud Monitoring PromQL Generator safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Cloud Monitoring PromQL Generator use?

Cloud Monitoring PromQL Generator is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cloud Monitoring PromQL Generator use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.6k tokens, read only when the agent opens those files.

What are the alternatives to Cloud Monitoring PromQL Generator?

Skills that share tags, products or a category with Cloud Monitoring PromQL Generator: Happy Infra Metrics and Grafana (slopus/happy, 24k stars), WizTelemetry Platform Service (kubesphere/kubesphere, 17k stars), Redis Observability (redis/agent-skills, 166 stars) and Developing Funboost Mixin (ydf0509/funboost, 895 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cloud Monitoring PromQL Generator?

google (a GitHub organization, an official publisher) maintains it in google/skills, which has 21,097 GitHub stars. The repository holds 150 skills in this directory. The repository was last updated on October 9, 2026.

Source: google/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.