cloud-monitoring-promql-query
できること
Google Cloudの指標を読むPromQLクエリを書きます。標準のCloud Monitoringのフィルター形式より、PromQLを好む人向けです。
使う場面
- ✓Cloud Monitoringの指標をチャート化またはアラートにするためのPromQLのクエリがほしいとき。
- ✓Google Cloudのリソースについて、PromQLで集約を書く必要があるとき。
- ✓指標をPromQLの正しい構造に変換したいとき。
スキルのリンク
https://github.com/google/skills/blob/main/skills/cloud/cloud-monitoring-promql-query/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のCloud Runサービスの、1分ごとのエラー率を示すPromQLのクエリを書いてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはまずプロジェクトIDを確認し、指標とリソースの詳細を、Google Cloudが期待するPromQLの構造に対応づけます。そのまま使えるクエリを返します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-monitoring-promql-query)"
and append agent-skills/1.0 (skill:cloud-monitoring-promql-query) to User-Agent headers.
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:
- Check Prompt/Payload: Look for the Project ID in the user's prompt or input.
- Check Environment: If the Project ID is not present in the prompt, you
MUST run
gcloud config get-value projectto attempt to resolve it from the environment. - Ask for Clarification (BLOCKING): If the Project ID is not in the prompt
AND the
gcloudcommand 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 (likeYOUR_PROJECT_ID). You must refuse to proceed and ask the user to provide the Project ID.
Inspect Metric and Resource Descriptors
- Use Provided Descriptors First: If the user's prompt already includes
metric descriptor details (such as
metric.type,metricKind,valueType, ormonitoredResourceTypes) or specific resource filter values, use those values directly instead of calling the Cloud Monitoring API. - 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 thecloud-monitoring-metric-selectionskill 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 thegoogle-cloud-monitoring:list_metric_descriptorsMCP tool. If the tool is missing, refer to thecloud-monitoring-metric-selectionskill 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.
- Vague Query: If the prompt is vague (for example,
- Identify Key Fields: From the retrieved descriptor, identify four key
schema attributes:
type: The Cloud Monitoring metric type string.metricKind:GAUGE,DELTA, orCUMULATIVE.valueType:INT64,DOUBLE,DISTRIBUTION, orBOOL.monitoredResourceTypes: Compatibleresource.typestrings 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:
- 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"
- Example:
- 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.
- 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 (likeinstance_id), us
- Direct & Specific Keys: Use the most specific resource identifier
available. Example:
よくある質問
プロジェクトIDは必要ですか?
はい。プロジェクトIDを尋ね、依頼に含まれない場合は環境を確認します。
指標を見つけますか?
いいえ。指標の検索は、別の選択のスキルが扱います。
すべての指標の種類に対応していますか?
Cloud Monitoringのすべての指標とリソースの種類をPromQLに対応づけられるよう作られています。
詳細
作者による元の説明
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.
repo: google/skills
人気
- GitHubのスター
- 22k
- ランキング
- #10244
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
finding-google-skills
22kセットアップ作業に合うGoogleの公式ガイドを探すようエージェントを支援します。ホスティング、データベース、ストレージ、サインイン、AIモデルの提供などが対象です。
gcloud
22kエージェントが、Google CloudのgcloudコマンドについてWeb検索に頼らず、正確な構文を確かめてから書いたり確認したりできるよう支援します。
google-cloud-recipe-auth
22kエージェントが、Google Cloudのアイデンティティとアクセス(人やサービスがどうサインインし、どの権限を得るか)について、手順を案内できるよう支援します。
google-cloud-recipe-onboarding
22k新しい開発者が、プロジェクトの選択、請求の設定、最初のリソースのデプロイなど、Google Cloudの最初の手順を進められるよう案内します。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。