jpskill.com
🛠️ 開発・MCP コミュニティ

gcp-networking-observability

Google Cloudのネットワークに関する問題を、各種ログやメトリクス分析、接続テストで調査し、BigQueryのデータセットも活用して、接続不良や遅延、パケットロスなどの原因を特定するSkill。

📜 元の英語説明(参考)

Investigate Google Cloud networking issues by analyzing VPC Flow Logs, firewall logs, Cloud NAT logs, threat logs, and networking metrics. Run Connectivity Tests for path diagnostics and use BigQuery linked datasets for high-volume traffic analysis. Use when troubleshooting connection failures, latency, packet loss, or top-talkers.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Google Cloudのネットワークに関する問題を、各種ログやメトリクス分析、接続テストで調査し、BigQueryのデータセットも活用して、接続不良や遅延、パケットロスなどの原因を特定するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o gcp-networking-observability.zip https://jpskill.com/download/14933.zip && unzip -o gcp-networking-observability.zip && rm gcp-networking-observability.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14933.zip -OutFile "$d\gcp-networking-observability.zip"; Expand-Archive "$d\gcp-networking-observability.zip" -DestinationPath $d -Force; ri "$d\gcp-networking-observability.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して gcp-networking-observability.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → gcp-networking-observability フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

GCP ネットワークの可観測性

概要

Google Cloud は、複数のネットワークテレメトリーストリームを発行します。VPC Flow Logs(サンプリングされた IP トラフィック)、ファイアウォールルールログ、Cloud NAT 変換ログ、Cloud Firewall Plus / Cloud IDS 脅威ログ、および Cloud Monitoring の集計メトリクスです。Connectivity Tests は、「A が B に到達できないのはなぜか?」という質問に対する静的なパス分析を提供します。適切なソースは質問によって異なります。1 つを選択して停止し、ツール間で検証を追いかけないでください。

手順

テレメトリーストリーム

ストリーム 用途
VPC Flow Logs トップトーカー、IP 間のバイト数/パケット数、トラフィック傾向、エグレス分析
Firewall Logs DENY イベント、ALLOW ルールの検証、誰がどのルールにヒットしたかの監査
Cloud NAT Logs ポート枯渇、送信元 NAT 変換の監査
Threat Logs Cloud Firewall Plus / Cloud IDS — ディープパケットインスペクションからの悪意のあるパターン
Networking Metrics パフォーマンスダッシュボード用の時系列スループット、RTT、パケットロス
Connectivity Tests 2 つのエンドポイント間の静的な到達可能性分析

VPC Flow Logs の有効化

# サブネットでフローログを有効にする(5% サンプリング、完全なメタデータ)
gcloud compute networks subnets update prod-subnet \
  --region=us-central1 \
  --enable-flow-logs \
  --logging-aggregation-interval=interval-5-sec \
  --logging-flow-sampling=0.5 \
  --logging-metadata=include-all
# ログシンク経由でフローログを BigQuery にルーティングする(分析に推奨)
gcloud logging sinks create vpc-flow-sink \
  bigquery.googleapis.com/projects/my-project/datasets/network_logs \
  --log-filter='resource.type="gce_subnetwork" AND log_id("compute.googleapis.com/vpc_flows")' \
  --use-partitioned-tables

トップトーカー分析 (BigQuery)

ボリュームベースのクエリには、常に _AllLogs データセットの BigQuery を優先してください。Cloud Logging の Logs Explorer は、スポットチェック用であり、集計用ではありません。

-- バイト数による上位 20 件の送信元→宛先 IP ペア(過去 24 時間)
SELECT
  jsonPayload.connection.src_ip AS src,
  jsonPayload.connection.dest_ip AS dst,
  jsonPayload.connection.dest_port AS dst_port,
  SUM(CAST(jsonPayload.bytes_sent AS INT64)) AS total_bytes,
  COUNT(*) AS flows
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/vpc_flows'
  AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 24 HOUR)
