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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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
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.
- Always use double quotes (
Common pitfalls:
- Instance ID vs. Instance Name: For the
gce_instanceresource 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 useresource.labels.instance_nameif that label is available for the resource. - Resource Type Accuracy: Do not guess resource types. You must look
up the correct
resource.typevalue in the service-specific reference files. For example, useinternal_http_lb_rulefor Internal HTTP(S) Load Balancer rules when filtering by forwarding rule name or region (instead ofhttp_load_balancer).
- Instance ID vs. Instance Name: For the
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 omitresource.labels.instance_id="..."if the user didn't specify an instance, but you MUST includelogName=".../projects/<PROJECT_ID>/..."with a placeholder if constructing a regional log bucket query where a project ID is strictly required.
- 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
Preferred fields:
- Include
resource.typeandlog_idrestrictions when the query targets specific Google Cloud services or resources. Global queries (for example, "latest error logs") do not require these restrictions.
- Include
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:
- App Engine
- BigQuery
- Cloud Deployment Manager
- Cloud Functions
- Cloud Observability (Monitoring, Logging, Trace)
- Cloud Run
- Cloud Source Repositories
- Cloud Spanner
- [Cloud SQL](references/query_cloud_sql.md
常见问题
它也能查询 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
评论
- …
同一仓库的更多技能
finding-google-skills
22k帮你的智能体为某项设置任务找到合适的 Google 指南,例如托管、数据库、存储、登录或 AI 模型服务。
gcloud
22k帮你的智能体编写并检查 Google Cloud gcloud 命令,在运行任何内容之前查阅准确的语法,避免猜测参数。
google-cloud-recipe-auth
22k引导你的智能体了解 Google Cloud 的身份与访问管理,包括人员和服务如何登录,以及它们各自获得哪些权限。
google-cloud-recipe-onboarding
22k带领新开发者完成在 Google Cloud 上的第一步,包括选择项目、关联计费,以及部署第一个资源。