
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
Configure a custom network with VPC Flow Logs
/ 5
Create an Apache web server
/ 5
Export the network traffic to BigQuery to further analyze the logs.
/ 5
In this lab, you will configure a network to record traffic to and from an Apache web server using VPC Flow Logs. You will then export the logs to BigQuery to analyze them.
In this lab, you will learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
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 Details panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
By default, VPC Flow Logs are disabled for a network. Therefore, you will create a new custom-mode network and enable VPC flow logs.
In the Google Cloud console, in the Navigation menu (), select VPC network > VPC networks.
Click Create VPC Network.
Specify the following and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | vpc-net |
Description | Enter an optional description |
For Subnet creation mode, click Custom.
Specify the following and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | vpc-subnet |
Region | |
IP address range | 10.1.3.0/24 |
Flow Logs | On |
Wait for the network to be created before continuing.
In order to serve HTTP and SSH traffic on the network, you need to create a firewall rule.
In the Navigation menu (), select VPC network > Firewall.
Click CREATE FIREWALL RULE.
Specify the following and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
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 | Specified protocols and ports, and then check tcp, type: 80, 22 |
Click Check my progress to verify the objective.
In the Navigation menu, select Compute Engine > VM instances.
Click Create instance.
Specify the following and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | web-server |
Region | |
Zone | |
Series | E2 |
Machine type | e2-micro |
Click Networking.
For Network tags, type http-server
.
For Network interfaces, click default.
Specify the following and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Network | vpc-net |
Subnetwork | vpc-subnet (10.1.3.0/24) |
Click Done.
Click Create.
Configure the VM instance that you created as an Apache web server and overwrite the default web page.
For web-server, click SSH to launch a terminal and connect.
In the web-server SSH terminal, update the package index:
Install the apache2 package:
To create a new default web page by overwriting the default, run the following:
Exit the SSH terminal:
Click Check my progress to verify the objective.
Find the IP address of the computer you are using. One easy way to do this is to go to a website that provides this address.
what's my IP
. It will either directly reply with your IP or give you a list of sites that perform this service.You can explore other fields within the log entry before continuing to the next task.
bq_vpcflows
, and click NEXT.bq_vpcflows
, and click CREATE DATASET.Now that the network traffic logs are being exported to BigQuery, you need to generate more traffic by accessing the web-server several times. Using Cloud Shell, you can curl
the IP address of the web-server several times.
Click the + icon to open a new BidQuery Editor tab.
Add the following to the BigQuery Editor and replace your_table_id with TABLE_ID while retaining the accents (`) on both sides:
The previous query gave you the same information that you saw in the Cloud console. Now, you will change the query to identify the top IP addresses that have exchanged traffic with your web-server.
You can generate more traffic to the web-server from multiple sources and query the table again to determine the bytes sent to the server.
Click Check my progress to verify the objective.
In this task, you will now explore a new release of VPC flow log volume reduction. Not every packet is captured into its own log record. However, even with sampling, log record captures can be quite large.
You can balance your traffic visibility and storage cost needs by adjusting specific aspects of logs collection, which you will explore in this section.
In the Console, navigate to the Navigation menu () and select VPC network > VPC networks.
Click vpc-net.
In the Subnets tab, click vpc-subnet:
The purpose of each field is explained below.
Aggregation time interval: Sampled packets for a time interval are aggregated into a single log entry. This time interval can be 5 sec (default), 30 sec, 1 min, 5 min, 10 min, or 15 min.
Metadata annotations: By default, flow log entries are annotated with metadata information, such as the names of the source and destination VMs or the geographic region of external sources and destinations. This metadata annotation can be turned off to save storage space.
Log entry sampling: Before being written to the database, the number of logs can be sampled to reduce their number. By default, the log entry volume is scaled by 0.50 (50%), which means that half of entries are kept. You can set this from 1.0 (100%, all log entries are kept) to 0.0 (0%, no logs are kept).
Set the Aggregation Interval to 30 seconds.
Set the Secondary sampling rate to 25%.
Click Save. You should see the following message:
Setting the aggregation level to 30 seconds can reduce your flow logs size by up to 83% compared to the default aggregation interval of 5 seconds. Configuring your flow log aggregation can seriously affect your traffic visibility and storage costs.
You have configured a VPC network, enabled VPC Flow Logs, and created a web server in that network. Then, you generated HTTP traffic to the web server, viewed the traffic logs in the Cloud console, and analyzed the traffic logs in BigQuery. Finally, you used VPC Flow Log aggregation for balancing your traffic visibility and storage cost.
There are multiple use cases for VPC Flow Logs. For example, you might use VPC Flow Logs to determine where your applications are being accessed from in order to optimize network traffic expense, to create HTTP load balancers to balance traffic globally, or to deny unwanted IP addresses with Cloud Armor.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 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 will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one