AWS Certified CloudOps Engineer – Associate
VPC Flow Logs: levels, aggregation interval and REJECT
The Amazon VPC User Guide says a flow log captures IP traffic data for a VPC, a subnet or a single network interface, and publishes it to CloudWatch Logs, Amazon S3 or Amazon Data Firehose. Records are aggregated over an interval of up to 10 minutes by default, or 1 minute if you choose. Each record shows ACCEPT or REJECT.
What can a flow log be attached to?
You create a flow log for a VPC, a subnet or a network interface. At the VPC or subnet level, every network interface in it is monitored. To limit records to one instance, create the flow log on its network interface.
For each flow log you choose the resource, the traffic to capture (accepted, rejected or all) and the destination. Network interfaces created by other services, such as Elastic Load Balancing, Amazon RDS and NAT gateways, can have flow logs too.
Flow log data is collected outside the path of the traffic, so creating or deleting a flow log does not affect throughput or latency. Deleting a flow log stops new records but does not delete data already published.
How fresh are the records?
A record covers one flow within an aggregation interval. The default maximum interval is 10 minutes. When you create the flow log you can set a maximum of 1 minute, which produces more records.
For a network interface attached to a Nitro-based instance, the interval is always 1 minute or less, whatever maximum was specified.
Flow logs are not a real-time stream. After capture, delivery typically takes about 5 minutes to CloudWatch Logs and about 10 minutes to Amazon S3, on a best-effort basis. A new flow log can take several minutes to start collecting.
How do you read ACCEPT and REJECT?
The default format contains the version 2 fields in a fixed order and cannot be changed. A custom format lets you pick the fields and their order. The action field is ACCEPT or REJECT.
Security groups are stateful and network ACLs are stateless, and the records show it. If a request appears as ACCEPT and its reply appears as REJECT, a network ACL denied the reply; a security group would have let the response through.
If a security group denies an inbound request, there is a single REJECT record, because the traffic never reached the instance. AWS lists diagnosing overly restrictive security group rules as one of the uses of flow logs.
Where the exam catches people
- Expecting flow logs in real time: records are aggregated, then delivered in about 5 to 10 minutes.
- Leaving the default interval when 1-minute records are required: the default maximum aggregation interval is 10 minutes.
- Blaming a security group for an
ACCEPTrequest with aREJECTreply: that pattern is a stateless network ACL. - Creating a second VPC-level flow log to watch one instance: scope the flow log to the network interface.
- Believing a flow log slows the network: flow log data is collected outside the traffic path.