gcp-logs
Query GCP Cloud Logging for errors, service logs, and request traces. Use when investigating GCP-hosted services.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Query GCP Cloud Logging for errors, service logs, and request traces. Use when investigating GCP-hosted services.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Generic migration orchestrator that reads CHANGELOG.md to understand and execute version-specific migrations
Determine feature slug interactively by auto-detecting next number and prompting user for description
Share personal documents to the shared namespace with atomic git commit and push
Use when creating implementation plans to generate properly structured plans with phases, success criteria, and project references.
Use when documenting research findings to create properly structured research documents with frontmatter, sections, and file references.
ALWAYS check this skill before using grep, glob, Task tool, or doing any codebase exploration. Guides you to use specialized agents that are more efficient than basic tools.
| name | gcp-logs |
| description | Query GCP Cloud Logging for errors, service logs, and request traces. Use when investigating GCP-hosted services. |
Search GCP Cloud Logging for application errors, service logs, and traces.
# Check gcloud auth
gcloud auth list 2>/dev/null | grep -q ACTIVE || {
echo "Not authenticated. Run: gcloud auth login"
exit 1
}
# Show current project
CURRENT_PROJECT=$(gcloud config get-value project 2>/dev/null)
echo "Current GCP Project: $CURRENT_PROJECT"
# If context suggests different project, prompt to switch
# Example: User mentions "production" but current project is "staging"
# Detect from query context and prompt:
# echo "Query mentions 'production' but current project is '$CURRENT_PROJECT'"
# echo "Switch to production project? Run: gcloud config set project example-production"
# read -p "Continue with current project? (y/n) " -n 1 -r
Follow this approach for effective log queries:
# Step 1: Check if ANY logs exist in time range
gcloud logging read 'timestamp>="2025-12-24T10:00:00Z"' --limit=10
# Step 2: Filter to specific service
gcloud logging read 'resource.labels.container_name="api-gateway"' --limit=50
# Step 3: Add severity filter
gcloud logging read 'resource.labels.container_name="api-gateway" AND severity>=ERROR' --limit=100
# Step 4: Narrow time window
gcloud logging read \
'resource.labels.container_name="api-gateway" AND severity>=ERROR AND timestamp>="2025-12-24T10:00:00Z" AND timestamp<="2025-12-24T11:00:00Z"' \
--limit=100 \
--format=json
For large outputs (>100 entries), save to tmp file:
# Save logs to tmp file
gcloud logging read 'severity>=ERROR' \
--limit=1000 \
--format=json > /tmp/gcp-errors-$(date +%Y%m%d-%H%M%S).json
# Then analyze with jq, grep, or other tools
cat /tmp/gcp-errors-*.json | jq '.[] | select(.severity=="CRITICAL")'
cat /tmp/gcp-errors-*.json | jq '.[] | .jsonPayload.message' | sort | uniq -c
Benefits:
For detailed query examples, see:
# Errors from specific service
gcloud logging read 'resource.labels.container_name="service-name" AND severity>=ERROR' --limit=100
# Logs in time range
gcloud logging read 'timestamp>="2025-12-24T10:00:00Z" AND timestamp<="2025-12-24T11:00:00Z"' --limit=200
# Combined filters
gcloud logging read 'resource.labels.container_name="api" AND severity>=ERROR AND timestamp>="2025-12-24T10:00:00Z"' --format=json
--format=json - Machine-readable JSON (recommended for piping to jq)--format=table - Human-readable table--limit to control result count (default: 10)--project to override current projectAND, OR, NOT