Recording Network Traffic Metadata with Flow Logs
This lesson explains how flow logs record metadata about IP traffic, who talked to whom, on which ports and whether the traffic was allowed, without capturing packet contents.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the levels and destinations of VPC Flow Logs.
- Interpret flow log record fields, including custom format fields.
- Interpret REJECT records in light of stateful and stateless filtering.
- Explain when Transit Gateway Flow Logs or Traffic Mirroring are needed.
Creating flow logs
VPC Flow Logs record metadata about IP traffic to and from network interfaces: source and destination addresses and ports, protocol, packet and byte counts, and whether security groups and network ACLs accepted or rejected the traffic. They do not capture packet contents, for which Traffic Mirroring is used. Flow logs are configured at a chosen level, and a flow log at the VPC level covers every interface in the VPC, including those created later. The following list describes the settings that define a flow log.
- Scope: a VPC, subnet or network interface.
- Destination: CloudWatch Logs, S3 (optionally Parquet with hourly partitions) or Firehose.
- Capture accepted, rejected or all traffic.
Flow log basics
Record fields
The default format has source and destination IPs and ports, protocol, packets, bytes, start and end times, and the action (ACCEPT or REJECT). Custom formats add vpc-id, subnet-id, instance-id, tcp-flags, flow-direction, and pkt-srcaddr/pkt-dstaddr (the original addresses behind a NAT gateway).
The following diagram shows what VPC Flow Logs revealed about a suspected data exfiltration, what they could not show, and what came next.

Interpreting REJECT
A security group or network ACL blocked the traffic. Security groups are stateful and NACLs stateless, so an accepted inbound flow with a rejected response points to a NACL. Flow logs also reveal port scans, exfiltration and unexpected connections.
Reading REJECT records
Beyond VPC Flow Logs
VPC Flow Logs record metadata about traffic through network interfaces, but two tools give further visibility. Transit Gateway Flow Logs record traffic passing through a transit gateway, the hub connecting VPCs, VPN connections and Direct Connect, so traffic between networks can be analysed in one place. VPC Traffic Mirroring copies full packets, including their contents, from network interfaces to monitoring appliances such as an intrusion detection system. This allows deep inspection that metadata alone cannot support. The following table summarises the tools.
| Tool | Captures |
|---|---|
| Transit Gateway Flow Logs | Traffic through the transit gateway hub: between VPCs, VPN and Direct Connect |
| VPC Traffic Mirroring | Full packets copied to monitoring appliances for deep inspection |
Flow logs miss payloads, DNS traffic to the Amazon resolver, instance metadata traffic and some other AWS-internal traffic.
What flow logs miss
Spotting exfiltration in flow logs
GuardDuty is silent, but a data engineer notices high NAT gateway costs from one subnet. Flow logs with a custom format including pkt-srcaddr and pkt-dstaddr are queried in Logs Insights for the largest outbound flows from that subnet:
filter flowDirection = "egress" and action = "ACCEPT" and srcAddr like /^10\.0\.12\./
| stats sum(bytes) as totalBytes by srcAddr, pktDstAddr, dstPort
| sort totalBytes desc
| limit 10One instance has sent 400 GB to a single external address on port 443 over three nights. Flow logs cannot show what was sent, but they establish who, where, when and how much, which is enough to isolate the instance and start a forensic investigation. Resolver query logs then show which domain the instance looked up before connecting.
Which feature captures packet payloads for analysis?
Show answer
VPC Traffic Mirroring. Flow logs record only connection metadata.
Exam Tips
Remember for the exam
- To see which connections were rejected, look for flow log records with the action REJECT.
- For traffic between VPCs through a central hub, use Transit Gateway Flow Logs.
- When packet payloads are needed for analysis, use VPC Traffic Mirroring.
- The original source IP address behind a NAT gateway is in the pkt-srcaddr custom field.
- An accepted inbound flow with a rejected response indicates a network ACL problem.