I have an AWS Transit Gateway attachment. I want to use Amazon CloudWatch metrics to calculate throughput, and set up a throughput-based notification.

## Short description

Use CloudWatch metrics to calculate throughput for a Transit Gateway attachment. To create an alert for when throughput exceeds your specified values, create a CloudWatch alarm with an Amazon Simple Notification Service (Amazon SNS) notification.

**Important**: Throughput calculation is approximate and doesn't provide exact up-to-the-moment bandwidth usage. A CloudWatch metrics alarm is effective for connections that exceed throughput for a duration of 15 minutes or more.

## Resolution

The following steps calculate throughput on a Transit Gateway attachment. You can use a similar calculation on different types of attachments:

- Open the CloudWatch console, and then choose the AWS Region that's associated with your transit gateway.
- In the navigation pane, choose
**Metrics**. Then, choose **All metrics**.
- Under
**All Metrics**, choose **TransitGateway**. Then, choose **Per-TransitGatewayAttachmentMetrics**.
- Select the
**BytesIn** and **BytesOut** metrics for the Transit Gateway attachment that you want to measure.
- Choose the
**Graphed metrics** tab, and then set the following parameters:

**Statistics: SUM**

**Period: 5 minutes**
- Choose
**Add Math**.
- From the dropdown list, choose
**Start with an empty expression**, and then in the math expression box enter **(m1+m2)*8/300**.

This formula converts bytes per second (Bps) to bits per second (bps) to calculate the output. The variables represent the following values:

**m1** = **BytesIn**

**m2** = **BytesOut**
- Choose
**Apply**.
- In the graphed metrics section, you see the expression that you added and the metrics in the expression. To see the representation in the graph section, select only the expression that you added:
**(m1+m2)*8/300**. The output is in **bits per second**.

**Note:** Clear **m1** and **m2** so that you select only the math expression.
- Create a CloudWatch alarm based on a metric math expression. When you create the alarm, set the following values:

For **Select metric**, enter the **expression** that you created in step 7. Select only this expression.

In the **Conditions** section, set the throughput value that you want to monitor as a condition. For example, to be notified when throughput reaches 100 Mbps, 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 information

Transit Gateway metrics