Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)22k · #10244

cloud-monitoring-promql-query

Skill này làm gì

Skill này viết truy vấn PromQL để đọc metric của Google Cloud. Skill dành cho những người thích PromQL hơn định dạng bộ lọc Cloud Monitoring tiêu chuẩn.

Khi nào nên dùng

  • ✓Khi bạn muốn một truy vấn PromQL để vẽ biểu đồ hoặc đặt cảnh báo cho một metric Cloud Monitoring.
  • ✓Khi bạn cần một phép tổng hợp viết bằng PromQL cho một tài nguyên Google Cloud.
  • ✓Khi bạn muốn chuyển một metric thành cấu trúc PromQL đúng.

Liên kết skill

https://github.com/google/skills/blob/main/skills/cloud/cloud-monitoring-promql-query/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/google/skills/blob/main/skills/cloud/cloud-monitoring-promql-query/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết truy vấn PromQL hiển thị tỷ lệ lỗi mỗi phút của dịch vụ Cloud Run của tôi.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill kiểm tra ID dự án trước, rồi ánh xạ chi tiết metric và tài nguyên sang cấu trúc PromQL mà Google Cloud yêu cầu. Skill trả về một truy vấn sẵn sàng dùng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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:

  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), us
Câu hỏi thường gặp

Skill có cần ID dự án của tôi không?

Có. Skill hỏi ID dự án và kiểm tra môi trường nếu ID không có trong yêu cầu của bạn.

Skill có tìm metric không?

Không. Việc khám phá metric do một skill chọn lựa riêng đảm nhiệm.

Skill có hoạt động với mọi loại metric không?

Skill được thiết kế để ánh xạ mọi loại metric và tài nguyên của Cloud Monitoring sang PromQL.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
22k
Vị trí xếp hạng
#10244
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự