CloudWatch metrics help you see how your DynamoDB tables are working. They show if your database is healthy and fast.
CloudWatch metrics for DynamoDB
aws cloudwatch get-metric-statistics \ --namespace AWS/DynamoDB \ --metric-name <MetricName> \ --dimensions Name=TableName,Value=<YourTableName> \ --start-time <StartTime> \ --end-time <EndTime> \ --period <PeriodInSeconds> \ --statistics <StatisticType>
Replace <MetricName> with the metric you want, like ConsumedReadCapacityUnits.
Use the TableName dimension to specify which table you want metrics for.
aws cloudwatch get-metric-statistics \ --namespace AWS/DynamoDB \ --metric-name ConsumedReadCapacityUnits \ --dimensions Name=TableName,Value=MyTable \ --start-time 2024-04-01T00:00:00Z \ --end-time 2024-04-01T01:00:00Z \ --period 300 \ --statistics Average
aws cloudwatch get-metric-statistics \ --namespace AWS/DynamoDB \ --metric-name ThrottledRequests \ --dimensions Name=TableName,Value=MyTable \ --start-time 2024-04-01T00:00:00Z \ --end-time 2024-04-01T01:00:00Z \ --period 60 \ --statistics Sum
This command fetches the average write capacity units consumed by the DynamoDB table named 'ExampleTable' in 5-minute intervals over 15 minutes.
aws cloudwatch get-metric-statistics \ --namespace AWS/DynamoDB \ --metric-name ConsumedWriteCapacityUnits \ --dimensions Name=TableName,Value=ExampleTable \ --start-time 2024-06-01T00:00:00Z \ --end-time 2024-06-01T00:15:00Z \ --period 300 \ --statistics Average
CloudWatch metrics update every minute, so recent data might not be available immediately.
You can use these metrics to create alarms that notify you if your table is overused or underused.
Common metrics include ConsumedReadCapacityUnits, ConsumedWriteCapacityUnits, ThrottledRequests, and SuccessfulRequestLatency.
CloudWatch metrics show how your DynamoDB tables perform over time.
You use AWS CLI or SDKs to get these metrics by specifying the metric name and table.
Monitoring these helps keep your database fast and reliable.