Cloud Logging Query Generation

Cloud Logging Query Generation

Writes correct Logging Query Language queries for Cloud Logging from plain-language requests, with per-service references for GKE, Cloud Run, BigQuery, audit logs and more.

Skill files24 files

references/

SKILL.md153 lines
1
---
2
name: cloud-logging-query-generation
3
metadata:
4
version: "1.0.2"
5
category: CloudObservabilityAndMonitoring
6
description: >-
7
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.
8
---
9
10
# Generate Logging Query Language queries
11
12
Use this skill to generate correct Logging Query Language (LQL) queries for
13
Cloud Logging.
14
15
## Attribution
16
17
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
18
MUST read [Usage Attribution](references/attribution.md). For commands executed
19
directly in the terminal (never in generated scripts, Terraform, or user code),
20
prefix `gcloud` with
21
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-logging-query-generation)"`
22
and append `agent-skills/1.0 (skill:cloud-logging-query-generation)` to `User-Agent` headers.
23
24
## Core rules
25
26
1. **Strict syntax requirements:**
27
28
* **Always use double quotes (`"`)** for string literals. Do not use
29
single quotes (`'`).
30
* Write boolean operators in all capitals: `AND`, `OR`, `NOT`.
31
* Always use parentheses to group terms and explicitly enforce precedence.
32
33
2. **Common pitfalls:**
34
35
* **Instance ID vs. Instance Name:** For the `gce_instance` resource type,
36
do NOT compare instance names to instance IDs. Instance names are
37
strings (for example, `my-instance`). Instance IDs are numeric. If you
38
only have the name, then search by instance name,
39
`SEARCH("my-instance")`, or use `resource.labels.instance_name` if that
40
label is available for the resource.
41
* **Resource Type Accuracy:** Do not guess resource types. You must look
42
up the correct `resource.type` value in the service-specific reference
43
files. For example, use `internal_http_lb_rule` for Internal HTTP(S)
44
Load Balancer rules when filtering by forwarding rule name or region
45
(instead of `http_load_balancer`).
46
47
3. **Output format and placeholders:**
48
49
* Output **only** the raw LQL query text. Do not include conversational
50
filler. Do not wrap the query in markdown code blocks unless explicitly
51
requested by the user. Valid LQL comments (using `--`) are allowed, and
52
are the ONLY acceptable way to include explanations or warnings.
53
* **Never block on missing variables.** If the user's request lacks
54
specific identifiers (like a project ID, instance name, or IP address),
55
do not ask them for clarification. If the variable is required for a
56
functional query (like a log bucket name for a regional log), insert an
57
uppercase placeholder string wrapped in angle brackets (for example,
58
`"<PROJECT_ID>"`). **CRITICALLY**: If you include a placeholder for a
59
variable the user omitted, it will act as an explicit filter that causes
60
logs to be missed. Therefore, you MUST omit the entire filter/line
61
containing the placeholder if the field is not strictly required. For
62
example, completely omit `resource.labels.instance_id="..."` if the user
63
didn't specify an instance, but you MUST include
64
`logName=".../projects/<PROJECT_ID>/..."` with a placeholder if
65
constructing a regional log bucket query where a project ID is strictly
66
required.
67
68
4. **Preferred fields:**
69
70
* Include `resource.type` and `log_id` restrictions when the query targets
71
specific Google Cloud services or resources. Global queries (for
72
example, "latest error logs") do not require these restrictions.
73
74
## Detailed reference
75
76
Refer to `references/api_reference.md` for LQL syntax rules, including
77
Operators, NULL handling, SEARCH, and Regex.
78
79
## Service reference files
80
81
Before generating a query, you MUST read the examples for the specific service.
82
LQL schemas and `resource.type` values are service-specific. **Do not stop
83
reading after finding the Base Schema in the file. You must verify if there are
84
specific requirements for state tracking (like `previousState`) or
85
resource-specific log IDs detailed in the paragraphs or specific query examples
86
below the schema block.**
87
88
**For the following services, read the exact file listed:**
89
90
* [App Engine](references/query_app_engine.md)
91
* [BigQuery](references/query_bigquery.md)
92
* [Cloud Deployment Manager](references/query_deployment_manager.md)
93
* [Cloud Functions](references/query_cloud_functions.md)
94
* [Cloud Observability (Monitoring, Logging, Trace)](references/query_cloud_observability.md)
95
* [Cloud Run](references/query_cloud_run.md)
96
* [Cloud Source Repositories](references/query_cloud_source_repositories.md)
97
* [Cloud Spanner](references/query_spanner.md)
98
* [Cloud SQL](references/query_cloud_sql.md)
99
* [Cloud Storage](references/query_cloud_storage.md)
100
* [Cloud Tasks](references/query_cloud_tasks.md)
101
* [Compute Engine (GCE)](references/query_compute_engine.md)
102
* [Dataflow](references/query_dataflow.md)
103
* [Dataproc](references/query_dataproc.md)
104
* [Kubernetes Engine (GKE)](references/query_gke.md)
105
* [IAM & Service Accounts](references/query_iam.md)
106
* [Networking (VPC, Load Balancing, and others)](references/query_networking.md)
107
* [Security (Audit logging)](references/query_security.md)
108
* [Service Usage (Enable/Disable API, Quotas)](references/query_service_usage.md)
109
* [Third Party (for example, Nginx, Apache)](references/query_third_party.md)
110
111
**For Google Cloud services that aren't listed:** If the service is not listed
112
above, write the LQL query based on your general knowledge.
113
114
## Query generation rules
115
116
1. **Resource Types:** Explicitly define the `resource.type` in your queries
117
when focusing on specific services. For some queries, you may need to search
118
across multiple types (for example, `resource.type=("bigquery_project" OR
119
"bigquery_dataset")`).
120
2. **Audit and Admin Logs:** If the user asks for audit logs, admin logs, API
121
logs, or logs about who created, updated, deleted, read, or accessed a
122
resource:
123
* You MUST read
124
[references/query_audit_logs.md](references/query_audit_logs.md) for the
125
correct `protoPayload` schema paths and common examples.
126
* If a specific example is not listed, guess the `protoPayload.methodName`
127
by combining the service and verb. When guessing, you MUST use the
128
scoped `SEARCH()` function (e.g., `SEARCH(protoPayload.methodName,
129
"compute.instances.insert")`) instead of the exact match operator (`=`)
130
to avoid version prefix mismatches. Do NOT use the colon operator (`:`)
131
as it may cause substring false positives.
132
* For generic API enable/disable events (e.g., a service was disabled),
133
always use `resource.type="audited_resource"`.
134
3. **Handling Unknown Schemas (Crucial):** If the user asks to filter by a
135
specific field or condition, and if you cannot find a matching example or
136
schema in the reference files, **then you must generate a query using global
137
search.**
138
* Only specify `jsonPayload.*` or `protoPayload.*` field structures when
139
you are certain of their exact name.
140
* Use the `SEARCH()` function to find the keyword globally within the
141
correct `resource.type`.
142
* **Mandatory LQL Comment:** When delivering a query that uses `SEARCH`,
143
you MUST add an LQL comment (using `--`) at the top of the query
144
indicating you used a global keyword search because the exact schema
145
wasn't in your references. Do NOT output conversational text, strictly
146
adhere to the Output Format rule.
147
148
## Supporting links
149
150
* [Cloud Logging query language documentation](https://docs.cloud.google.com/logging/docs/view/logging-query-language)
151
* [Monitored resource types catalog](https://docs.cloud.google.com/logging/docs/api/v2/resource-list)
152
* [Cloud Logging query library](https://docs.cloud.google.com/logging/docs/view/query-library)
153

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,691 prompts

More by @OpenSourceBuffGuy

See all
Scarlet Court Photo Type Poster prompt image

Scarlet Court Photo Type Poster

Defines an action-ad poster style with a flat scarlet field, a blue sports-court photo panel, a cutout athlete crossing both and oversized cream display lettering.

image-prompt, json-prompt, placeholders, poster, sports, advertising, typography, collage, vibrant-colors, limited-palette, text-rendering, vertical-format, widescreen, graphic-design, for-designers, high-angle, photorealistic, film-grain, structured-output, long-form, advanced, style-reference, editorial

Convert Excel to Markdown prompt image

Convert Excel to Markdown

Teaches an AI agent to convert .xlsx workbooks into Markdown with a bundled script before analysing, summarising or extracting data from them, including whole folders.

agent-skill, converter, document-analysis, data-extraction, excel, markdown, python, csv, spreadsheet, command-line, code, structured-output, for-data-analysts, for-developers, workflow-automation, best-practices, conditional-logic, tool-use, long-form

CSS Architecture prompt image

CSS Architecture

Teaches a coding agent to organise scalable CSS using BEM, SMACSS, CSS variables, utility-first and CSS-in-JS patterns with consistent naming.

agent-skill, css, frontend, web-development, design-systems, clean-code, best-practices, code-generation, tailwind, react, html, design-patterns, style-guide, ui-ux, code, for-developers, for-designers, long-form

Reviews

Loading reviews…

Discussion

Loading comments…