Create the custom network

Fortschritt prüfen

/ 10

Create a subnet with VPC Flow Logs enabled

Fortschritt prüfen

/ 15

Create the firewall rule in the custom network

Fortschritt prüfen

/ 10

Create the web server in the custom network

Fortschritt prüfen

/ 15

Install Apache in web server

Fortschritt prüfen

/ 15

Export the network traffic to BigQuery

Fortschritt prüfen

/ 20

Configure VPC flow log aggregation

Fortschritt prüfen

/ 15

Dieses Lab kann KI-Tools enthalten, die den Lernprozess unterstützen.
Dieser Inhalt ist noch nicht für Mobilgeräte optimiert.
Die Lernumgebung funktioniert am besten, wenn Sie auf einem Computer über einen per E‑Mail gesendeten Link darauf zugreifen.

GSP212

Google Cloud self-paced labs

Overview

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.

Objectives

In this lab, you learn how to perform the following tasks:

  • Configure a custom network with VPC Flow Logs.
  • Create an Apache web server.
  • Verify that VPC Flow Logs records network traffic.
  • Export the network traffic logs to BigQuery to analyze the logs.
  • Configure VPC flow log aggregation.

Setup and requirements

Before you click the Start Lab button

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:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

How to start your lab and sign in to the Google Cloud console

  1. 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:

    • The Open Google Cloud console button
    • The temporary credentials (username and password) that you must use for this lab
    • Other information, if needed, to step through this lab

    Note that the lab timer is located near the top of the page, showing the remaining time.

  2. 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.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab setup and access panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab setup and access panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field. Navigation menu icon and Search field

Activate Cloud Shell

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.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  2. Click through the following windows:

    • Continue through the Cloud Shell information window.
    • Authorize Cloud Shell to use your credentials to make Google Cloud API calls.

When you are connected, you are already authenticated, and the project is set to your Project_ID, . The output contains a line that declares the Project_ID for this session:

Your Cloud Platform project in this session is set to {{{project_0.project_id | "PROJECT_ID"}}}

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  1. (Optional) You can list the active account name with this command:
gcloud auth list
  1. Click Authorize.

Output:

ACTIVE: * ACCOUNT: {{{user_0.username | "ACCOUNT"}}} To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:
gcloud config list project

Output:

[core] project = {{{project_0.project_id | "PROJECT_ID"}}} Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Task 1. Configure a custom network with VPC Flow Logs

Create the custom network

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.

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click VPC network > VPC networks.

    VPC networks option highlighted in the Navigation menu

  2. Click Create VPC network.

  3. For Name, type vpc-net, and add an optional description if you want.

  4. For Subnet creation mode, select Custom.

  5. 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
  1. Click Done, and then click Create.
Note: Turning on VPC Flow Logs does not affect VM performance, but high-traffic systems can generate a large volume of logs and increase storage costs. Note: Wait for Google Cloud to finish creating the network before proceeding to the next step.

Click Check my progress to verify the objectives.

Create the custom network. Create a subnet with VPC Flow Logs enabled in .

Create the firewall rule

To allow HTTP and SSH traffic on the custom network, create a firewall rule.

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click VPC network > Firewall.

  2. Click Create firewall rule.

  3. 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
Note: Make sure to include /0 in Source IPv4 ranges to allow traffic from all IPv4 networks.
  1. Click Create.

Click Check my progress to verify the objective.

Create the firewall rule in the custom network.

Task 2. Create an Apache web server

Create the web server

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click Compute Engine > VM instances.

  2. Click Create instance.

  3. 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)
  1. In the instance navigation pane, click Networking.

  2. Under Firewall, select Allow HTTP traffic.

  3. 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
  1. 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.

Create the web server in the custom network (zone: ).

Install Apache

Configure the VM instance as an Apache web server and overwrite the default webpage.

  1. On the VM instances page, in the row for web-server, click SSH to launch a terminal and connect.

  2. In the web-server SSH terminal, update the package index:

sudo apt-get update
  1. Install the apache2 package:
sudo apt-get install apache2 -y
  1. Overwrite the default Apache webpage:
echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' | sudo tee /var/www/html/index.html
  1. Exit the SSH terminal:
exit

Click Check my progress to verify the objective.

Install Apache in the web server.

Task 3. Verify that network traffic is logged

