Join our Newsletter — 33% off our NHI Course
Home› Guides› Google Cloud VPC Flow Logs: enabling, sampling and…
Guide Cloud Security

Google Cloud VPC Flow Logs: enabling, sampling and detection use cases

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 14 min read
On this page

Google Cloud VPC Flow Logs are the cheapest way to see who talked to whom inside and out of a VPC, but teams often switch them on with default settings, never query them, and then discover gaps or a large logging bill during an incident. This guide explains what flow logs record, how to enable them through the Network Management API or the Compute Engine API, how aggregation, sampling, metadata and filters change cost and fidelity, and how to turn the records into practical detections. It is written for cloud security engineers and detection engineers working on Google Cloud. Audit logs, log buckets and sink design in general are covered in the Google Cloud Audit Logs and Log Sinks Guide; this page stays on network telemetry.

This is an independent guide from NHI Mgmt Group, based on Google Cloud's public documentation as of November 2026. It is not sponsored or reviewed by Google. Product features change, so confirm settings against Google Cloud's current documentation.

Key takeaways

  • Flow logs are sampled metadata, not packets. Records aggregate sampled packets by 5-tuple, and byte and packet counts are estimates; use Packet Mirroring when you need full packet content.
  • Two APIs, two sets of defaults. Google recommends the Network Management API, which keeps 100% of sampled log entries by default; configurations made with the Compute Engine API keep 50% by default.
  • Cost is controlled by four dials. Aggregation interval, secondary sampling rate, metadata and filter expressions decide volume, so set them per subnet according to detection value.
  • Retention is short unless you route. Flow logs land in Cloud Logging in the project of the reporting network and are kept for 30 days by default; sink them to BigQuery or a log bucket with longer retention for hunting.
  • Detections need baselines. Unusual egress, east-west connections that break segmentation and inbound traffic to exposed ports are the high-value use cases, and each depends on knowing normal traffic first.

What VPC Flow Logs capture

VPC Flow Logs sample packets sent from and received by VM instances (including Google Kubernetes Engine nodes), Cloud Run and App Engine resources that use Direct VPC egress, and packets that cross VLAN attachments for Cloud Interconnect and Cloud VPN tunnels. Google documents sampling for TCP, UDP, ICMP, ESP, GRE and RDMA traffic, in both directions. Records are written to Cloud Logging in the project that owns the reporting VPC network; for Shared VPC, logs go to the host project.

Two behaviours matter for detection design:

  • Firewall position: ingress packets denied by firewall rules are not sampled, while egress packets are sampled before egress firewall rules are applied, so denied outbound attempts can still appear. Pair flow logs with Firewall Rules Logging to see denied inbound traffic.
  • Dropped traffic records: dropped flows produce separate records with disposition=DROPPED and a drop_reason such as FIREWALL_DENY, NO_MATCHING_ROUTE, SPOOFED_SOURCE or NAT_OUT_OF_PORTS. Counts for these appear in bytes_dropped and packets_dropped rather than bytes_sent.
  • Optional TCP connection logging: on Network Management API configurations, connection logging records outbound connection attempts (SYN) and acknowledged inbound connections (SYN-ACK) in the connection_direction field. Google caps this at 100 connections per vCPU per second and 800 per VM per second, so very busy hosts may not log every connection.

Coverage gaps to plan for: flow logs are not supported on legacy networks or on subnets with purpose INTERNAL_HTTPS_LOAD_BALANCER; pod-to-pod traffic on the same GKE node needs intranode visibility turned on; and a VM with several network interfaces needs flow logs on every subnet that holds one of its interfaces. Google states that enabling flow logs adds no delay or performance penalty to traffic.

Enabling flow logs and configuration options

Flow logs can be enabled at organisation, VPC network, subnet, VLAN attachment and Cloud VPN tunnel level. Organisation-level configuration covers all subnets, VLAN attachments and Cloud VPN tunnels in every VPC network, and each project is billed for the flow logs its own resources report.

