New to Claude Skills? Learn how to install them →

google on GitHub

Cloud Monitoring Chart Generation

Free

Automate Google Cloud Monitoring widget creation from PromQL queries.

by google17.6k stars on google/skills
2 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Cloud Monitoring Chart Generation does

The Cloud Monitoring Chart Generation skill streamlines the process of creating Google Cloud Monitoring widgets by transforming PromQL queries and metric metadata into valid google.monitoring.dashboard.v1.Widget Protocol Buffer textprotos. This skill is particularly useful for developers and DevOps engineers who need to generate dashboards programmatically using the Cloud Monitoring Dashboards API, gcloud CLI, or declarative dashboard definitions.

This skill operates through a structured three-stage pipeline. In the first stage, it computes candidate labels based on the provided metric display name, resource type, metric unit, and PromQL query. The second stage involves synthesizing a SemanticPlotSpec, which includes key parameters like the widget title, y-axis label, plot type, and unit override. The final stage assembles the widget textproto, ensuring that the output is valid and ready for use in your monitoring setup.

The skill is designed to be easy to use, with clear instructions for executing the bundled Python scripts. Users can expect automatic handling of output filenames and a validation step to ensure the generated textproto meets the required schema. This reduces the risk of errors and enhances the efficiency of dashboard creation.

Ideal for teams leveraging Google Cloud's monitoring capabilities, this skill helps automate repetitive tasks and ensures consistency across dashboard configurations. By integrating this skill into your workflow, you can focus on analyzing metrics rather than manually crafting widget definitions.

When to use it

Use this skill when you need to generate Google Cloud Monitoring widgets programmatically from PromQL queries and metric metadata.

When not to use it

This skill is not suitable for tasks like metric discovery or PromQL query generation; other skills should be used for those purposes.

What you can build with it

Automating Dashboard Creation

Use this skill to automate the generation of Google Cloud Monitoring dashboards based on predefined PromQL queries, enhancing efficiency.

Standardizing Widget Definitions

Leverage this skill to ensure consistent widget definitions across multiple dashboards by generating them programmatically.

Integrating with CI/CD Pipelines

Incorporate this skill into your CI/CD pipelines to dynamically create and update monitoring dashboards as part of your deployment process.

How to install Cloud Monitoring Chart Generation

View source

1. Install with the skills CLI

npx skills add google/skills/cloud-monitoring-chart-generation --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by google

Cloud Monitoring Chart Generation Skill (cloud-monitoring-chart-generation)

Transforms PromQL queries and metric metadata into valid Server-Driven UI (SDUI) google.monitoring.dashboard.v1.Widget Protocol Buffer textprotos. These generated textprotos are designed to be ingested by the Cloud Monitoring Dashboards API, gcloud CLI, or declarative dashboard provisioning pipelines.

[!CAUTION] CRITICAL EXECUTION & WORKING DIRECTORY RULES:

  • DO NOT CHANGE WORKING DIRECTORY: Keep your working directory at your workspace root. Do NOT cd into skill subdirectories.
  • NO DISCOVERY OR SEARCH RULE: The metric descriptor, PromQL query, unit, and resource type are ALWAYS present in the conversation context. NEVER run file or codebase search tools, such as grep, find, directory listings, or codebase queries, to discover metric metadata or inspect repository structures.
  • SCRIPT EXECUTION: Execute the bundled Python scripts directly using python3, for example: python3 scripts/assemble_widget_proto.py ....
  • OUTPUT GENERATION: The assemble_widget_proto script automatically generates deterministic sequential filenames like chart.textproto and chart_2.textproto and saves them to the active workspace. The script will handle naming and saving automatically, and will print the generated filename to the console.

Prerequisites: Environment Setup

Install the required dependencies in your environment or sandbox:

pip install -r scripts/requirements.txt

3-Stage Pipeline Workflow

[ Stage 1: compute_labels ]  --->  [ Stage 2: LLM Synthesis ]  --->  [ Stage 3: assemble_widget_proto ]
  Generates candidate labels         Formulates SemanticPlotSpec       Emits validated widget textproto

Stage 1: Baseline Candidate Synthesis

Run Stage 1 using python3:

python3 scripts/compute_labels.py \
  --metric_display_name "METRIC_DISPLAY_NAME" \
  --resource_type "RESOURCE_TYPE" \
  --metric_unit "UNIT" \
  --promql_query "PROMQL_QUERY"

Stage 2: SemanticPlotSpec Prediction (LLM)

