跳到正文
Skillpedia
部署与云(DevOps)22k · #10239

cloud-logging-query-generation

它能做什么

这个技能把日常需求转换为 Google Cloud 日志的 Logging Query Language 搜索语句。它适用于调试时需要查找特定日志条目的人。

适用场景

  • ✓当你想搜索 Google Cloud 日志中某个特定错误、服务或资源的时候。
  • ✓当你在排查问题,需要精确的日志过滤器的时候。
  • ✓当日志查询没有返回任何结果,需要一个正确版本的查询的时候。

技能链接

https://github.com/google/skills/blob/main/skills/cloud/cloud-logging-query-generation/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/google/skills/blob/main/skills/cloud/cloud-logging-query-generation/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请给我一个 Cloud Logging 查询,显示过去一小时内 Cloud Run 服务的所有 500 错误。”

每周 5 个新技能,1 分钟读完。

工作原理

它会把你的需求转换为 Logging Query Language,使用双引号、大写的 AND、OR 和 NOT,以及分组的条件。它还会避免常见错误,例如混淆实例名称和 ID。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Generate Logging Query Language queries

Use this skill to generate correct Logging Query Language (LQL) queries for Cloud Logging.

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-logging-query-generation)" and append agent-skills/1.0 (skill:cloud-logging-query-generation) to User-Agent headers.

Core rules

  1. Strict syntax requirements:

    • Always use double quotes (") for string literals. Do not use single quotes (').
    • Write boolean operators in all capitals: AND, OR, NOT.
    • Always use parentheses to group terms and explicitly enforce precedence.
  2. Common pitfalls:

    • Instance ID vs. Instance Name: For the gce_instance resource type, do NOT compare instance names to instance IDs. Instance names are strings (for example, my-instance). Instance IDs are numeric. If you only have the name, then search by instance name, SEARCH("my-instance"), or use resource.labels.instance_name if that label is available for the resource.
    • Resource Type Accuracy: Do not guess resource types. You must look up the correct resource.type value in the service-specific reference files. For example, use internal_http_lb_rule for Internal HTTP(S) Load Balancer rules when filtering by forwarding rule name or region (instead of http_load_balancer).
  3. Output format and placeholders:

    • Output only the raw LQL query text. Do not include conversational filler. Do not wrap the query in markdown code blocks unless explicitly requested by the user. Valid LQL comments (using --) are allowed, and are the ONLY acceptable way to include explanations or warnings.
    • Never block on missing variables. If the user's request lacks specific identifiers (like a project ID, instance name, or IP address), do not ask them for clarification. If the variable is required for a functional query (like a log bucket name for a regional log), insert an uppercase placeholder string wrapped in angle brackets (for example, "<PROJECT_ID>"). CRITICALLY: If you include a placeholder for a variable the user omitted, it will act as an explicit filter that causes logs to be missed. Therefore, you MUST omit the entire filter/line containing the placeholder if the field is not strictly required. For example, completely omit resource.labels.instance_id="..." if the user didn't specify an instance, but you MUST include logName=".../projects/<PROJECT_ID>/..." with a placeholder if constructing a regional log bucket query where a project ID is strictly required.
  4. Preferred fields:

    • Include resource.type and log_id restrictions when the query targets specific Google Cloud services or resources. Global queries (for example, "latest error logs") do not require these restrictions.

Detailed reference

Refer to references/api_reference.md for LQL syntax rules, including Operators, NULL handling, SEARCH, and Regex.

Service reference files

Before generating a query, you MUST read the examples for the specific service. LQL schemas and resource.type values are service-specific. Do not stop reading after finding the Base Schema in the file. You must verify if there are specific requirements for state tracking (like previousState) or resource-specific log IDs detailed in the paragraphs or specific query examples below the schema block.

For the following services, read the exact file listed:

常见问题

它也能查询 SQL 数据库吗?

不能。它只为 Cloud Logging 生成查询,不为 SQL 或 Spanner 等数据库生成。

为什么实例名称和 ID 很重要?

名称是文本,ID 是数字,因此查询必须匹配正确的那一个。

它始终使用什么语法?

文本用双引号,AND、OR 和 NOT 用大写,并用括号分组条件。

详情

作者的原始描述

Generates Logging Query Language (LQL) queries for Cloud Logging on Google Cloud from natural language. Use this skill when you need to query log data or when you are debugging issues. You can filter log data by Google Cloud service. Don't use this skill to query other databases, such as SQL or Cloud Spanner.

repo: google/skills

热度

GitHub 星标
22k
排名
#10239
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能