Google recommends the Network Management API (gcloud network-management vpc-flow-logs-configs create), which needs the Network Management API enabled and the Network Management Admin role (roles/networkmanagement.admin). The older Compute Engine API path (gcloud compute networks subnets update --enable-flow-logs) works on subnets only, needs Compute Admin or Compute Network Admin, and does not support TCP connection logging.

SettingNetwork Management APICompute Engine API (subnets)Effect
Aggregation interval--aggregation-interval: interval-5-sec (default), 30 sec, 1, 5, 10 or 15 min--logging-aggregation-interval: 5-sec (default) to 15-minLonger intervals merge more packets into one record and reduce volume
Secondary sampling--flow-sampling: above 0.0 up to 1.0, default 1.0--logging-flow-sampling: 0.0 to 1.0, default 0.5Share of sampled entries actually written
Metadata--metadata: include-all-metadata (default), exclude-all-metadata, custom-metadata with --metadata-fields--logging-metadata: include-all, exclude-all, custom with --logging-metadata-fieldsAdds VM, VPC, GKE, location and service context at extra storage cost
Filter--filter-expr, up to 2,048 characters--logging-filter-exprOnly flows matching the CEL expression are written
TCP connection logging--connection-logging: enabled or disabled (default)Use the Network Management API for thisAdds SYN and SYN-ACK direction records

The primary sampling rate is set by Google, varies with the load on the physical host and cannot be changed. Everything in the table above is the secondary layer you control. Manage configurations in infrastructure as code so that new subnets inherit the agreed settings; turning a configuration off pauses collection, and deleting it removes the configuration.

Sampling, aggregation and cost

Flow log charges are listed under Google Cloud Network Telemetry pricing and are billed to the project containing the reporting resource; storage and any export destination (BigQuery, Cloud Storage) are charged separately. Prices change, so model cost from the current pricing page and a week of real volume from a pilot subnet rather than estimates.

Subnet profileSuggested starting settingsReasoning
Internet-facing and DMZ subnets5 sec interval, sampling 1.0, all metadataHighest detection value; location metadata supports egress and geography rules
Crown-jewel data and admin subnets5 or 30 sec interval, sampling 1.0, custom metadata (instance, VPC, location)East-west visibility for lateral movement around sensitive systems
General workload subnets30 sec to 1 min interval, sampling 0.5, custom metadataTrend and investigation data at lower volume
High-volume batch or analytics subnets5 to 15 min interval, low sampling, filter out known bulk flows to Google servicesKeeps visibility of unexpected destinations without logging bulk transfers

Filters are the sharpest cost tool, but every filter is a blind spot. Prefer filtering known-good, high-volume flows (for example internal backups to a known range) over filtering by direction or protocol, and record each filter with an owner and review date. Note that rtt_msec, bytes_sent, packets_sent, start_time and end_time cannot be used in filter expressions.

Fields and metadata

Base fields are always included; metadata fields depend on the metadata setting. Google notes that metadata values are approximations and may be missing or incorrect, so detections should key on IPs and ports and use metadata for context.

FieldTypeDetection use
connection.src_ip, dest_ip, src_port, dest_port, protocolBase5-tuple for every rule; protocol is the IANA number (6 TCP, 17 UDP)
connection.nat_ip, nat_portBase (Cloud NAT, reporter SRC)Map an internal VM to its public NAT address when matching external threat intelligence
reporterBaseSRC, DEST, SRC_GATEWAY or DEST_GATEWAY; deduplicate flows seen at both ends
bytes_sent, packets_sent, rtt_msec, start_time, end_timeBaseVolume and timing for exfiltration and beaconing analysis (estimates)
disposition, drop_reasonBase (dropped records)Blocked egress attempts and spoofing signals
src_instance, dest_instance, src_vpc, dest_vpcMetadataName the VM, project, VPC and subnet behind an IP
src_gke_details, dest_gke_detailsMetadataCluster, pod and service context for container traffic
src_location, dest_locationMetadataGeography of public endpoints outside the VPC
src_google_service, dest_google_serviceMetadataSeparate traffic to Google APIs from internet traffic
internet_routing_details.egress_as_pathMetadata (egress only)Autonomous system path for outbound internet flows

