- Newest
- Most votes
- Most comments
This is a great question that addresses a common area of misunderstanding in AWS monitoring. Unfortunately, AWS does not offer a single metric that adds up all outgoing traffic for a whole VPC, even though you are correct to search for a single "VPC Network Out" metric. Traffic leaves a logical network container, or VPC, via a number of gateways and endpoints, including NAT gateways, Internet gateways, VPC endpoints, and others. These are all distinct resources, each with a unique set of metrics.How to Track Outbound Total Egress Traffic: The right strategy is what you suggested—summing the metrics from various components. Internet Gateways (IGW) are a unique instance, though, as they are pass-through resources and don't release their own CloudWatch metrics.
You must keep an eye on the following resources in order to create a thorough picture of your VPC's outgoing internet traffic: 1.NAT Gateway (for private networks): Metrics for outgoing traffic from instances in private subnets are primarily obtained from this source. Name of Metric: BytesOutFromDestination Namespace: NATGateway/AWS What it measures: The quantity of bytes transmitted to the destination (the internet) via the NAT Gateway. This is your primary private subnet egress metric.
- Elastic load balancers and public instances (for public subnets): Instances in public subnets use the IGW to connect to the internet directly because they can have either a public IP or an elastic IP. You have to keep an eye on the resources themselves because the IGW lacks metrics. Use the NetworkOut metric in the AWS/EC2 namespace for EC2 instances. This metric must be added up for all pertinent instances in public subnets. Use the ProcessedBytes metric in the AWS/ApplicationELB or AWS/NetworkELB namespace for application/network load balancers. This is less accurate for pure egress becauseit counts both in and out.
3.Additional Points of Egress: Interface Endpoints, or VPC Endpoints: Keep an eye on the BytesOut metric in the AWS/PrivateLinkEndpoints namespace for traffic to AWS services. Site-to-Site VPN/Direct Connect: Keep an eye on the DataTransferOut metric for DX or the TunnelOutboundBytes metric for VPNs.
A CloudWatch dashboard is the suggested remedy. Although you can't make a single metric, you can make a CloudWatch Dashboard that shows the total of these elements.
- Make a fresh dashboard for CloudWatch.
- Include a Line or Number widget.
- To calculate the NAT Gateway contribution, add up the BytesOutFromDestination for each of your NAT Gateways using a metric math expression.
- This is more difficult for the public instance contribution. A metric math expression that adds up the NetworkOut for each EC2 instance in your public subnets would have to be made. Isolating these instances can be aided by resource tagging.
Example Metric Math Insight: Although it's complicated, you could estimate total egress using Metric Math:
//Traffic on NAT Gateways SUM (SEARCH('{AWS/NATGateway,NatGatewayId} MetricName="BytesOutFromDestination", 'Sum', 300)) + // Traffic from Public EC2 Instances (this needs to be carefully filtered) SUM (SEARCH('{AWS/EC2,InstanceId} MetricName="NetworkOut", 'Sum', 300))
Use a tool such as AWS VPC Flow Logs for a more scalable and manageable solution. Flow logs can be exported to Amazon S3 and subsequently examined using Amazon QuickSight or Athena. This provides you with comprehensive, unprocessed information about all IP traffic in your VPC, enabling you to make custom reports and aggregations to see the precise amount of outgoing traffic you have, filtered by port, source, or destination.
answered a year ago
Relevant content
asked 9 months ago
