For the complete documentation index, see llms.txt. This page is also available as Markdown.

Google Cloud

OneLens analyses your Google Cloud VPC flow logs to show which VMs, GKE nodes and workloads send traffic where, and what it costs: Cloud NAT, internet egress, cross-zone and cross-region transfer. You choose the date range (up to 30 days) and OneLens analyses it once, from flow-log files you export to a Cloud Storage bucket you own.

Setup takes about 15 minutes, plus a few hours for the first files to arrive.

How it works

1

VPC Flow Logs record traffic

VPC Flow Logs record the traffic of the subnets or VPC networks you choose.

2

Route logs to Cloud Storage

A Cloud Logging sink writes the logs to a Cloud Storage bucket in your project, as hourly files.

3

Grant OneLens access

You grant the OneLens Reader service account read access to that bucket. This is the service account created when you onboarded OneLens.

4

Request an analysis

You request an analysis in OneLens for a date range. OneLens checks it can read the bucket, then analyses the files in its nightly processing window.

5

View results

Results appear under Optimize → Deep Insights → VPC Flow Analysis.

OneLens can only analyse days for which flow logs were enabled and their files are still in the bucket. Turn on flow logs before the period you want to analyse.

Before you start

  • Google Cloud is connected to OneLens. Follow Connecting to GCP first. That setup creates the OneLens Reader service account and the roles OneLens needs to identify VMs, GKE nodes and Cloud NAT.

  • Estimate the cost first. Google charges for flow-log generation per GiB (see Costs). Google's Network Telemetry pricing page links a VPC Flow Logs cost estimator that gives a monthly estimate per project or subnet before you enable anything.

Required roles

Role
Where
Used for

Network Management Admin (roles/networkmanagement.admin)

Projects with the subnets or networks to log

Step 3, turning on flow logs

Logs Configuration Writer (roles/logging.configWriter)

The project (or organisation) that routes the logs

Step 2, the log sink and exclusion

Storage Admin (roles/storage.admin)

The bucket's project

Steps 1, 2 and 4: the bucket and its permissions

Role Administrator (roles/iam.roleAdmin)

The bucket's project

Step 4, the custom role for OneLens

Set it up

1

Create a bucket for the flow logs

Use a bucket that holds only flow logs. Granting OneLens read access to it then gives access to the flow logs and nothing else.

gcloud storage buckets create gs://BUCKET_NAME \
  --project=PROJECT_ID \
  --location=asia-south1 \
  --uniform-bucket-level-access

Create the bucket in asia-south1 (Mumbai), the region OneLens reads your files from. Reads within the same region are free. A bucket in another region, or in a multi-region location, costs your project Google's data-transfer rate for the files OneLens reads: about the size of the flow logs for the dates you analyse.

Optional: to keep storage costs down, add a lifecycle rule that deletes files after a set number of days. Keep files at least as long as the longest period you want to analyse.

2

Route the flow logs to the bucket

Create a log sink that sends VPC flow logs to the bucket, and let the sink write to it:

gcloud logging sinks create onelens-vpc-flow-logs storage.googleapis.com/BUCKET_NAME \
  --project=PROJECT_ID \
  --log-filter='resource.type="vpc_flow_logs_config" AND logName:"networkmanagement.googleapis.com%2Fvpc_flows"'

gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME \
  --member="$(gcloud logging sinks describe onelens-vpc-flow-logs --project=PROJECT_ID --format='value(writerIdentity)')" \
  --role=roles/storage.objectCreator

Optional: keep the logs out of your _Default Cloud Logging bucket so they are stored only in your bucket:

gcloud logging sinks update _Default --project=PROJECT_ID \
  --add-exclusion='name=exclude-vpc-flow-logs,filter=resource.type="vpc_flow_logs_config" AND logName:"networkmanagement.googleapis.com%2Fvpc_flows"'

Google charges for flow-log generation whether or not the logs are kept in Cloud Logging. The exclusion only stops a second copy being stored there.

Logging several projects? Create the sink once at organisation level instead, with --organization=ORGANIZATION_ID --include-children in place of --project, and add the exclusion in each project.

3

Turn on VPC flow logs

Create a flow-log configuration for each subnet you want to analyse:

gcloud network-management vpc-flow-logs-configs create onelens-SUBNET_NAME \
  --project=PROJECT_ID \
  --location=global \
  --subnet=projects/PROJECT_ID/regions/REGION/subnetworks/SUBNET_NAME \
  --aggregation-interval=interval-15-min \
  --flow-sampling=1.0 \
  --metadata=include-all-metadata

To cover a whole VPC network instead, replace --subnet=… with --network=projects/PROJECT_ID/global/networks/NETWORK_NAME.

Setting
Use
Why

--aggregation-interval

interval-15-min

OneLens analyses traffic per day. A longer interval writes fewer log records, which lowers the log-generation cost. Google's default is 5 seconds.

--flow-sampling

1.0

