{"data":{"slug":"github-google-skills-skills-cloud-cloud-logging-query-generation-e184b23645ae","title":"Generate Logging Query Language queries","summary":"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.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-cloud-logging-query-generation-e184b23645ae","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-cloud-logging-query-generation-e184b23645ae","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-cloud-logging-query-generation-e184b23645ae.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-cloud-logging-query-generation-e184b23645ae\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Before generating queries, ensure you have read the service-specific reference files for the relevant Google Cloud service. These files contain critical information about resource types, log schemas, and query examples.","instructions":"---\nname: cloud-logging-query-generation\nmetadata:\n  version: \"1.0.2\"\n  category: CloudObservabilityAndMonitoring\ndescription: >-\n  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.\n---\n\n# Generate Logging Query Language queries\n\nUse this skill to generate correct Logging Query Language (LQL) queries for\nCloud Logging.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:cloud-logging-query-generation)\"`\nand append `agent-skills\/1.0 (skill:cloud-logging-query-generation)` to `User-Agent` headers.\n\n## Core rules\n\n1.  **Strict syntax requirements:**\n\n    *   **Always use double quotes (`\"`)** for string literals. Do not use\n        single quotes (`'`).\n    *   Write boolean operators in all capitals: `AND`, `OR`, `NOT`.\n    *   Always use parentheses to group terms and explicitly enforce precedence.\n\n2.  **Common pitfalls:**\n\n    *   **Instance ID vs. Instance Name:** For the `gce_instance` resource type,\n        do NOT compare instance names to instance IDs. Instance names are\n        strings (for example, `my-instance`). Instance IDs are numeric. If you\n        only have the name, then search by instance name,\n        `SEARCH(\"my-instance\")`, or use `resource.labels.instance_name` if that\n        label is available for the resource.\n    *   **Resource Type Accuracy:** Do not guess resource types. You must look\n        up the correct `resource.type` value in the service-specific reference\n        files. For example, use `internal_http_lb_rule` for Internal HTTP(S)\n        Load Balancer rules when filtering by forwarding rule name or region\n        (instead of `http_load_balancer`).\n\n3.  **Output format and placeholders:**\n\n    *   Output **only** the raw LQL query text. Do not include conversational\n        filler. Do not wrap the query in markdown code blocks unless explicitly\n        requested by the user. Valid LQL comments (using `--`) are allowed, and\n        are the ONLY acceptable way to include explanations or warnings.\n    *   **Never block on missing variables.** If the user's request lacks\n        specific identifiers (like a project ID, instance name, or IP address),\n        do not ask them for clarification. If the variable is required for a\n        functional query (like a log bucket name for a regional log), insert an\n        uppercase placeholder string wrapped in angle brackets (for example,\n        `\"<PROJECT_ID>\"`). **CRITICALLY**: If you include a placeholder for a\n        variable the user omitted, it will act as an explicit filter that causes\n        logs to be missed. Therefore, you MUST omit the entire filter\/line\n        containing the placeholder if the field is not strictly required. For\n        example, completely omit `resource.labels.instance_id=\"...\"` if the user\n        didn't specify an instance, but you MUST include\n        `logName=\"...\/projects\/<PROJECT_ID>\/...\"` with a placeholder if\n        constructing a regional log bucket query where a project ID is strictly\n        required.\n\n4.  **Preferred fields:**\n\n    *   Include `resource.type` and `log_id` restrictions when the query targets\n        specific Google Cloud services or resources. Global queries (for\n        example, \"latest error logs\") do not require these restrictions.\n\n## Detailed reference\n\nRefer to `references\/api_reference.md` for LQL syntax rules, including\nOperators, NULL handling, SEARCH, and Regex.\n\n## Service reference files\n\nBefore generating a query, you MUST read the examples for the specific service.\nLQL schemas and `resource.type` values are service-specific. **Do not stop\nreading after finding the Base Schema in the file. You must verify if there are\nspecific requirements for state tracking (like `previousState`) or\nresource-specific log IDs detailed in the paragraphs or specific query examples\nbelow the schema block.**\n\n**For the following services, read the exact file listed:**\n\n*   [App Engine](references\/query_app_engine.md)\n*   [BigQuery](references\/query_bigquery.md)\n*   [Cloud Deployment Manager](references\/query_deployment_manager.md)\n*   [Cloud Functions](references\/query_cloud_functions.md)\n*   [Cloud Observability (Monitoring, Logging, Trace)](references\/query_cloud_observability.md)\n*   [Cloud Run](references\/query_cloud_run.md)\n*   [Cloud Source Repositories](references\/query_cloud_source_repositories.md)\n*   [Cloud Spanner](references\/query_spanner.md)\n*   [Cloud SQL](references\/query_cloud_sql.md)\n*   [Cloud Storage](references\/query_cloud_storage.md)\n*   [Cloud Tasks](references\/query_cloud_tasks.md)\n*   [Compute Engine (GCE)](references\/query_compute_engine.md)\n*   [Dataflow](references\/query_dataflow.md)\n*   [Dataproc](references\/query_dataproc.md)\n*   [Kubernetes Engine (GKE)](references\/query_gke.md)\n*   [IAM & Service Accounts](references\/query_iam.md)\n*   [Networking (VPC, Load Balancing, and others)](references\/query_networking.md)\n*   [Security (Audit logging)](references\/query_security.md)\n*   [Service Usage (Enable\/Disable API, Quotas)](references\/query_service_usage.md)\n*   [Third Party (for example, Nginx, Apache)](references\/query_third_party.md)\n\n**For Google Cloud services that aren't listed:** If the service is not listed\nabove, write the LQL query based on your general knowledge.\n\n## Query generation rules\n\n1.  **Resource Types:** Explicitly define the `resource.type` in your queries\n    when focusing on specific services. For some queries, you may need to search\n    across multiple types (for example, `resource.type=(\"bigquery_project\" OR\n    \"bigquery_dataset\")`).\n2.  **Audit and Admin Logs:** If the user asks for audit logs, admin logs, API\n    logs, or logs about who created, updated, deleted, read, or accessed a\n    resource:\n    *   You MUST read\n        [references\/query_audit_logs.md](references\/query_audit_logs.md) for the\n        correct `protoPayload` schema paths and common examples.\n    *   If a specific example is not listed, guess the `protoPayload.methodName`\n        by combining the service and verb. When guessing, you MUST use the\n        scoped `SEARCH()` function (e.g., `SEARCH(protoPayload.methodName,\n        \"compute.instances.insert\")`) instead of the exact match operator (`=`)\n        to avoid version prefix mismatches. Do NOT use the colon operator (`:`)\n        as it may cause substring false positives.\n    *   For generic API enable\/disable events (e.g., a service was disabled),\n        always use `resource.type=\"audited_resource\"`.\n3.  **Handling Unknown Schemas (Crucial):** If the user asks to filter by a\n    specific field or condition, and if you cannot find a matching example or\n    schema in the reference files, **then you must generate a query using global\n    search.**\n    *   Only specify `jsonPayload.*` or `protoPayload.*` field structures when\n        you are certain of their exact name.\n    *   Use the `SEARCH()` function to find the keyword globally within the\n        correct `resource.type`.\n    *   **Mandatory LQL Comment:** When delivering a query that uses `SEARCH`,\n        you MUST add an LQL comment (using `--`) at the top of the query\n        indicating you used a global keyword search because the exact schema\n        wasn't in your references. Do NOT output conversational text, strictly\n        adhere to the Output Format rule.\n\n## Supporting links\n\n*   [Cloud Logging query language documentation](https:\/\/docs.cloud.google.com\/logging\/docs\/view\/logging-query-language)\n*   [Monitored resource types catalog](https:\/\/docs.cloud.google.com\/logging\/docs\/api\/v2\/resource-list)\n*   [Cloud Logging query library](https:\/\/docs.cloud.google.com\/logging\/docs\/view\/query-library)\n","use_cases":["Filter logs by specific Google Cloud services","Debug issues using log data","Analyze audit and admin logs for resource changes"],"limitations":["Does not support querying other databases like SQL or Cloud Spanner","Requires reading service-specific reference files for accurate queries","Must use double quotes for string literals and boolean operators in uppercase"],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/1e285f9d77ab260fd50944b49c3e2269b459474c\/skills\/cloud\/cloud-logging-query-generation\/SKILL.md","source_commit":"1e285f9d77ab260fd50944b49c3e2269b459474c","license":null,"version":null,"listing_approved_at":"2026-11-15","created_at":"2026-11-14T15:35:15.000000Z","updated_at":"2026-11-15T17:10:05.000000Z","seo_title":"Generate Logging Query Language queries for Cloud Logging","seo_description":"Generate accurate LQL queries for Cloud Logging to filter and analyze log data efficiently.","seo_keywords":["Generate LQL queries for Cloud Logging","Cloud Logging query generation","Filter logs by service","Debugging with Cloud Logs","Audit log queries for GCP"]}}