GROUP BY src, dst, dst_port
ORDER BY total_bytes DESC
LIMIT 20;
-- VM による外部エグレス(非 RFC1918 宛先)を検索する
SELECT
  jsonPayload.src_instance.vm_name AS vm,
  jsonPayload.connection.dest_ip AS external_dst,
  SUM(CAST(jsonPayload.bytes_sent AS INT64)) / POW(1024, 3) AS gb_sent
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/vpc_flows'
  AND NOT NET.IP_IN_NET(jsonPayload.connection.dest_ip, '10.0.0.0/8')
  AND NOT NET.IP_IN_NET(jsonPayload.connection.dest_ip, '172.16.0.0/12')
  AND NOT NET.IP_IN_NET(jsonPayload.connection.dest_ip, '192.168.0.0/16')
  AND DATE(timestamp) = CURRENT_DATE()
GROUP BY vm, external_dst
ORDER BY gb_sent DESC
LIMIT 50;

クエリが NULL VM 名を返す場合、サブネットには EXCLUDE_ALL_METADATA が設定されています。jsonPayload.connection.src_ip を結合キーとして使用して再試行してください。

ファイアウォール DENY 分析

-- 上位の拒否された接続試行(ファイアウォールルール + 送信元 IP)
SELECT
  jsonPayload.rule_details.reference AS rule,
  jsonPayload.connection.src_ip AS src,
  jsonPayload.connection.dest_port AS port,
  COUNT(*) AS hits
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/firewall'
  AND jsonPayload.disposition = 'DENIED'
  AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
GROUP BY rule, src, port
ORDER BY hits DESC
LIMIT 25;

Connectivity Tests (静的パス分析)

# VM と外部 IP 間の到達可能性をテストする
gcloud network-management connectivity-tests create vm-to-api \
  --source-instance=projects/my-project/zones/us-central1-a/instances/web-1 \
  --destination-ip-address=203.0.113.10 \
  --destination-port=443 \
  --protocol=TCP

# 実行して結果を読み取る
gcloud network-management connectivity-tests run vm-to-api
gcloud network-management connectivity-tests describe vm-to-api \
  --format='value(reachabilityDetails.result,reachabilityDetails.traces)'

Connectivity Tests は、到達可能性に関する質問に決定論的に答えます — ログを掘り下げる必要はありません。結果が REACHABLE の場合、パスは機能します。UNREACHABLE には、失敗したホップとルールが含まれます。

Cloud NAT ポート枯渇

-- NAT ポートを飽和させている VM を見つける
SELECT
  jsonPayload.endpoint.vm_name AS vm,
  COUNT(*) AS allocations,
  COUNTIF(jsonPayload.allocation_status = 'DROPPED') AS dropped
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/nat_flows'
  AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 MINUTE)
GROUP BY vm
ORDER BY dropped DESC
LIMIT 10;

dropped > 0 の場合、Cloud NAT 構成で min-ports-per-vm を増やすか、NAT IP を追加してください。

Networking Metrics (Cloud Monitoring)

# Monitoring API 経由で RTT/レイテンシーの時系列をプルする
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://monitoring.googleapis.com/v3/projects/my-project/timeSeries?\
filter=metric.type%3D%22networking.googleapis.com/vm_flow/rtt%22&\
interval.startTime=2026-04-15T00:00:00Z&\
interval.endTime=2026-04-15T01:00:00Z"

ダッシュボードの場合は、Flow Analyzer にリンクしてください — SQL を記述せずに上位 N 件のトラフィックを表示する最も速い方法です。

調査ワークフロー

  1. 質問に対する適切なプライマリソースを特定します。
    • 「接続が失敗するのはなぜですか?」→ Connectivity Tests + ファイアウォールログ
    • 「誰が最も多くのデータを送信していますか?」→ VPC Flow Logs (BigQuery)
    • 「レイテンシーは何が変わりましたか?」→ Networking metrics (Monitoring)
  2. プライマリソースに対して 1 つのクエリを実行します。
  3. 答えを提示します — 答えが 0null、または「トラフィックなし」であっても。そこで止めてください。
  4. 2 番目のソースを実行しないでください。

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

