0
0
DynamoDBquery~5 mins

CloudWatch metrics for DynamoDB

Choose your learning style9 modes available
Introduction

CloudWatch metrics help you see how your DynamoDB tables are working. They show if your database is healthy and fast.

You want to check if your DynamoDB table is handling requests well.
You need to find out if your database is running out of capacity.
You want to monitor errors or throttling in your DynamoDB usage.
You want to track how much data your table stores over time.
You want to set alarms to get notified if something goes wrong.
Syntax
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.

Examples
This gets the average read capacity used by the table 'MyTable' in 5-minute intervals for one hour.
DynamoDB
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
This shows the total number of throttled requests in one-minute intervals for the table 'MyTable'.
DynamoDB
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
Sample Program

This command fetches the average write capacity units consumed by the DynamoDB table named 'ExampleTable' in 5-minute intervals over 15 minutes.

DynamoDB
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
OutputSuccess
Important Notes

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.

Summary

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.