Review the user prompt, PromQL query structure, and Stage 1 baseline candidates to formulate a 4-key SemanticPlotSpec JSON object:

  1. title: Polish titleCandidate to ensure it is concise, human-readable, and under 80 characters.
  2. yAxisLabel: Set this to a concise, human-readable quantitative descriptor or metric concept, such as "Utilization", "Bytes", or "Bytes Rate". Do NOT append unit symbols or suffixes such as "(%)", "(/s)", or "(By)" to the label, because units are rendered automatically via unitOverride.
  3. plotType: Default to LINE. Use STACKED_AREA if requested by the user or for distribution queries.
  4. unitOverride: Set this to the Unified Code for Units of Measure (UCUM) unit string, derived from the PromQL query by applying the Unit Override Computation Rules below.

Unit Override Computation Rules:

  • Rate Functions (rate(...), irate(...)): Convert cumulative counters into per-second rates. Append /s to the raw metric unit. For example, a raw metric unit of By with rate(...) results in unitOverride: "By/s".

  • Ratios & Percentages (100 * ... / ...): Ratios of identical metric units multiplied by 100 represent percentages, resulting in unitOverride: "%".

  • Normalizations: Normalize 10^2.% to "%", per the Unified Code for Units of Measure (UCUM) standard.

  • Preserved Units: For aggregation functions like avg_over_time(...) or sum by (...), retain and output the underlying metric unit without modification. For example, output "%", "By", or "s" unchanged.

  • Legend Template: Do NOT configure the legend_template field. It is intentionally omitted so that the Cloud Monitoring frontend dynamically renders its multi-column table legend at runtime.

Example SemanticPlotSpec:

{
  "title": "VM CPU Utilization (us-central1-a)",
  "yAxisLabel": "Utilization",
  "plotType": "LINE",
  "unitOverride": "%"
}

Stage 3: Protobuf Assembly & Output

Run Stage 3 using python3 to generate and save the widget textproto:

python3 scripts/assemble_widget_proto.py \
  --promql_query "PROMQL_QUERY" \
  --spec_json 'SEMANTIC_PLOT_SPEC_JSON'

[!IMPORTANT] MANDATORY FILE OUTPUT CONTRACT: The script automatically names and saves output files like chart.textproto and chart_2.textproto directly in your workspace root without subdirectories.

  • Assigned Filename Feedback: Whenever an output file is saved, the script logs the file path to stderr, for example: Wrote widget textproto to: .../chart.textproto. Read your command execution logs for the exact filename created so you can target it in Stage 4 validation.
  • Text Chat Output: Enclose the generated SDUI widget textproto inside a ```textproto code block in your response:
title: "..."
xy_chart {
  ...
}

Stage 4: Mandatory Self-Verification & Auto-Retry Loop

[!CAUTION] DO NOT FINISH YOUR TURN UNTIL FILE VERIFICATION PASSES:

  1. Run Validation Check: Execute the validator script against the generated file, such as chart.textproto or the sequential filename like chart_2.textproto output from Stage 3:
    python3 scripts/validate_chart.py --input_file "GENERATED_FILE.textproto"
    
  2. Auto-Retry if Missing or Failed: If validate_chart reports that the file is missing or invalid, verify your script parameters and immediately re-run Stage 3:
    python3 scripts/assemble_widget_proto.py \
      --promql_query "PROMQL_QUERY" \
      --spec_json 'SEMANTIC_PLOT_SPEC_JSON'
    
  3. Validation & Retries: Run validate_chart to verify the generated textproto. If validation fails due to a schema or syntax error, correct the parameters and retry up to 2 times. If validation still fails after 2 retries, stop retrying, notify the user of the validation error, and present the best-effort textproto.
  4. Execution vs. Validation Errors: Note that schema/syntax validation errors from validate_chart.py are distinct from OS or environment execution restrictions, such as Permission denied or Command not found, which are handled below in Graceful Sandbox Fallback.

Graceful Sandbox Fallback

If compute_labels.py, assemble_widget_proto.py, or validate_chart.py cannot be executed due to environment or sandbox restrictions, do the following:

  1. Notify the user which script cannot be executed and why.
  2. Synthesize and output the complete widget textproto directly in your response, following all formatting and unit rules.
  3. Provide a "Local Verification" section containing the standalone python3 commands so the user can run and validate the schema locally if desired.

Supporting Links

Frequently asked questions about Cloud Monitoring Chart Generation

Similar skills