Cloud Monitoring Promql Query logo

Cloud Monitoring Promql Query

OrganizationPopular
google
cloud-monitoring-promql-query

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.

Overview

Publishergoogle
Repositoryskills
Skill namecloud-monitoring-promql-query
Stars
20.1K
Forks
1.6K
Bundled files
4
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by google on GitHub. Read the source before you install it.

Installation

Install the Cloud Monitoring Promql Query AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/google/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/cloud/cloud-monitoring-promql-query .claude/skills/cloud-monitoring-promql-query
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cloud Monitoring Promql Query in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Cloud Monitoring Promql Query on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Cloud Monitoring Promql Query is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Cloud Monitoring Promql Query AI skill do?

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.

Why use Cloud Monitoring Promql Query on TypingMind?

Because you install it once and use it with any model. Cloud Monitoring Promql Query is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Cloud Monitoring Promql Query in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/google/skills/tree/main/skills/cloud/cloud-monitoring-promql-query. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Cloud Monitoring Promql Query?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Cloud Monitoring Promql Query?

As many as you like. As long as a model supports skills, you can use Cloud Monitoring Promql Query with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cloud Monitoring Promql Query AI skill free?

Yes. It is published on GitHub by google under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