In Logs Explorer, Network Management API logs use logName="projects/PROJECT_ID/logs/networkmanagement.googleapis.com%2Fvpc_flows" with resource.type="vpc_flow_logs_config", and Compute Engine API logs use compute.googleapis.com%2Fvpc_flows with resource.type="gce_subnetwork". Queries reference fields under jsonPayload, for example jsonPayload.connection.dest_port=22. Detections that span both APIs must match both log names.

Detection use cases

Each use case below lists the signal, the fields and the ATT&CK technique it supports. Start with the first three; they give the best return for the least tuning.

Use caseSignal in flow logsATT&CK
Egress to unusual destinationsFirst-seen external dest_ip or AS for a VM or service, or a new dest_location countryT1071 Application Layer Protocol
Large or sustained outbound transferSum of bytes_sent per VM to one external IP well above its baselineT1048 Exfiltration Over Alternative Protocol, T1041 Exfiltration Over C2 Channel
Exposed management portsInbound flows from public sources to dest_port 22, 3389, database or Kubernetes API portsT1021 Remote Services
Lateral movement across tiersEast-west flows between subnets or VPCs that the segmentation design says should not talk, especially SSH, RDP, SMB (445) and WinRM (5985, 5986)T1021 Remote Services
Internal scanningOne source contacting many destination IPs or ports in a short window, often with many FIREWALL_DENY dropsT1046 Network Service Discovery
Regular beaconingRepeated small flows to one external host at fixed intervals, best with the 5 second aggregation intervalT1071 Application Layer Protocol
Traffic on unexpected portsWell-known protocols to external hosts on non-standard portsT1571 Non-Standard Port
Cryptomining connectionsConnections to mining pool infrastructure; Security Command Center Event Threat Detection lists VPC flow logs as a source for its Cryptomining Bad IP findingT1496 Resource Hijacking

Practical notes for building these:

  • Use filter examples as hunting seeds: Google's documented expression !(has(src_vpc.vpc_name) && has(dest_vpc.vpc_name)) isolates traffic with an endpoint outside your VPC networks, which is the population for every egress rule.
  • Allow-list Google services and known partners: use dest_google_service and a maintained list of SaaS and partner ranges so egress rules fire on the unknown, not the expected.
  • Resolve identity behind the flow: a VM IP leads to its attached service account. Correlate suspicious flows with Data Access audit logs for that service account to see what it touched. See the Google Cloud IAM and Service Accounts Guide.
  • Use managed detections as a floor: Event Threat Detection uses VPC flow logs, Firewall Rules logs and Cloud NAT logs for its Malware: bad IP, Cryptomining Bad IP and Log4j Malware: Bad IP findings. Custom rules cover what threat intelligence matching cannot, such as segmentation breaks.
  • Validate segmentation continuously: flow logs show whether firewall policies in the Google Cloud VPC and Cloud NGFW Security Guide behave as designed, and egress rules complement Cloud Egress Filtering.

Routing to SIEM and BigQuery

Cloud Logging keeps flow logs for 30 days by default. For hunting and incident response you need longer, queryable history, delivered through log sinks. A sink has one inclusion filter and optional exclusion filters, and can route to a log bucket, a BigQuery dataset, a Cloud Storage bucket, a Pub/Sub topic (for third-party SIEM ingestion) or another Google Cloud project. Aggregated sinks at organisation or folder level route entries from all child resources.

  1. Pilot: enable the Network Management API configuration on two or three representative subnets with default settings, measure daily volume for a week and confirm the queries above return data.
  2. Decide destinations: BigQuery for SQL hunting and baselines, Pub/Sub for a SIEM, Cloud Storage for low-cost long retention. Keep the security copy in a separate logging project with restricted IAM.
  3. Create an aggregated sink: at folder or organisation level with an inclusion filter on both vpc_flows log names, so new projects are covered automatically.
  4. Tune per subnet profile: apply the profile table, starting high and reducing sampling or metadata only where volume is high and detection value is low.
  5. Roll out by environment: production internet-facing first, then data and admin subnets, then general workloads. Track coverage as a metric.
  6. Test detections: generate known traffic (a connection from a test VM to an approved external test host, a blocked connection between tiers) and confirm the record arrives and the rule fires.
  7. Roll back safely: if cost spikes, raise the aggregation interval or lower sampling on the noisy subnet rather than disabling it; disabling leaves an investigation gap.

