Identity logs answer who did what, but they do not show how traffic moved through the network. VPC Flow Logs fill that gap. They record connection metadata inside the VPC: source, destination, ports, protocol and whether the traffic was accepted or rejected. In an investigation, they are how you detect lateral movement, internal scanning and data exfiltration.
To capture and use VPC Flow Logs defensively, the challenge is gaining that visibility without drowning in volume. That means knowing exactly what they record (and what they leave out), choosing the capture format well before you need it and having the queries and the correlation with other sources ready in advance.
What Flow Logs record
Flow Logs capture flow metadata per network interface, per subnet or for the entire VPC. Each record includes the source and destination IPs, ports, protocol, bytes and the action (accepted or rejected). Rejected traffic deserves special attention, because a burst of rejected connections can indicate scanning. Accepted connections between workloads that should not talk to each other, on the other hand, suggest lateral movement.
Also know what is left out. Flow Logs record metadata, and packet contents are not part of the record. They tell you a connection happened, but not what went through it. To see the content, you need other approaches, such as application-layer inspection.
Custom format and the fields that matter
The default Flow Logs format covers the basics. The custom format adds fields that make a big difference in an investigation, such as those showing traffic direction, the real addresses behind network address translation and connection flags. Define the right format before the incident. Otherwise you risk finding out, in the middle of the analysis, that the data you needed was never captured.
action # ACCEPT or REJECTflow-direction # ingress or egresspkt-srcaddr # real source IP, before NATpkt-dstaddr # real destination IP, before NATtcp-flags # TCP connection flagstraffic-path # path taken by egress trafficThe pkt-srcaddr and pkt-dstaddr fields matter because, when traffic passes through NAT or a load balancer, the traditional address fields show the intermediary. In this case, only the packet fields reveal who really originated or received the connection. The flow-direction field separates inbound from outbound, which helps when you suspect exfiltration. And tcp-flags lets you tell a scan apart from an established connection.
Investigating and correlating
Flow Logs are worth much more when cross-referenced with other sources. Combined with CloudTrail, they link network activity to the identity that provisioned the resource. With application logs, they gain business context. During an incident, they help map which hosts a compromised resource tried to reach and whether there was unusual outbound traffic, which is a sign of exfiltration.
Queries that keep coming up
Whether Flow Logs go to CloudWatch Logs or to S3 with Athena queries, some questions always come up: who generated the most outbound traffic, which connections were rejected (and on which ports) and which source and destination pairs exchanged the most bytes. Summing outbound bytes by destination helps catch exfiltration, and counting rejections by port makes scans stand out.
fields dstAddr, bytes| filter action = "ACCEPT"| stats sum(bytes) as total_out by dstAddr| sort total_out desc| limit 20- Review rejected connections for signs of scanning
- Look for workloads talking when they should not (lateral movement)
- Sum outbound bytes by destination to find exfiltration
- Use pkt-srcaddr to see the real IP behind NAT and load balancers
- Cross-reference with CloudTrail and application logs
- Map everything a compromised host tried to reach
Storage, cost and focus
Flow Logs generate a lot of volume. Send them to cheap storage and use queries to analyze on demand, instead of trying to follow everything all the time. S3 is usually cheaper for long retention and analysis with Athena, while CloudWatch Logs makes quick queries and alerts easier. Many environments use both paths, each for a different need.
Choose the scope carefully. Capturing the whole VPC gives broad coverage, but enabling logs only on sensitive subnets and interfaces can balance visibility and cost. At a minimum, turn them on wherever there are critical workloads and exposure. Keep in mind that each record aggregates the flow over a time interval, so Flow Logs show connection patterns rather than individual packets. And there is traffic they do not capture, such as queries to the instance metadata server.
Practical checklist
- Enable Flow Logs at least on critical VPCs and subnets
- Capture both accepted and rejected traffic
- Include pkt-srcaddr, flow-direction and tcp-flags in the custom format
- Send logs to cheap storage, with S3 for long retention
- Set a retention period that fits your investigation needs
- Treat bursts of rejected connections as possible scanning
- Investigate communication between workloads that should not talk to each other
- Sum outbound bytes by destination to look for exfiltration
- Correlate with CloudTrail and application logs
- Have standard queries for network investigations
- Fit the capture scope to a cost that makes sense
Best practices
- Use Flow Logs for network visibility, which identity logs do not give you
- Define a custom format with the fields that matter in an investigation
- Pay attention to rejected traffic and unexpected communication
- Use pkt-srcaddr to get to the real IP behind NAT
- Correlate with other sources to get context
- Send the volume to low-cost storage
- Remember that records hold aggregated metadata, not packet contents
Common mistakes
- Not enabling Flow Logs on any network
- During the investigation, lateral movement and exfiltration do not show up.
- Default format only, without the packet fields
- You see the NAT or load balancer address instead of the real IP at the endpoint.
- Capturing everything with no cost strategy
- Volume and the bill grow much faster than visibility.
- Expecting packet contents in Flow Logs
- The expectation is wrong: records hold aggregated metadata and no content.
- Ignoring rejected traffic
- Scans and internal enumeration go unnoticed.
- Flow Logs with no correlation to other sources
- The network view stays isolated and does not link activity to an identity or a context.
Authorship and review
Cesar Gargiulo
CEO and founder of GUARDIASEC. Technical and editorial lead for the content published in this library.
Published on . Found a technical error? Write to [email protected] and we will correct it and keep a record of the change.