Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create the custom network
/ 10
Create a subnet with VPC Flow Logs enabled
/ 15
Create the firewall rule in the custom network
/ 10
Create the web server in the custom network
/ 15
Install Apache in web server
/ 15
Export the network traffic to BigQuery
/ 20
Configure VPC flow log aggregation
/ 15
Create the custom network
/ 10
Create a subnet with VPC Flow Logs enabled
/ 15
Create the firewall rule in the custom network
/ 10
Create the web server in the custom network
/ 15
Install Apache in web server
/ 15
Export the network traffic to BigQuery
/ 20
Configure VPC flow log aggregation
/ 15
VPC Flow Logs records a sample of network flows sent from and received by VM instances, including instances used as GKE nodes. You can use these logs for network monitoring, forensics, real-time security analysis, and expense optimization.
In this lab, you configure a custom VPC network to record traffic to and from an Apache web server using VPC Flow Logs. You verify the flow logs in Cloud Logging, export the logs to BigQuery for SQL analysis, and adjust flow log aggregation and sampling settings to manage log volume.
There are multiple use cases for VPC Flow Logs. For example, you can determine where users access your applications from to optimize network traffic expense, create HTTP Load Balancers to balance traffic globally, or denylist unwanted IP addresses with Cloud Armor.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:
Note that the lab timer is located near the top of the page, showing the remaining time.
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab setup and access panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab setup and access panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
By default, Google Cloud disables VPC Flow Logs for a network. Therefore, you create a new custom-mode network and enable VPC Flow Logs on its subnet.
In the Google Cloud console, on the Navigation menu (), click VPC network > VPC networks.
Click Create VPC network.
For Name, type vpc-net, and add an optional description if you want.
For Subnet creation mode, select Custom.
Under New subnet, specify the following values, and leave the remaining settings as their defaults:
| Property | Value |
|---|---|
| Name | vpc-subnet |
| Region | |
| IPv4 range | 10.1.3.0/24 |
| Flow logs | On |
Click Check my progress to verify the objectives.
To allow HTTP and SSH traffic on the custom network, create a firewall rule.
In the Google Cloud console, on the Navigation menu (), click VPC network > Firewall.
Click Create firewall rule.
Specify the following values, and leave the remaining settings as their defaults:
| Property | Value |
|---|---|
| Name | allow-http-ssh |
| Network | vpc-net |
| Targets | Specified target tags |
| Target tags | http-server |
| Source filter | IPv4 ranges |
| Source IPv4 ranges | 0.0.0.0/0 |
| Protocols and ports | Select Specified protocols and ports, select the TCP checkbox, and type 80, 22 |
/0 in Source IPv4 ranges to allow traffic from all IPv4 networks.Click Check my progress to verify the objective.
In the Google Cloud console, on the Navigation menu (), click Compute Engine > VM instances.
Click Create instance.
In the Machine configuration section, specify the following values, and leave the remaining settings as their defaults:
| Property | Value |
|---|---|
| Name | web-server |
| Region | |
| Zone | |
| Series | E2 |
| Machine type | e2-micro (2 vCPU, 1 GB memory) |
In the instance navigation pane, click Networking.
Under Firewall, select Allow HTTP traffic.
Under Network interfaces, click default to edit the interface, specify the following values, and then click Done:
| Property | Value |
|---|---|
| Network | vpc-net |
| Subnetwork | vpc-subnet |
Click Create to launch your virtual machine instance.
Wait a couple of minutes until a status checkmark indicates that the instance is running.
Click Check my progress to verify the objective.
Configure the VM instance as an Apache web server and overwrite the default webpage.
On the VM instances page, in the row for web-server, click SSH to launch a terminal and connect.
In the web-server SSH terminal, update the package index:
apache2 package:Click Check my progress to verify the objective.
On the VM instances page (Navigation menu () > Compute Engine > VM instances), copy the External IP address for web-server.
Open a new browser tab and navigate to http://EXTERNAL_IP, replacing EXTERNAL_IP with the address you copied.
http:// (not https://), because Apache listens on HTTP port 80. The Hello World! welcome page that you configured opens.Determine the public IPv4 address of the computer you are using so you can filter for your own requests in Cloud Logging.
Open the AWS IPv4 Check service in a new browser tab to display your public IPv4 address.
Copy your IPv4 address. The instructions refer to this value as YOUR_IP_ADDRESS.
In the Google Cloud console, on the Navigation menu (), click View All Products > Observability > Logging > Logs Explorer.
Click All resources, select Subnetwork, and then click Apply.
Click All log names, select vpc_flows (under compute.googleapis.com), and then click Apply.
In the Query editor, append "YOUR_IP_ADDRESS" (replacing YOUR_IP_ADDRESS with your copied IPv4 address) on a new line, and then click Run query.
Click one of the log entries to expand it.
Expand jsonPayload and then connection (or click Expand all in the entry header).
connection object records the destination IP address and port, the source IP address and port, and the IP protocol number. Depending on traffic direction, either the source or destination is web-server and the other is your workstation. The protocol value is 6 (IANA protocol number for TCP). One port is 80 (HTTP on web-server) and the other is an ephemeral port greater than 1024 on your workstation.Explore other fields in the log entry before moving to the next task.
Create a Log Router sink that routes all VPC Flow Logs from your subnetwork to a BigQuery dataset without filtering by your workstation IP address.
In Logs Explorer, clear the Query editor so that your workstation IP address is no longer in the filter.
Click All resources, select Subnetwork, and then click Apply.
Click All log names, select vpc_flows, and then click Apply.
Click Run query to verify that the query filters only by resource.type="gce_subnetwork" and logName="projects/.../logs/compute.googleapis.com%2Fvpc_flows".
Click Actions > Create sink.
For Sink name, type vpc-flows, and then click Next.
For Select sink service, select BigQuery dataset.
For Select BigQuery dataset, select Create new BigQuery dataset.
For Dataset ID, type bq_vpc_flows, and then click Create dataset.
Click Create sink.
The Log Router page opens and lists the vpc-flows sink. If you do not see the sink immediately, click Log Router in the Logging navigation menu.
Now that Log Router exports VPC Flow Logs to BigQuery, generate additional traffic by sending repeated HTTP requests to web-server from Cloud Shell.
In the Google Cloud console, on the Navigation menu (), click Compute Engine > VM instances.
Note the External IP address for web-server to use as EXTERNAL_IP in the next step.
In Cloud Shell, store the external IP address in an environment variable, replacing EXTERNAL_IP with the address you noted:
Click Check my progress to verify the objective.
The Welcome to BigQuery in the Cloud Console message box opens. This message box provides a link to the quickstart guide and the release notes.
The BigQuery console opens.
curl requests from Cloud Shell, and refresh the page.Click the Details tab.
Copy the Table ID (for example, qwiklabs-gcp-xx.bq_vpc_flows.compute_googleapis_com_vpc_flows_YYYYMMDD).
Click SQL query (or the + tab button) to open a new query editor.
Paste the following query into the editor, replacing your_table_id with your copied Table ID while keeping the backticks (`) on both sides:
CAST(jsonPayload.bytes_sent AS INT64) because Cloud Logging exports 64-bit integer JSON fields as strings. The results table displays total bytes sent, source and destination IP addresses and ports, protocol, VPC name, and subnet name.The previous query returns connection-level details similar to Logs Explorer. Next, run a query that identifies the top source IP addresses sending traffic to web-server.
your_table_id with your copied Table ID while keeping the backticks (`) on both sides:jsonPayload.reporter = 'DEST' isolates flows reported by the receiving VM (web-server) so bidirectional traffic is not double-counted. The results show each source IP sorted by the highest byte volume sent to web-server, with your Cloud Shell IP address near the top.Now explore VPC flow log volume reduction. VPC Flow Logs does not capture every packet into its own log record, yet even with sampling, log captures can grow rapidly on busy subnets.
You can balance traffic visibility against storage costs by tuning aggregation and sampling settings.
compute.googleapis.com/vpc_flows, created when you enabled Flow Logs in Task 1) to the Network Management API (networkmanagement.googleapis.com/vpc_flows, pre-enabled in your lab project), which supports organization, VPC, subnet, Interconnect, and VPN scopes and integrates with Network Intelligence Center > Flow Analyzer. In this task, you update the existing Compute Engine API configuration on vpc-subnet.In the Google Cloud console, on the Navigation menu (), click VPC network > VPC networks.
Click the Subnets in current project tab.
Select the checkbox next to vpc-subnet, and then click Manage flow logs > Add new configuration.
Under Configurations - Subnets (Compute Engine API), click Compute Engine API configuration to expand Edit configuration.
For Aggregation interval, select 30 seconds.
Click Advanced settings to display the metadata and sampling options.
Review the purpose of each setting:
5 seconds default, 30 seconds, 1 minute, 5 minutes, 10 minutes, or 15 minutes).50% (0.50) keeps half of entries; values range from 100% (1.0, keep all) down to 0% (0.0, keep none).For Secondary sampling rate, type 25 (to set 25%).
Click Done, and then click Save.
Setting the aggregation interval to 30 seconds can reduce flow log volume by up to 83% compared to the default 5-second interval.
Click Check my progress to verify the objective.
You configured a custom VPC network with VPC Flow Logs enabled, deployed an Apache web server, verified flow logs in Cloud Logging, exported and analyzed the logs in BigQuery, and tuned VPC flow log aggregation and sampling settings.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated on November 19, 2026
Lab Last Tested on November 19, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We can notify you via email when it becomes available
Great!
We can contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one