Avoid excluding flow logs in the _Default sink before the security sink is proven, otherwise records can be lost from both paths. Partitioned BigQuery tables and scheduled queries that build daily per-VM egress baselines keep hunting costs predictable; see the BigQuery Security Guide for protecting the dataset itself.

Measuring coverage and effectiveness

  • Coverage: percentage of production subnets, VLAN attachments and VPN tunnels with an active flow log configuration.
  • Freshness: median delay between flow end time and arrival in the SIEM or BigQuery.
  • Retention met: days of queryable flow history against the policy target.
  • Detection health: number of flow-based rules with a passing test in the last 90 days.
  • Signal quality: share of flow-based alerts closed as true positive or useful, reviewed monthly.
  • Cost per covered subnet: monthly flow log and storage cost by subnet profile, to justify tuning.

Framework mapping

FrameworkReferenceHow flow logs support it
NIST CSF 2.0DE.CM-01, DE.AE-02Network monitoring and analysis of adverse events
NIST SP 800-53 Rev 5AU-12, AU-11, AU-6, SI-4Record generation, retention, review and system monitoring
CIS Controls v8.1Safeguard 13.6 Collect Network Traffic Flow LogsDirect requirement for flow log collection on network devices
ISO/IEC 27001:2022 Annex AA.8.15 Logging, A.8.16 Monitoring activitiesProduce, keep and review network activity records

Common failure patterns

  • Enabled but never queried: flow logs sit in the _Default bucket for 30 days and expire before anyone needs them. Route them and build at least the egress and exposed-port rules.
  • Treating sampled counts as exact: bytes_sent is an estimate from sampled packets, so thresholds for exfiltration must allow for error and use baselines, not absolute numbers.
  • Coverage drift: new subnets, VPN tunnels and VLAN attachments appear without flow logs. Use organisation-level configuration or infrastructure-as-code defaults and alert on gaps.
  • Over-filtering for cost: filters that keep only ingress or only external traffic remove the east-west records needed to trace lateral movement.
  • Missing denied inbound traffic: firewall-denied ingress is not sampled, so scans against a well-protected perimeter are invisible without Firewall Rules Logging.
  • One API in the query: mixed estates write both networkmanagement.googleapis.com and compute.googleapis.com log names, and rules that match only one silently miss half the traffic.

Practitioner checklist

  • Use the Network Management API for new configurations and record the chosen settings in infrastructure as code.
  • Enable flow logs on every production subnet, VLAN attachment and Cloud VPN tunnel, starting with internet-facing subnets.
  • Turn on Firewall Rules Logging alongside flow logs and enable GKE intranode visibility where pod traffic matters.
  • Set aggregation, sampling, metadata and filters per subnet profile, with an owner and review date for each filter.
  • Create an aggregated sink to a dedicated logging project with retention that meets policy, matching both vpc_flows log names.
  • Build and test rules for unusual egress, exposed management ports, cross-tier east-west traffic and internal scanning.
  • Correlate flow alerts with service account activity in audit logs during triage.
  • Report coverage, freshness, retention and detection test results monthly.

Standards and references

Related NHI Mgmt Group resources: Google Cloud Audit Logs and Log Sinks Guide · Google Cloud VPC and Cloud NGFW Security Guide · VPC Service Controls Guide · Google Cloud Security Guide

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.