More Info:
VCN Flow Logs should be enabled for all Virtual Cloud Networks. Flow logs provide visibility into network traffic patterns and are essential for detecting lateral movement and data exfiltration.Risk Level
MediumAddress
Compliance, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS AWS
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- Cloudanix Best Practice
- DPDPA
- Digital Operational Resilience Act (EU)
- GDPR
- HIPAA
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- PCI
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Use the VCN’s built‑in Flow Logs feature and send them to the OCI Logging service. Steps below are all in the OCI Console.
Prerequisites
- You have permissions to manage VCNs and Logging in the target compartment.
- (Recommended) Decide which VCNs/subnets you want logs for and a naming convention for log groups.
1. Create (or choose) a Log Group
- In the OCI Console, open the Navigation menu.
- Go to Observability & Management → Logging → Log Groups.
- Select the Compartment where your VCN resides.
- Click Create Log Group (or choose an existing one).
- Enter a Name and Description, then click Create.
2. Enable Flow Logs on the VCN (recommended: at subnet level)
- Open the Navigation menu → Networking → Virtual Cloud Networks.
- Select the correct Compartment, then click your VCN.
- Under Resources, click Flow Logs.
- Click Create Flow Log.
- Configure:
- Flow Log Name: e.g.,
vcn1-subnetA-flows. - Target:
- Log Group: select the log group from step 1.
- Log Name: e.g.,
vcn1-subnetA-flow-log.
- Scope Type:
- Choose Subnet (or VCN) depending on your policy.
- Scope:
- If Subnet: select the specific subnet(s) whose traffic you want to log.
- Traffic Type: choose All, or restrict to Ingress/Egress per requirements.
- Aggregation Interval / Log Format: leave defaults unless you have specific requirements.
- Flow Log Name: e.g.,
- Click Create Flow Log.
3. Verify Logs Are Being Collected
- Go to Observability & Management → Logging → Logs.
- Select the Compartment and Log Group you used.
- Click the flow log you created.
- Check the Log entries tab to confirm new records are appearing (may take a few minutes).
Using CLI
Using CLI
Below is a practical, CLI‑focused way to enable VCN Flow Logs for OCI Networking Monitoring.High‑level steps
Subnet or VCN OCID (usually you configure flow logs at subnet level):(If you want VCN‑level logs, identify the VCN OCID similarly with
Capture the Log Group OCID:
Key parts:
If you share:
-
Decide:
- Which compartment you will use for logs
- Which VCN/subnet(s) you want flow logs for
- Which log group to place them in
- Which log retention you want (days)
-
Using OCI CLI:
- Create (or reuse) a Log Group
- Create a Flow Log on the target subnet(s) or VCN
0. Prerequisites
- OCI CLI installed and configured (
oci setup config) - Your user/instance principal has:
logging-familypermissions on the target compartmentinspect virtual-network-familyat least
1. Identify target resources
Compartmentoci network vcn list --compartment-id $COMP_OCID.)2. Create (or reuse) a Log Group
If you already have a log group for network logs, skip to step 3.3. Create a VCN Flow Log (subnet source) using CLI
Flow logs are service logs in the Logging service with sourceflowlogs
and the resource set to your subnet (or VCN) OCID.Basic example (subnet):--log-type SERVICE– this is a service logservice: "flowlogs"– the VCN Flow Logs serviceresource: "<subnet_ocid>"– subnet being loggedcategory: "all"– all flow log records--retention-duration 30– days (change as required)
To log at VCN level, set "resource": "<vcn_ocid>" instead of subnet OCID.
4. Verify the log is active
5. (Optional) Enable flow logs for multiple subnets
Example loop over all subnets in a VCN:If you share:
- compartment OCID
- whether you want subnet‑ or VCN‑level logs
I can tailor an exact CLI script for your environment.
Using Python
Using Python
Below is how to enable VCN Flow Logs in OCI using Python (OCI Python SDK), step by step.
This will enable flow logs for all traffic in the VCN and send them to the log group.
You should see your
If you share your tenancy/compartment structure and whether you want logs at VCN level only or also per subnet, I can tailor the Python snippet to your exact layout (e.g., looping through all VCNs/subnets in a compartment).
1. Prerequisites
- Python SDK installed
- Configured OCI CLI/SDK config
~/.oci/config should have at least:- IAM Policy
2. Decide Scope and Resources
You need:- VCN OCID – the network you want to capture flow logs for
- Subnet OCID(s) – if logging at subnet level
- Compartment OCID – where the VCN resides
- Log Group – where flow logs will be stored (create one if needed)
- A VCN-level flow log (captures flows for the whole VCN), or
- Subnet-level flow logs (per subnet).
3. Create (or Use) a Log Group
4. Enable VCN-Level Flow Logs
5. Enable Subnet-Level Flow Logs (Optional, Per Subnet)
6. Verify Logs Are Enabled
You can list logs in the log group:vcn-flow-log (and/or subnet-flow-log) with is_enabled=True.If you share your tenancy/compartment structure and whether you want logs at VCN level only or also per subnet, I can tailor the Python snippet to your exact layout (e.g., looping through all VCNs/subnets in a compartment).
Using Terraform
Using Terraform
terraform plan should show:- 1 new
oci_logging_log_group - 1 new
oci_logging_logwithis_enabled = trueandservice = "flowlogs"referencing the VCN OCID.

