Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate missing VPC Network Logging (VPC Flow Logs) in GCP using the Console, enable flow logs on each subnet:
  1. Sign in and go to VPC networks
    • Go to: https://console.cloud.google.com/
    • Make sure you’re in the correct project.
    • In the left menu, go to VPC network → VPC networks.
  2. Select the VPC network
    • Click the name of the VPC network where you want logging enabled.
    • You’ll see a list of Subnets for that VPC.
  3. Edit each subnet to enable flow logs
    • For each subnet that should have logging:
      1. Click the three dots (⋮) at the end of the subnet row and choose Edit subnet (or click the subnet name, then click Edit).
      2. Find the Flow logs setting.
      3. Set Flow logs to On.
      4. (Optional but recommended) Configure:
        • Aggregation interval (e.g., 5 min for more detail, or 30 min for less cost).
        • Sampling (e.g., 0.5 or 1.0 for security-focused environments).
        • Metadata (e.g., “Include all metadata” for richer logs; adjust if you have privacy or cost constraints).
        • Filter (e.g., “All” for all traffic, or more restrictive if you have a specific policy).
  4. Choose the destination (if prompted)
    • By default, VPC Flow Logs are exported to Cloud Logging.
    • If needed, set up sinks later (Logging → Logs Router) to send logs to:
      • Cloud Storage (archival),
      • BigQuery (analytics),
      • Pub/Sub (streaming to SIEM or other tools).
  5. Save the changes
    • Click Save at the bottom of the Edit subnet page.
    • Repeat for every subnet that must have VPC Flow Logs enabled.
  6. Verify logs are arriving
    • Go to Logging → Logs Explorer.
    • In the query builder, set:
      • Resource type: gce_subnetwork
      • Or use a simple query like:
    • Run the query and confirm you see new flow log entries.
If you tell me your compliance baseline (e.g., CIS, PCI, internal standard), I can recommend specific aggregation, sampling, and metadata settings.
Below are step‑by‑step GCP CLI instructions to enable VPC Network Logging, covering both:
  • VPC Flow Logs (subnet-level)
  • Firewall Rule Logging (rule-level)
Adjust names/regions/project as needed.

1. Prerequisites


2. Enable VPC Flow Logs on a Subnet

VPC Flow Logs are configured per subnet.

2.1. List existing subnets

Note the NAME, REGION, and NETWORK of the subnet you want to fix.

2.2. Check current flow log status for a subnet

If blank/false, logs are not enabled.

2.3. Enable flow logs for the subnet

Basic enablement (default logging config):

2.4. (Optional) Tune flow log sampling & aggregation

Example: sample 0.5, aggregation interval 5 min, metadata with filter:
Common --aggregation-interval values:
  • INTERVAL_5_SEC
  • INTERVAL_30_SEC
  • INTERVAL_1_MIN
  • INTERVAL_5_MIN
  • INTERVAL_10_MIN
  • INTERVAL_15_MIN

3. Enable Logging for Firewall Rules

Firewall logging is configured per firewall rule.

3.1. List firewall rules

Identify the rule(s) you want to log.

3.2. Check logging status of a firewall rule

3.3. Enable logging for a firewall rule

Log both allowed and denied traffic:
(Optional) Log only denied or only allowed traffic:
(Note: exact logging options flags may vary; in many environments --enable-logging is sufficient, and log routing is handled via Cloud Logging sinks.)

4. Verify Logs Are Being Generated

4.1. In Cloud Logging (via CLI)

List log names that contain VPC flow logs:
List log names that contain firewall logs:
View recent VPC flow log entries:
View recent firewall log entries:

If you share your PROJECT_ID, subnet name, and region, I can give you the exact commands filled in.
For GCP “VPC Network Logging” you typically mean VPC Flow Logs on subnetworks (and optionally firewall rule logging). Below is how to enable VPC Flow Logs on one or more subnetworks using Python.

1. Prerequisites

  1. A GCP project and VPC subnet(s) already created.
  2. Permissions:
    • compute.subnetworks.update
    • Often via roles like roles/compute.networkAdmin.
  3. Local setup:
  4. Authentication (any one):
    • gcloud auth application-default login (for local/dev)
    • Or run in a service account context with proper roles.

2. Enable VPC Flow Logs on a Subnetwork (Python)

This uses the compute.subnetworks.patch method and sets enableFlowLogs: true.

3. Enable Flow Logs on All Subnets in a VPC Network (Python)

If you want to turn on logs for every subnetwork in a given VPC network:
Run that for each region where your VPC has subnetworks.

4. (Optional) Firewall Rule Logging via Python

If your “VPC Network Logging” requirement also includes firewall rule logging:

If you tell me your exact project/region/VPC/subnet naming pattern or whether this should be part of a CI/CD script, I can tailor the code further (e.g., idempotent check, environment‑based config).
Enabling or changing log_config on an existing subnetwork is an in‑place update and does not force replacement of the subnetwork.For an already‑managed subnetwork, just add or adjust the log_config block in its existing google_compute_subnetwork resource.Verification: terraform plan should show an update to the google_compute_subnetwork with log_config being added or modified, and no -/+ replacement for the subnetwork.