GCP Networking Observability

Overview

Google Cloud emits multiple network telemetry streams: VPC Flow Logs (sampled IP traffic), firewall rule logs, Cloud NAT translation logs, Cloud Firewall Plus / Cloud IDS threat logs, and aggregated metrics in Cloud Monitoring. Connectivity Tests provide static path analysis for "why can't A reach B?" questions. The right source depends on the question — pick one and stop, do not chase verification across tools.

Instructions

Telemetry Streams

Stream Use it for
VPC Flow Logs Top talkers, bytes/packets between IPs, traffic trends, egress analysis
Firewall Logs DENY events, verifying ALLOW rules, audit of who hit which rule
Cloud NAT Logs Port exhaustion, source NAT translation auditing
Threat Logs Cloud Firewall Plus / Cloud IDS — malicious patterns from deep packet inspection
Networking Metrics Time-series throughput, RTT, packet loss for performance dashboards
Connectivity Tests Static reachability analysis between two endpoints

Enabling VPC Flow Logs

# Enable flow logs on a subnet (5% sampling, full metadata)
gcloud compute networks subnets update prod-subnet \
  --region=us-central1 \
  --enable-flow-logs \
  --logging-aggregation-interval=interval-5-sec \
  --logging-flow-sampling=0.5 \
  --logging-metadata=include-all
# Route flow logs to BigQuery via a Log Sink (recommended for analysis)
gcloud logging sinks create vpc-flow-sink \
  bigquery.googleapis.com/projects/my-project/datasets/network_logs \
  --log-filter='resource.type="gce_subnetwork" AND log_id("compute.googleapis.com/vpc_flows")' \
  --use-partitioned-tables

Top-Talker Analysis (BigQuery)

Always prefer BigQuery on _AllLogs datasets for volume-based queries. Cloud Logging's Logs Explorer is for spot-checking, not aggregation.

-- Top 20 source→destination IP pairs by bytes (last 24 hours)
SELECT
  jsonPayload.connection.src_ip AS src,
  jsonPayload.connection.dest_ip AS dst,
  jsonPayload.connection.dest_port AS dst_port,
  SUM(CAST(jsonPayload.bytes_sent AS INT64)) AS total_bytes,
  COUNT(*) AS flows
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/vpc_flows'
  AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 24 HOUR)
GROUP BY src, dst, dst_port
ORDER BY total_bytes DESC
LIMIT 20;
-- Find external egress (to non-RFC1918) by VM
SELECT
  jsonPayload.src_instance.vm_name AS vm,
  jsonPayload.connection.dest_ip AS external_dst,
  SUM(CAST(jsonPayload.bytes_sent AS INT64)) / POW(1024, 3) AS gb_sent
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/vpc_flows'
  AND NOT NET.IP_IN_NET(jsonPayload.connection.dest_ip, '10.0.0.0/8')
  AND NOT NET.IP_IN_NET(jsonPayload.connection.dest_ip, '172.16.0.0/12')
  AND NOT NET.IP_IN_NET(jsonPayload.connection.dest_ip, '192.168.0.0/16')
  AND DATE(timestamp) = CURRENT_DATE()
GROUP BY vm, external_dst
ORDER BY gb_sent DESC
LIMIT 50;

If the query returns NULL VM names, the subnet has EXCLUDE_ALL_METADATA set. Retry using jsonPayload.connection.src_ip as the join key.

Firewall DENY Analysis

-- Top denied connection attempts (firewall rule + source IP)
SELECT
  jsonPayload.rule_details.reference AS rule,
  jsonPayload.connection.src_ip AS src,
  jsonPayload.connection.dest_port AS port,
  COUNT(*) AS hits
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/firewall'
  AND jsonPayload.disposition = 'DENIED'
  AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR)
