📖 Scenario: You are working as a cloud engineer for a company that wants to monitor and analyze its network traffic on Google Cloud Platform (GCP). Your task is to set up basic network intelligence tools using GCP services to collect and view network flow logs.
🎯 Goal: Build a simple GCP configuration that enables VPC flow logs on a subnet, creates a logging sink to export logs to a Cloud Storage bucket, and sets up a basic log-based metric to monitor network traffic.
📋 What You'll Learn
Enable VPC flow logs on a subnet named default-subnet in the default-vpc network
Create a Cloud Storage bucket named network-logs-bucket to store exported logs
Create a logging sink named network-logs-sink that exports VPC flow logs to the bucket
Create a log-based metric named vpc_flow_log_count to count the number of flow log entries
💡 Why This Matters
🌍 Real World
Network intelligence tools help companies monitor their cloud network traffic for security and performance. Setting up flow logs and exporting them is a common first step.
💼 Career
Cloud engineers and network administrators use these skills to ensure network visibility and troubleshoot issues in cloud environments.
Progress0 / 4 steps
1
Enable VPC flow logs on the subnet
Write a gcloud command to update the subnet named default-subnet in the network default-vpc to enable VPC flow logs.
GCP
Hint
Use the gcloud compute networks subnets update command with the --enable-flow-logs flag.
2
Create a Cloud Storage bucket for logs
Write a gcloud command to create a Cloud Storage bucket named network-logs-bucket in the us-central1 region.
GCP
Hint
Use gcloud storage buckets create with the bucket name and location.
3
Create a logging sink to export VPC flow logs
Write a gcloud command to create a logging sink named network-logs-sink that exports logs with the filter resource.type="gce_subnetwork" AND logName:"compute.googleapis.com/vpc_flows" to the bucket network-logs-bucket.
GCP
Hint
Use gcloud logging sinks create with the sink name, destination bucket, and filter.
4
Create a log-based metric to count VPC flow logs
Write a gcloud command to create a log-based metric named vpc_flow_log_count with the filter resource.type="gce_subnetwork" AND logName:"compute.googleapis.com/vpc_flows" that counts the number of matching log entries.
GCP
Hint
Use gcloud logging metrics create with the metric name, description, filter, and type.
Practice
(1/5)
1. What is the main purpose of GCP's Network Intelligence Tools?
easy
A. To manage user permissions
B. To create virtual machines
C. To check and understand cloud network connections
D. To store large amounts of data
Solution
Step 1: Understand the role of Network Intelligence Tools
These tools are designed to help users check and understand how their cloud network connections work.
Step 2: Compare with other options
Creating virtual machines, storing data, and managing permissions are handled by other GCP services, not Network Intelligence Tools.
Final Answer:
To check and understand cloud network connections -> Option C
B. Details of the connectivity test including source, destination, and result
C. List of all connectivity tests
D. Command to create a new test
Solution
Step 1: Understand the describe command
The describe command shows detailed information about a specific connectivity test.
Step 2: Confirm test existence and success
Since test-1 exists and ran successfully, the output will include its details like source, destination, and test result.
Final Answer:
Details of the connectivity test including source, destination, and result -> Option B
Quick Check:
Describe test = show test details [OK]
Hint: Describe shows details of one test, not list or errors [OK]
Common Mistakes:
Expecting a list of tests instead of details
Assuming error if test exists
Confusing describe with create command
4. You run gcloud network-intelligence connectivity-tests describe test-2 but get an error saying the test does not exist. What is the likely cause?
medium
A. Network Intelligence Tools are not enabled in the project
B. The command syntax is incorrect
C. The source VM is down
D. The test test-2 was not created
Solution
Step 1: Analyze the error message
The error says the test does not exist, meaning it was never created.
Step 2: Check command and environment
The command syntax is correct, and the error is specific to the test name, not the service or VM status.
Final Answer:
The test test-2 was not created -> Option D
Quick Check:
Describe error = test missing [OK]
Hint: Create test before describing it to avoid 'not exist' error [OK]
Common Mistakes:
Assuming syntax error without checking test existence
Blaming service enablement without error details
Thinking VM status causes test not found error
5. You want to check if a VM in one region can connect to a Cloud SQL instance in another region. Which Network Intelligence Tool and approach should you use?
hard
A. Create and run a connectivity test specifying the VM as source and Cloud SQL as destination
B. Use Cloud Storage to transfer data between regions
C. Run a firewall rule audit to check permissions only
D. Create a new VM in the same region as Cloud SQL
Solution
Step 1: Identify the tool for cross-region connectivity checks
Network Intelligence Tools allow creating connectivity tests between source and destination resources across regions.
Step 2: Choose the correct approach
Creating and running a connectivity test with the VM as source and Cloud SQL as destination directly tests network reachability.
Step 3: Eliminate other options
Cloud Storage is unrelated to connectivity tests, firewall audits check rules but not actual connectivity, and creating a new VM does not test existing network paths.
Final Answer:
Create and run a connectivity test specifying the VM as source and Cloud SQL as destination -> Option A
Quick Check:
Connectivity test = VM to Cloud SQL check [OK]
Hint: Use connectivity test for cross-region VM to Cloud SQL checks [OK]