一键导入
investigate-logging
Google Cloud Logging を gcloud logging read で取得し jq/duckdb で分析。"Cloud Logging", "GCP ログ調査", "GKE ログ", "Cloud Run ログ" などで起動。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Google Cloud Logging を gcloud logging read で取得し jq/duckdb で分析。"Cloud Logging", "GCP ログ調査", "GKE ログ", "Cloud Run ログ" などで起動。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Ask OpenAI Codex CLI for an autonomous second AI opinion. "ask codex", "codex と相談" などで起動。
Request GitHub Copilot review on a Pull Request. "PR レビュー依頼", "copilot review" などで起動。
Extract VTT transcript from a Zoom recording share page. "zoom transcript", "zoom 文字起こし" などで起動。
Download the video (MP4) from a Zoom recording share page. "zoom video download", "zoom 録画 ダウンロード", "zoom 動画 ダウンロード" などで起動。
Round-trip code review through difit. Use when the user mentions "difit", "diff review", "open the diff", "let me look at this", or "review this PR locally". Launch mode arg — "open" (default, no comments at launch), "explain" (AI annotates its own change), "review" (AI posts findings on human code).
Stop tool execution before exhausting your Claude usage — set a 5h/7d usage-% or per-session cost threshold.
| name | investigate-logging |
| description | Google Cloud Logging を gcloud logging read で取得し jq/duckdb で分析。"Cloud Logging", "GCP ログ調査", "GKE ログ", "Cloud Run ログ" などで起動。 |
| allowed-tools | ["Bash(timeout *)","Bash(gcloud logging *)","Bash(jq *)","Bash(gojq *)","Bash(duckdb *)","Read","Write","Glob","Grep","AskUserQuestion"] |
| user-invocable | true |
Google Cloud Logging を効率的に調査するためのスキル。
timeout コマンドを使うgcloud auth login で認証済みUser says: 「本番で 500 エラーが発生しているので調べて」
Actions:
Result: エラーの原因特定と発生パターンのサマリを報告
User says: 「API のレスポンスが遅いので原因を調べて」
Actions:
Result: レイテンシ分布と遅延の原因候補を報告
User says: 「このリクエストの処理の流れを追いたい」
Actions:
# trace ID でフィルタ
timeout 60 gcloud logging read 'trace="projects/PROJECT_ID/traces/TRACE_ID"' \
--project PROJECT_ID --freshness 1h --format json > /tmp/trace.json
# 時系列でソート
jq -f ${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/scripts/filters/trace.jq /tmp/trace.json
Result: リクエストの処理フローと各サービスでの処理時間を報告
ユーザーに確認: プロジェクト ID、調査目的、時間範囲、既知の情報 (サービス名、エラーメッセージなど)
まず数件取得してログが存在するか、構造を確認する。
# 1. ログが存在するか確認
timeout 30 gcloud logging read 'resource.type="k8s_container"' \
--project PROJECT_ID --freshness 1h --limit 3 --format json | jq 'length'
# 2. ログ全体の構造を確認
timeout 30 gcloud logging read 'resource.type="k8s_container"' \
--project PROJECT_ID --freshness 1h --limit 1 --format json | jq '.[0]'
# 3. 利用可能なリソースタイプを確認
timeout 30 gcloud logging read '' \
--project PROJECT_ID --freshness 1h --limit 50 --format json \
| jq '[.[].resource.type] | unique'
結果が返ってこない場合: ログが存在しない可能性が高い。フィルタ条件を緩めて確認する。
# 1. ファイルに書き出し
timeout 120 gcloud logging read 'FILTER' \
--project PROJECT_ID --freshness 7d --limit 1000 --format json > /tmp/logs.json
# 2. 件数確認
jq length /tmp/logs.json
# 3. jq で分析 or duckdb で集計
jq '[.[] | {timestamp, ...}]' /tmp/logs.json
duckdb -s "SELECT field, COUNT(*) FROM read_json('/tmp/logs.json') GROUP BY 1"
timeout 60 gcloud logging read 'FILTER' \
--project PROJECT_ID \
--freshness 1h \
--limit 100 \
--format json
resource.type, resource.labels.*, logName, severity, timestamp, httpRequest.status, labels.*, trace
field="value" # 完全一致
field:substring # 部分一致 (遅い)
severity >= ERROR
expr1 AND expr2 # AND はインデックス活用可
expr1 OR expr2 # OR はインデックス活用不可 (遅い)
-field:* # フィールドを除外
timestamp >= "2024-01-01T00:00:00Z"
resource.type="k8s_container"
resource.type="http_load_balancer"
resource.type="cloud_run_revision"
severity>=ERROR
httpRequest.status>=500
httpRequest.latency >= "250ms"
${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/scripts/filters/ にプリセットあり。
# 一覧表示
ls ${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/scripts/filters/
# 使用例
jq -f ${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/scripts/filters/minimal.jq /tmp/logs.json
| フィルタ | 用途 | 出力フィールド |
|---|---|---|
| minimal.jq | 概要把握 | timestamp, severity, logName, resource, message |
| http-request.jq | HTTP リクエスト詳細 | timestamp, method, url, status, latency, userAgent |
| latency.jq | レイテンシ分析 (降順ソート) | timestamp, url, latency_ms, status |
| error-analysis.jq | エラー調査 | timestamp, severity, message, stack, trace, spanId |
| trace.jq | トレース調査 (時系列ソート) | timestamp, severity, trace, spanId, message, latency |
| audit.jq | 監査ログ | timestamp, method, resource, principal, callerIp |
| client-analysis.jq | クライアント分析 | timestamp, remoteIp, userAgent, status, path |
| k8s-pod.jq | GKE Pod メタデータ | timestamp, namespace, pod, container, severity, message |
| bigquery-job.jq | BigQuery ジョブ | timestamp, jobId, state, query (truncated), bytesProcessed |
| request-summary.jq | HTTP 統計サマリ | status 別カウント、平均/最大レイテンシ |
詳細は ${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/references/duckdb-patterns.md を参照。
# 基本パターン: JSON を直接読み込んで集計
duckdb -s "SELECT field, COUNT(*) FROM read_json('/tmp/logs.json') GROUP BY 1"
詳細は ${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/references/troubleshooting.md を参照。
詳細は ${CLAUDE_PLUGIN_ROOT}/skills/investigate-logging/references/service-examples.md を参照。