GROUP BY rule, src, port
ORDER BY hits DESC
LIMIT 25;

Connectivity Tests (Static Path Analysis)

# Test reachability between a VM and an external IP
gcloud network-management connectivity-tests create vm-to-api \
  --source-instance=projects/my-project/zones/us-central1-a/instances/web-1 \
  --destination-ip-address=203.0.113.10 \
  --destination-port=443 \
  --protocol=TCP

# Run and read the result
gcloud network-management connectivity-tests run vm-to-api
gcloud network-management connectivity-tests describe vm-to-api \
  --format='value(reachabilityDetails.result,reachabilityDetails.traces)'

Connectivity Tests answer reachability questions deterministically — no log digging. If the result is REACHABLE, the path works; UNREACHABLE includes the failing hop and rule.

Cloud NAT Port Exhaustion

-- Find which VMs are saturating NAT ports
SELECT
  jsonPayload.endpoint.vm_name AS vm,
  COUNT(*) AS allocations,
  COUNTIF(jsonPayload.allocation_status = 'DROPPED') AS dropped
FROM `my-project.network_logs._AllLogs`
WHERE log_id = 'compute.googleapis.com/nat_flows'
  AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 MINUTE)
GROUP BY vm
ORDER BY dropped DESC
LIMIT 10;

If dropped > 0, increase min-ports-per-vm on the Cloud NAT config or add more NAT IPs.

Networking Metrics (Cloud Monitoring)

# Pull RTT/latency time series via Monitoring API
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://monitoring.googleapis.com/v3/projects/my-project/timeSeries?\
filter=metric.type%3D%22networking.googleapis.com/vm_flow/rtt%22&\
interval.startTime=2026-04-15T00:00:00Z&\
interval.endTime=2026-04-15T01:00:00Z"

For dashboards, link the Flow Analyzer — it's the fastest way to view top-N traffic without writing SQL.

Investigation Workflow

  1. Identify the right primary source for the question:
    • "Why is connection failing?" → Connectivity Tests + firewall logs
    • "Who is sending the most data?" → VPC Flow Logs (BigQuery)
    • "What changed in latency?" → Networking metrics (Monitoring)
  2. Run one query against the primary source.
  3. Present the answer — even if the answer is 0, null, or "no traffic." Stop there.
  4. Never run a second source to "verify" — different tools have different sampling and aggregation, comparing them creates rabbit holes.

    Examples

Example 1 — App can't reach a third-party API

User reports their service in us-central1 can't connect to a payments API. Run a Connectivity Test from the Cloud Run service to the API IP on port 443 — the result names the failing hop (e.g., firewall-rule deny-egress-public). Update the rule, rerun the test, confirm REACHABLE. No need to dig through firewall logs.

Example 2 — Surprise egress bill

User sees a $4k spike in egress charges for the month. Query VPC Flow Logs in BigQuery grouped by source VM and external destination IP, ordered by bytes. Top result: a VM exfiltrating 800 GB to a single IP. Cross-check the destination IP against threat intel, kill the VM, file an incident. One query — done.

Guidelines

  • Pick one source per question — never query a second tool to "double-check" the first
  • Always use BigQuery on _AllLogs for volume/aggregation queries; Logs Explorer is for spot-checks
  • Print the SQL before running it — the user should see what you're querying
  • Time-range upfront — calculate "last 1 hour" / "yesterday" once, don't re-derive
  • Treat 0 / null / no traffic as a conclusive answer — don't search for "more interesting" data
  • For routine reachability questions, Connectivity Tests beat log mining every time
  • Enable VPC Flow Logs at 0.5–1.0 sampling for active troubleshooting; 0.05–0.1 for baseline
  • Route to BigQuery via Log Sink — Cloud Logging retention costs add up at high volume
  • Watch EXCLUDE_ALL_METADATA subnets — VM names will be NULL, fall back to IPs
  • For NAT port exhaustion, increase min-ports-per-vm or scale NAT IPs before app changes