VPC Flow Logs (original) (raw)

VPC Flow Logs samples packets in your Virtual Private Cloud (VPC) network to generate flow logs. Flow logs are aggregated by IP connection (5-tuple). VPC Flow Logs samples the following packets:

You can view flow logs in Cloud Logging, and you can export logs to any destination that Cloud Logging export supports. These logs can be used for network monitoring, forensics, security analysis, and expense optimization. For more information, seeSupported configurations.

Use cases

The following are use cases for VPC Flow Logs.

Network monitoring

VPC Flow Logs provides you with visibility into network throughput and performance. You can:

Understanding network usage and optimizing network traffic expenses

You can analyze network usage with VPC Flow Logs to optimize network traffic expenses. For example, you can analyze the network flows for the following:

Network forensics

You can use VPC Flow Logs for network forensics. For example, if an incident occurs, you can examine the following:

Learn how Google Cloud users strengthen their cyber defense with VPC Flow Logs.

Supported configurations

You can enable VPC Flow Logs at the organization and project levels. An organization-level VPC Flow Logs configuration enables flow logs for all subnets, VLAN attachments, and Cloud VPN tunnels in all VPC networks in the organization.

At the project level, you can enable VPC Flow Logs for specific VPC networks, subnets, VLAN attachments, and Cloud VPN tunnels.

Configuration scope Generates flow logs for these resources Steps to enable
Organization All VM instances and Cloud Run resources in all subnets in the organization All VLAN attachments in the organization All Cloud VPN tunnels in the organization Enable VPC Flow Logs for an organization
VPC network All VM instances and Cloud Run resources in all subnets in the VPC network All VLAN attachments in the VPC network All Cloud VPN tunnels in the VPC network Enable VPC Flow Logs for a VPC network
Subnet All VM instances and Cloud Run resources in a specific subnet Enable VPC Flow Logs for a subnet: Recommended: Enable VPC Flow Logs for a subnet (Network Management API) Enable VPC Flow Logs for a subnet (Compute Engine API)
VLAN attachment A specific VLAN attachment Enable VPC Flow Logs for a VLAN attachment
Cloud VPN tunnel A specific Cloud VPN tunnel Enable VPC Flow Logs for a Cloud VPN tunnel

You can use filtering to customize these configuration scopes. For more information, see Log sampling and processing.

Logs collection

Packets are sampled within an aggregation interval. All packets collected for a given IP connection within the aggregation interval are aggregated into a single flow log entry. This data is then sent toLogging in the Google Cloud project of the VPC network that reported the flow.

Logs are stored in Logging for 30 days by default. If you want to keep logs longer than that, you can either set a custom retention period orexport them to a supported destination.

Log sampling and processing

To generate flow logs, VPC Flow Logs samples packets in your VPC network, including packets that are sent from and received by VMs and serverless endpoints and packets that pass through gateways such as VLAN attachments or Cloud VPN tunnels. After the flow logs are generated, VPC Flow Logs processes them by following the procedure described in this section.

VPC Flow Logs samples packets using a primary sampling rate. The primary sampling rate is dynamic and varies depending on the load of the physical host running the reporting resource at the time of sampling. The probability of sampling any single IP connection increases with the volume of packets. You can't control the primary flow log sampling process or adjust the primary sampling rate.

After the flow logs are generated, VPC Flow Logs processes them according to the following procedure:

  1. Filtering. You can specify that only logs that match specified criteria are generated. For example, you can filter so that only logs for a particular VM or only logs with a particular metadata value are generated and the rest are discarded. For more information, seeLog filtering.
  2. Aggregation. Information for sampled packets is aggregated over a configurable aggregation interval to produce a flow log entry.
  3. Secondary flow log sampling. This is a second sampling process. Flow log entries are further sampled according to a configurable secondary sampling rate parameter. The secondary sampling is performed on the flow logs generated by the primary flow log sampling process. For example, if the secondary sampling rate is set to 1.0, or 100%, VPC Flow Logs samples 100% of the flow logs generated by the primary flow log sampling.
  4. Metadata. If disabled, all metadata annotations are discarded. If you want to keep metadata, you can retain all fields or a specific set of fields. For more information, see Metadata annotations.
  5. Write to Logging. The final log entries are written to Cloud Logging.

Because VPC Flow Logs doesn't capture every packet, it compensates for missed packets by interpolating from the captured packets. This happens for packets missed because of initial and user-configurable sampling settings.

Even though Google Cloud doesn't capture every packet, log record captures can be quite large. You can balance your traffic visibility and storage cost needs by adjusting the following aspects of logs collection:

Specifications

Pricing and billing

Standard pricing for Logging, BigQuery, or Pub/Sub apply. VPC Flow Logs pricing is described inNetwork Telemetry pricing.

VPC Flow Logs charges are billed to the Google Cloud project of the resource that reports flow logs. If VPC Flow Logs is enabled for an organization, each project is billed separately.

What's next