Skip to content

Script for Calculating EC2 Instance Network Egress - Identifying Traffic Destination

0

Hi everyone,

I'm got a script to calculate the network egress (data out) for each EC2 instance in a specific region over a defined timeframe. The script currently leverages the AWS/EC2 namespace and NetworkOut metric with cloudwatch get-metric-statistics. More information on it.

While it provides the total network egress per instance, I'd like to understand if there's a way to differentiate between the following types of egress traffic:

  • VPC Peering traffic
  • Site-to-Site VPN traffic
  • Actual data transfer out to the internet

Is there a specific metric or approach within CloudWatch or EC2 that would allow me to identify the destination of the network egress traffic for each instance?

I've considered exploring network interfaces and potentially using the NetworkInterfaceId dimension, but I'm unsure if that would provide the complete picture.

Any insights or alternative approaches you could suggest would be greatly appreciated!

PS: I enabled VPC flow logs but it isn't giving a complete picture. Not enough information is provided.

1 Answer
1

Hi Adit, one option would be to enable VPC Flow Logs, which among other information contain the destination address (and original packet destination address) + interface id + bytes of flows. You can send the flow logs to CloudWatch to analyze them with a modified version of the script or by using CloudWatch Logs Insights. Having the destination IP you could group the flows by inbound, outbound peered VPC, outbound S2S VPN or Internet. Feasibility of this solution depends on your specific use case (see pricing).

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Yes, VPC flow logs is an option but the problem is we cannot send the flog logs to cloudwatch to analyze it since it will be too expensive for us. I will just enable VPC flow logs to test it out. let's see if it helps me.

  • Hi, is there some other solution that can help identify what amount of data is going out via internet?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.