GCP VPC Flow Logs via Pub/Sub Setup
Netography Fusion ingests VPC flow logs from Google Cloud Platform (GCP) via a GCP Pub/Sub subscription. The steps to integrate with GCP are:
Enable VPC flow logs
Create a Pub/Sub topic
Create a Cloud Logging Sink Pub/Sub for the topic
Create a Pub/Sub Pull Subscription to the topic
Add Netography's GCP service account as a principal for the Pub/Sub subscription
In Fusion, Add GCP as a new flow source.
👍You can onboard an entire GCP organization or folder by following these steps one time
You only need to create 1 GCP Pub/Sub topic, 1 GCP Cloud aggregated Logging Sink, 1 GCP Pub/Sub Subscription, and 1 Fusion GCP flow source to onboard GCP VPC flow logs to Fusion for as many VPC, subnets, projects, and sub-folders you have in your GCP organization or in a single folder in your GCP organization. If you need more granular control over what enabled VPC flow logs should be routed to Netography, you can create 1 GCP Pub/Sub topic, 1 GCP Pub/Sub Subscription, 1 Fusion GCP flow source, and as many Cloud Logging Sinks as you need all routed to the one topic.
Additional information on using a aggregated logging sink and its benefits and limitations are described in step 3 below.
In addition to ingesting VPC flow logs, you may want to enrich them with context from GCP resources by adding the GCP Context Integration
Prerequisites
If you have GCP organization policy constraints in place, you may be unable to perform these steps until you update the organizational policies. If you receive an error referring to an organization policy, update the policy and retry. Updating an organization policy requires the Organization Policy Administrator role (
roles/orgpolicy.policyAdmin).You need sufficient permissions in GCP to perform each step. The GCP documentation referenced in each step details the roles and permissions associated with that action.
GCP Setup
1. Enable VPC flow logs
You can skip this step if you already have VPC flow logs enabled for the networks to monitor.
Follow these steps using the configuration settings below: GCP: Enable VPC Flow Logs when you create a subnet
Additional instructions for enabling GCP VPC flow logs are available at GCP: Use VPC Flow Logs.
You can create filters in GCP to limit what traffic flow logs are generated for if you do not want to generate flow logs for all traffic. To only include traffic that is external to a VPC, use the filter expression '!(has(src_vpc.vpc_name) && has(dest_vpc.vpc_name))'.
Flow Log Configuration
Aggregation Interval
1 minute
Sample Rate
100
Include Metadata
Yes
Option 1. Enabling VPC Flow Logs at the Subnet Level
On the Subnets in current project tab, select one or more subnets and then click Manage flow logs.
In Manage flow logs, click Add new configuration. This will configure a new VPC flow log configuration.
Do one of the following:
If you selected one subnet, in the Configurations — Subnets section, click Add a configuration.
If you selected multiple subnets, in the Configure VPC Flow Logs section, select Network Management API.
For Name, enter a name for the new VPC Flow Logs configuration.
Change the Aggregation Interval to
1 minute.Optional: Adjust the Description and any of the settings in the Advanced settings section:
Log filtering: By default, Keep only logs that match a filter is deselected.
Include metadata in the final log entries: By default, Metadata annotations includes all fields.
Secondary sampling rate:
100%means that all entries generated by the primary flow log sampling process are kept.
Click Save.
Option 2. Enabling VPC Flow Logs for VPC Networks
On the Networks in current project tab, select one or more networks and then click Manage flow logs.
In Manage flow logs, click Add new configuration. This will configure a new VPC flow log configuration.
In the popup window, under Configurations - VPC networks click on Add a configuration.
For Name, enter a name for the new VPC Flow Logs configuration.
Change the Aggregation Interval to
1 minute.Optional: Adjust the Description and any of the settings in the Advanced settings section:
Log filtering: By default, Keep only logs that match a filter is deselected.
Include metadata in the final log entries: By default, Metadata annotations includes all fields.
Secondary sampling rate:
100%means that all entries generated by the primary flow log sampling process are kept.
Click Save.
Option 3. Configuring VPC Flow Logs at the Organization Level
Configurations created at an organizational level will apply to all VPCs within that organization.
Navigate to the VPC Flow Logs configuration page.
Click Add VPC Flow Logs configuration and then click Add a configuration for the organization.
For Name, enter a name for the new VPC Flow Logs configuration.
Change the Aggregation Interval to
1 minute.Optional: Adjust the Description and any of the settings in the Advanced settings section:
Optional: Adjust the Description and any of the settings in the Advanced settings section:
Log filtering: By default, Keep only logs that match a filter is deselected.
Include metadata in the final log entries: By default, Metadata annotations includes all fields.
Secondary sampling rate:
100%means that all entries generated by the primary flow log sampling process are kept.
Click Save.
2. Create a Cloud Pub/Sub topic
Create a Cloud Pub/Sub topic to publish flow logs to. If you are onboarding an individual GCP project, you can create the topic as part of creating the sink in step 3. If you are onboarding multiple projects at an organization or folder level, you can create a single topic in a designated project that you will use for centralized logging resources, and then use this one topic as the destination for a single aggregated sink, multiple individual project Cloud Logging Sinks, or a combination of the two.
To separately create the topic, follow these steps using the configuration settings below: GCP: Create a Topic
Pub/Sub Topic Configuration
Topic ID
Any value ( e.g. neto-flowlogs-pubsub-topic)
Add a default subscription
No
Use a schema
No
Enable ingestion
No
Enable message retention
Yes- 1 Day
Note: GCP charges for unacknowledged message retention over 1 day. In most circumstances, the messages will be acknowledged and removed from the topic in real-time, but retention will ensure there is no data lost unless the logs are not read in that time period. You can adjust the retention period based on your organization's requirements.
GCP Console Steps
Go to the Pub/Sub Topics page in the Google Cloud console.
Click Create Topic.
Fill out the form using the above configuration values, then click Save.
3. Create a Cloud Logging Sink Pub/Sub
Create a Cloud Logging Sink with a destination of Cloud Pub/Sub topic, using the topic you created in step 2 or creating the topic in the process.
Follow these steps using the configuration settings below: GCP: Create a sink.
Cloud Logging Sink Configuration
Sink name
Any value ( e.g. neto-flowlogs-sink)
Sink description
Any value (e.g. Netography Fusion flow log ingest)
Sink destination service type
Cloud Pub/Sub topic
Sink destination Cloud Pub/Sub topic
Create a topic or use topic created in previous step
Inclusion filter
resource.type="gce_subnetwork" AND log_id("compute.googleapis.com/vpc_flows")
Enable message retention
Yes- 1 Day
Inclusion Filter
The inclusion filterresource.type="gce_subnetwork" will include all VPC flow logs in the sink. You can add filters using inclusion or exclusion based on your desired configuration. For example, to only publish to the sink VPC flow logs that are ingress/exgress a VPC (excluding internal intra-VPC traffic), the inclusion filter would be:
resource.type="gce_subnetwork"and NOT ( jsonPayload.src_vpc.vpc_name:_ AND jsonPayload.dest_vpc.vpc_name:_ )
Adding this filter at the sink will still generate the VPC flow logs for intra-VPC traffic but will not deliver those logs to Fusion (this may be useful if you are using intra-VPC flow logs for other purposes). To filter which VPC flow logs are generated, set the filter in the VPC flow log configuration instead of at the sink (see GCP: Filtering VPC flow logs).
GCP Console Steps
Go to the Log Router page in the Google Cloud console.
Select the project (or folder or organization if using an aggregated sink) to create the sink in.
Click Create sink.
Fill out the form using the above configuration values, then click Save
4. Create a Pub/Sub Pull Subscription to the topic
Follow these steps using the configuration settings below: GCP: Create a pull subscription.
Pub/Sub Subscription Configuration
Subscription ID
Any value ( e.g. neto-flowlogs-sub)
Cloud Pub/Sub Topic
Topic ID from previous steps (if creating from Subscriptions page)
Delivery Type
Pull
Message retention duration
1 Day (or based on your requirements)
Retry policy
Retry after exponential backoff delay (Default min/max values)
Default values for all other fields can be used.
GCP Console Steps
Go to the Topics page in the Google Cloud console.
Click ⋮ next to the topic you created in previous step.
From the context menu, select Create Subscription.
Fill out the form using the above configuration values, then click Save.
Note: Alternatively, you can create a subscription from the Subscriptions page by entering the Topic ID from the previous step.
5. Add Netography's GCP service account as a principal to the Pub/Sub subscription
To grant Netography access to read logs from the Pub/Sub subscription, add the Netography GCP service account as a new principal in the subscription.
Follow these steps to add a principal to the subscription: GCP: Access Control for Pub/Sub > Controlling access through the Google Cloud Console
Pub/Sub Subscription Principal Configuration
Principal
Role
Pub/Sub Subscribe
GCP Console Steps
Go to the Subscriptions page in the Google Cloud console in the Pub/Sub section.
Select the subscription you created in the previous step to bring up the subscription info panel on right.
Select Add Principal in the info panel for the subscription.
Fill out the form using the above configuration values, then click Save.
Netography Fusion Setup
6. Add a new GCP flow source to Fusion
In the Fusion portal, click the gear icon to go to Settings, navigate to Traffic Sources, click Add Traffic Source, select GCP, and fill out the form using the configuration below.
GCP Flow Source Configuration
The following fields are specific to the GCP configuration.
Project ID
yes
GCP Project ID containing the Pub/Sub subscription
Subscription ID
yes
GCP Pub/Sub Subscription ID
Sample Percentage
yes
GCP Flow Log Sampling Percentage
The Sample Percentage field is only used for display purposes and does not need to be set to the same value as the value configured in GCP for the flow logs. If you are using multiple sampling percentages, you can use 100 as the value for this field.
Last updated