OneLens uses the volumes as logged and does not scale them up, so a lower rate under-reports traffic and cost.

--metadata

include-all-metadata

Adds the GKE pod, workload, Google service and location details that OneLens uses to name traffic.

You don't need to turn on GKE intranode visibility.

4

Give OneLens read access to the bucket

Give the OneLens Reader service account read access to the bucket's files, and nothing more: create a role with only the two permissions OneLens uses (listing and reading files), then grant it on the bucket. The Reader service account is the one you created when you connected Google Cloud to OneLens; you'll find it in IAM in your billing-export project.

gcloud iam roles create onelensFlowLogReader \
  --project=PROJECT_ID \
  --title="OneLens Flow Log Reader" \
  --description="Lists and reads VPC flow-log files for OneLens" \
  --permissions=storage.objects.list,storage.objects.get \
  --stage=GA

gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME \
  --member=serviceAccount:READER_SERVICE_ACCOUNT_EMAIL \
  --role=projects/PROJECT_ID/roles/onelensFlowLogReader

Grant it on the bucket, not the project, so OneLens can read this bucket only.

To tell Cloud NAT traffic from direct internet traffic, OneLens also uses the Compute Viewer, Kubernetes Engine Viewer and Monitoring Viewer roles that standard onboarding grants the Reader service account. If your onboarding left them out, the analysis still completes, but Cloud NAT cost may be understated and the request shows a note saying so.

5

Check that files arrive

The first files appear one to three hours after you turn on flow logs. Each hour is written as one or more files under networkmanagement.googleapis.com/vpc_flows/YYYY/MM/DD/.

gcloud storage ls -r gs://BUCKET_NAME/networkmanagement.googleapis.com/vpc_flows/ | tail -3
6

Request an analysis in OneLens

In Optimize → Deep Insights → VPC Flow Analysis → Flow logs, select Add Flow Log, choose Google Cloud, and enter:

Field
Value

Project

The project whose flow logs you exported

Bucket

BUCKET_NAME, the name only, without gs://

Folder prefix

Leave empty for a log sink. Only set it if the files sit under a folder in the bucket.

Log type

VPC Flow Logs (networkmanagement.googleapis.com/vpc_flows)

Dates

Up to 15 days, ending yesterday or earlier

OneLens checks that it can read the bucket when you submit. If it can't, it tells you what to fix and saves nothing. Accepted requests are analysed in OneLens's nightly processing window, so results are usually ready within a day.

How OneLens reads your logs

  • Who reads: your OneLens Reader service account. OneLens acts as it through the service-account impersonation you allowed when connecting Google Cloud. No keys are created.

  • What it reads: only the files for the dates you request, under the flow-log folder of the bucket you name. Nothing is written to your bucket.

  • How: each file is read through a signed URL that the Reader service account creates and that expires after 35 minutes. If you turn on Cloud Storage Data Access audit logs, these reads appear there under the Reader service account.

  • What OneLens keeps: traffic and cost totals per day by resource, route and destination. It doesn't keep a copy of your log files or GKE pod IP addresses.

Costs

Charge
Billed to
Rate

Flow-log generation

The project that owns the logged subnets

$0.25 per GiB for the first 10 TiB a month per billing account, then $0.15, $0.075 and $0.05 per GiB at higher volumes (Google pricing). It applies even if the logs are excluded from Cloud Logging.

Cloud Storage

The bucket's project

Your bucket's storage class and region (pricing)

OneLens reading the files

The bucket's project

Read operations cost fractions of a cent per analysis. Data transfer is added if the bucket isn't in asia-south1 (see step 1).

For scale: a production GKE cluster in OneLens's own environment produced about 240 GiB of flow logs a day at 15-minute aggregation, about $60 a day in log generation.

Turn it off

Stopping the flow logs stops the generation charge. Keep the bucket for as long as you want to analyse past dates.

Troubleshooting

Message
What to do

OneLens can't read gs://…

Check the bucket name, then complete step 4: grant the OneLens Reader service account the OneLens Flow Log Reader role on the bucket

No flow-log files under gs://…

Check the folder prefix and log type. Files appear one to three hours after flow logs are turned on.

No active GCP billing account is onboarded for this tenant

Connect Google Cloud to OneLens first.

No flow-log files for <start>..<end> in the export bucket.

Flow logs weren't on for those dates, or the files were deleted. Choose dates that have files.

… GiB of flow logs is above the 3,072 GiB limit for one request; choose a shorter date range.

Request a shorter period.

No OneLens Reader service account found for GCP project …

The project isn't under a billing account connected to OneLens. Check the project ID, or connect its billing account.

Completed, but some route checks were refused, so Cloud NAT cost may be understated …

Grant the Reader service account Compute Viewer, Kubernetes Engine Viewer and Monitoring Viewer on the projects with the logged VMs and clusters, then request the analysis again.

Unexpected error while analysing the flow logs …

Submit the request again. Contact OneLens support if it fails again.

Last updated