"How do I calculate bandwidth and set a CloudWatch alarm for AWS Direct Connect, AWS Site-Site VPN, or Transit Gateway connections?"
"I have an AWS Direct Connect, AWS Site-to-Site VPN Connection, or an AWS Transit Gateway connection. I want to use Amazon CloudWatch metrics to calculate bandwidth and set up a bandwidth-based notification."
"I have an AWS Direct Connect, AWS Site-to-Site VPN Connection, or an AWS Transit Gateway connection. I want to use Amazon CloudWatch metrics to calculate bandwidth and set up a bandwidth-based notification.Short descriptionUse CloudWatch metrics to calculate bandwidth for an AWS Direct Connect connection, AWS Site-to-Site VPN, or AWS Transit Gateway connection. Then, create a CloudWatch alarm with an Simple Notification Service (Amazon SNS) notification to be alerted when bandwidth exceeds the values that you set.Important: Bandwidth calculation is approximate and doesn’t provide exact bandwidth usage up to the moment. A CloudWatch metrics-based alarm is effective for connections that exceed bandwidth for a duration of 15 minutes or more.Based on the type of connection that you have, see the related Resolution section to calculate the bandwidth and set up the CloudWatch alarm. You can also set up Amazon SNS notifications for the CloudWatch alarm.ResolutionDirect Connect connectionAccess the CloudWatch console.In the navigation pane, choose Metrics. Then, choose All metrics.Under All Metrics, choose DX. Then, choose Connection metrics.Select ConnectionBpsIngress and ConnectionBpsEgress for the Direct Connect connection that you want to measure.Choose the Graphed metrics tab and set following:Statistics: MaximumPeriod: 5 minutesChoose Add Math. From the dropdown list, choose Start with an empty expression.After you choose Start with an empty expression, a math expression box appears. In this box, enter (m1+m2).This formula calculates total bandwidth. The variables represent the following values:m1 = ConnectionBpsIngress (in bits per second)m2 = ConnectionBpsEgress (in bits per second)Choose Apply.In the graphed metrics section, the expression that you added and the metrics in the expression are listed. To see the representation in the graph section, select only the expression that you added: (m1+m2).The Output result is in bits per second.Configure your CloudWatch alarm for Direct Connect connections. Use the math expression that you calculated in the previous step for Metric. When creating the alarm, set the following values:For Select metric, re-enter the expression from the steps in the Calculate bandwidth for a Direct Connect connection section of this article. Select only the expression that you created.In the Conditions section, set bandwidth value that you want to monitor as a condition. For example, to be notified when bandwidth reaches 100Mbps, enter Greater/Equal(>=) 1,000,000,00.In the Additional configuration section, set Datapoints to alarm to 3 out of 3.[Optional] Set up Amazon SNS notifications for the CloudWatch alarm.Site-to-Site VPN connectionAccess the CloudWatch console.In the navigation pane, choose Metrics. Then, choose All metrics.Under All Metrics, choose VPN. Then, choose VPN tunnel metrics.Select TunnelDataIn and TunnelDataOut metrics for the VPN tunnel that you want to measure.Choose the Graphed metrics tab and set following parameters:Statistics: SUMPeriod: 5 minutesChoose Add Math. From the dropdown list, choose Start with an empty expression.After you choose Start with an empty expression, a math expression box appears. In this box, enter (m1+m2)*8/300.This formula converts bytes to bits, divides by time in seconds to calculate output in bits per second. The variables represent the following values:m1 = TunnelDataIn (in bytes)m2 = TunnelDataOut (in bytes)Choose Apply.In the graphed metrics section, the expression that you added and the metrics in the expression are listed. To see the representation in the graph section, select only the expression you added: (m1+m2)*8/300. The Output result is in bits per second.Configure your CloudWatch alarm for VPN connections. Use the math expression that you calculated in the previous step for Metric. When creating the alarm, set the following values:For Select metric, re-enter the expression from the steps in the Calculate bandwidth for a Site-to-Site VPN connection section of this article. Select only the expression that you created.In the Conditions section, set bandwidth value you want to monitor as a condition. For example, to be notified when bandwidth reaches 100Mbps, enter Greater/Equal(>=) 1,000,000,00.In the Additional configuration section**,** set Datapoints to alarm to 3 out of 3.[Optional] Set up Amazon SNS notifications for the CloudWatch alarm.Transit Gateway attachmentThe following procedure calculates bandwidth on a Transit Gateway VPC attachment. You can use a similar calculation on different types of attachments.Access the CloudWatch console.In the navigation pane, choose Metrics. Then, choose All metrics.Under All Metrics, choose Transit Gateway. Then, choose Per-TransitGatewayAttachment Metrics.Select BytesIn and BytesOut metrics for the Transit Gateway attachment that you want to measure.Choose the Graphed metrics tab, and then set following parameters:Statistics: SUMPeriod: 5 minutesChoose Add Math. From the dropdown list, choose Start with an empty expression.After you choose Start with an empty expression, a math expression box displays. In this box, enter (m1+m2)*8/300.This formula converts bytes to bits, divided by time in seconds to calculate output in bits per second. The variables represent the following values:m1 = BytesIn (in bytes)m2 = BytesOut (in bytes)Choose Apply.In the graphed metrics section, the expression that you added and the metrics in the expression are listed. To see the representation in the graph section, select only the expression you added: (m1+m2)*8/300. The Output result is in bits per second.Create a CloudWatch alarm based on a metric math expression. Use the math expression that you calculated in the previous step for Metric. When creating the alarm, set the following values:Set the following values when creating the alarm:For Select metric, re-enter the expression from the steps in the Calculate bandwidth for a Transit Gateway attachment section. Select only the expression that you created.In the Conditions section, set bandwidth value that you want to monitor as a condition. For example, to be notified when bandwidth reaches 100Mbps, enter Greater/Equal(>=) 1,000,000,00.In the Additional configuration section**,** set Datapoints to alarm to 3 out of 3.[Optional] Set up Amazon SNS notifications for the CloudWatch alarm.Related informationVPN tunnel metrics and dimensionsAWS Direct Connect metrics and dimensionsAWS Transit Gateway metricsFollow"