Generate network traffic

  1. On the VM instances page (Navigation menu (Navigation menu icon) > Compute Engine > VM instances), copy the External IP address for web-server.

  2. Open a new browser tab and navigate to http://EXTERNAL_IP, replacing EXTERNAL_IP with the address you copied.

Note: Ensure the URL begins with http:// (not https://), because Apache listens on HTTP port 80. The Hello World! welcome page that you configured opens.

Identify your public IPv4 address

Determine the public IPv4 address of the computer you are using so you can filter for your own requests in Cloud Logging.

  1. Open the AWS IPv4 Check service in a new browser tab to display your public IPv4 address.

  2. Copy your IPv4 address. The instructions refer to this value as YOUR_IP_ADDRESS.

Access the VPC Flow Logs

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click View All Products > Observability > Logging > Logs Explorer.

  2. Click All resources, select Subnetwork, and then click Apply.

  3. Click All log names, select vpc_flows (under compute.googleapis.com), and then click Apply.

  4. 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.

Note: If you do not see the vpc_flows log name option or any log entries yet, wait a couple of minutes, refresh the page, and run the query again.

Logs Explorer showing VPC Flow Logs query results

  1. Click one of the log entries to expand it.

  2. Expand jsonPayload and then connection (or click Expand all in the entry header).

Expanded log entry displaying jsonPayload connection fields

Note: The 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.

Task 4. Export the network traffic to BigQuery to further analyze the logs

Create an export sink

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.

  1. In Logs Explorer, clear the Query editor so that your workstation IP address is no longer in the filter.

  2. Click All resources, select Subnetwork, and then click Apply.

  3. Click All log names, select vpc_flows, and then click Apply.

  4. Click Run query to verify that the query filters only by resource.type="gce_subnetwork" and logName="projects/.../logs/compute.googleapis.com%2Fvpc_flows".

  5. Click Actions > Create sink.

  6. For Sink name, type vpc-flows, and then click Next.

  7. For Select sink service, select BigQuery dataset.

  8. For Select BigQuery dataset, select Create new BigQuery dataset.

  9. For Dataset ID, type bq_vpc_flows, and then click Create dataset.

  10. 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.

Generate log traffic for BigQuery

Now that Log Router exports VPC Flow Logs to BigQuery, generate additional traffic by sending repeated HTTP requests to web-server from Cloud Shell.

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click Compute Engine > VM instances.

  2. Note the External IP address for web-server to use as EXTERNAL_IP in the next step.

  3. In Cloud Shell, store the external IP address in an environment variable, replacing EXTERNAL_IP with the address you noted:

export MY_SERVER=EXTERNAL_IP
  1. Send 50 HTTP requests to web-server from Cloud Shell:
for ((i=1;i<=50;i++)); do curl $MY_SERVER; done

Click Check my progress to verify the objective.

Export the network traffic to BigQuery.

Open the BigQuery console

  1. In the Google Cloud Console, select Navigation menu > BigQuery.

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.

  1. Click Done.

The BigQuery console opens.

Visualize the VPC Flow Logs in BigQuery

  1. In the BigQuery Explorer pane, expand your Project ID, expand the bq_vpc_flows dataset, and then click the table whose name starts with compute_googleapis_com_vpc_flows_.
Note: If the bq_vpc_flows dataset does not expand or the table does not appear yet, wait a minute, send another round of curl requests from Cloud Shell, and refresh the page.
  1. Click the Details tab.

  2. Copy the Table ID (for example, qwiklabs-gcp-xx.bq_vpc_flows.compute_googleapis_com_vpc_flows_YYYYMMDD).

  3. Click SQL query (or the + tab button) to open a new query editor.

  4. Paste the following query into the editor, replacing your_table_id with your copied Table ID while keeping the backticks (`) on both sides:

SELECT jsonPayload.src_vpc.vpc_name, SUM(CAST(jsonPayload.bytes_sent AS INT64)) AS bytes, jsonPayload.src_vpc.subnetwork_name, jsonPayload.connection.src_ip, jsonPayload.connection.src_port, jsonPayload.connection.dest_ip, jsonPayload.connection.dest_port, jsonPayload.connection.protocol FROM `your_table_id` GROUP BY jsonPayload.src_vpc.vpc_name, jsonPayload.src_vpc.subnetwork_name, jsonPayload.connection.src_ip, jsonPayload.connection.src_port, jsonPayload.connection.dest_ip, jsonPayload.connection.dest_port, jsonPayload.connection.protocol ORDER BY bytes DESC LIMIT 15;
  1. Click Run.
Note: The query uses 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.

Analyze the VPC Flow Logs in BigQuery

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.

  1. Open a new query tab, paste the following query, and replace your_table_id with your copied Table ID while keeping the backticks (`) on both sides:
SELECT jsonPayload.connection.src_ip, jsonPayload.connection.dest_ip, SUM(CAST(jsonPayload.bytes_sent AS INT64)) AS bytes, jsonPayload.connection.dest_port, jsonPayload.connection.protocol FROM `your_table_id` WHERE jsonPayload.reporter = 'DEST' GROUP BY jsonPayload.connection.src_ip, jsonPayload.connection.dest_ip, jsonPayload.connection.dest_port, jsonPayload.connection.protocol ORDER BY bytes DESC LIMIT 15;
  1. Click Run.
Note: Filtering on 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. Note: Unless you accessed web-server from your browser after creating the export sink, your workstation IP address does not appear in the exported table.

Task 5. Add VPC flow log aggregation

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.

Note: Google Cloud is transitioning VPC Flow Logs from the subnet-only Compute Engine API (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.

Set up aggregation

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click VPC network > VPC networks.

  2. Click the Subnets in current project tab.

  3. Select the checkbox next to vpc-subnet, and then click Manage flow logs > Add new configuration.

  4. Under Configurations - Subnets (Compute Engine API), click Compute Engine API configuration to expand Edit configuration.

  5. For Aggregation interval, select 30 seconds.

  6. Click Advanced settings to display the metadata and sampling options.

Configure flow logs drawer showing aggregation interval and advanced settings

Review the purpose of each setting:

  • Aggregation interval: Aggregates sampled packets over the chosen time window into a single log entry (5 seconds default, 30 seconds, 1 minute, 5 minutes, 10 minutes, or 15 minutes).
  • Metadata annotations: Annotates each flow log entry with VM names, VPC details, and geographic metadata by default. Turning off metadata annotations reduces log entry size.
  • Secondary sampling rate: Scales the fraction of aggregated log entries written to Cloud Logging. The default 50% (0.50) keeps half of entries; values range from 100% (1.0, keep all) down to 0% (0.0, keep none).
  1. For Secondary sampling rate, type 25 (to set 25%).

  2. 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.

Configure VPC flow log aggregation.

Congratulations!

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.

Next steps / learn more

Google Cloud training and certification

...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.

Vorbereitung

  1. Labs erstellen ein Google Cloud-Projekt und Ressourcen für einen bestimmten Zeitraum
  2. Labs haben ein Zeitlimit und keine Pausenfunktion. Wenn Sie das Lab beenden, müssen Sie von vorne beginnen.
  3. Klicken Sie links oben auf dem Bildschirm auf Lab starten, um zu beginnen

Privates Surfen verwenden

  1. Kopieren Sie den bereitgestellten Nutzernamen und das Passwort für das Lab
  2. Klicken Sie im privaten Modus auf Konsole öffnen

In der Konsole anmelden

  1. Melden Sie sich mit Ihren Lab-Anmeldedaten an. Wenn Sie andere Anmeldedaten verwenden, kann dies zu Fehlern führen oder es fallen Kosten an.
  2. Akzeptieren Sie die Nutzungsbedingungen und überspringen Sie die Seite zur Wiederherstellung der Ressourcen
  3. Klicken Sie erst auf Lab beenden, wenn Sie das Lab abgeschlossen haben oder es neu starten möchten. Andernfalls werden Ihre bisherige Arbeit und das Projekt gelöscht.

Diese Inhalte sind derzeit nicht verfügbar

Bei Verfügbarkeit können wir Sie per E-Mail benachrichtigen

Sehr gut!

Bei Verfügbarkeit können wir Sie per E-Mail kontaktieren

Es ist immer nur ein Lab möglich

Bestätigen Sie, dass Sie alle vorhandenen Labs beenden und dieses Lab starten möchten

Privates Surfen für das Lab verwenden

Am besten führen Sie dieses Lab in einem Inkognito- oder privaten Browserfenster aus. So vermeiden Sie Konflikte zwischen Ihrem privaten Konto und dem Teilnehmerkonto, die zusätzliche Kosten für Ihr privates Konto verursachen könnten.