Getting started with CloudWatch Contributor Insights for DynamoDB
This section describes how to enable and use Amazon CloudWatch Contributor Insights in different modes to meet your monitoring needs using the Amazon DynamoDB console or the Amazon Command Line Interface (Amazon CLI).
In the following examples, you use the DynamoDB table that is defined in the Getting started with DynamoDB tutorial.
Topics
Choosing a Contributor Insights mode
Before enabling Contributor Insights, you should understand the two available modes. Review the mode comparison to select the option that best aligns with your specific requirements.
Aspect | Accessed and throttled keys mode | Throttled keys mode |
---|---|---|
Monitors | All requests (successful and throttled) | Only throttled requests |
Graphs | Most Accessed Items + Most Throttled Items | Most Throttled Items only |
Best for | Targeted analysis and optimization | Throttling monitoring |
Use when | You need complete visibility into access patterns. You're doing short-term analysis or debugging. | Your primary concern is identifying and resolving throttling issues. You want to keep Contributor Insights enabled continuously for real-time throttling alerts. |
Using Contributor Insights (console)
The console provides an intuitive way to enable Contributor Insights and select the appropriate mode for your monitoring needs.
To use Contributor Insights in the console
Sign in to the Amazon Web Services Management Console and open the DynamoDB console at https://console.amazonaws.cn/dynamodb/
. -
In the navigation pane on the left side of the console, choose Tables.
-
Choose the
Music
table. -
Choose the Monitor tab.
-
Choose Turn on CloudWatch Contributor Insights.
-
In the Manage CloudWatch Contributor Insights settings dialog box, toggle Turn on for both the
Music
base table and theAlbumTitle-index
global secondary index. -
Leave the Only throttled keys mode toggle in the off position for both and then choose Save changes.
This enables the default accessed and throttled keys mode for both the table and GSI, which provides monitoring of both accessed and throttled items. Switching the Only throttled keys mode toggle to the on position would enable the throttled keys mode.
If the operation fails, see DescribeContributorInsights FailureException in the Amazon DynamoDB API Reference for possible reasons.
-
The CloudWatch Contributor Insights graphs are now visible on the Monitor tab for the
Music
table. Since you enabled accessed and throttled keys mode, you see both accessed and throttled item graphs.
Switching between modes
You can switch between modes at any time without disabling Contributor Insights.
To switch Contributor Insights modes
-
On the Monitor tab of your table, choose Manage CloudWatch Contributor Insights.
-
In the Manage Contributor Insights settings dialog box, for each base table or GSIs:
-
Toggle Only throttled keys mode on or off to enable the throttled keys mode or go back to the default accessed and throttled keys mode.
-
Toggle Turn on off to disable CloudWatch Contributor Insight for a table or GSI.
-
-
Choose Save changes.
Once complete, the graphs will reflect the new mode.
Creating CloudWatch alarms
Follow these steps to create a CloudWatch alarm and be notified when any partition key consumes more than 50,000 ConsumedThroughputUnits or experiences throttling.
-
Sign in to the Amazon Web Services Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
-
In the navigation pane on the left side of the console, choose Contributor Insights.
-
Choose the appropriate rule based on your mode and what you want to monitor:
-
For accessed items monitoring (accessed and throttled keys mode only): Choose DynamoDBContributorInsights-PKC-Music
-
For throttled items monitoring (both modes): Choose DynamoDBContributorInsights-PKT-Music
-
-
Choose the Actions drop down.
-
Choose View in metrics.
-
Choose Max Contributor Value.
Note
Only
Max Contributor Value
andMaximum
return useful statistics. The other statistics in this list don't return meaningful values. -
On the Actions column, Choose Create Alarm.
-
Enter an appropriate threshold value and choose Next:
-
For accessed items (PKC rules): Enter 50000 for
ConsumedThroughputUnits
-
For throttled items (PKT rules): Enter 1 for
ThrottleCount
to be alerted on any throttling
-
-
See Using Amazon CloudWatch alarms for details on how to configure the notification for the alarm.
Using Contributor Insights (Amazon CLI)
The Amazon CLI provides programmatic access to Contributor Insights with full support for both modes. You can specify the mode when enabling Contributor Insights or switch modes later.
Basic operations with default mode
To use Contributor Insights with default settings
-
Enable CloudWatch Contributor Insights for DynamoDB on the
Music
base table with the accessed and throttled keys mode. SinceACCESSED_AND_THROTTLED_KEYS
is the default mode, you can omit the--contributor-insights-mode=ACCESSED_AND_THROTTLED_KEYS
parameter.aws dynamodb update-contributor-insights \ --table-name Music \ --contributor-insights-action=ENABLE
-
Enable Contributor Insights for DynamoDB on the
AlbumTitle-index
global secondary index.aws dynamodb update-contributor-insights \ --table-name Music \ --index-name AlbumTitle-index \ --contributor-insights-action=ENABLE
-
Get the status and rules for the
Music
table and all its indexes.aws dynamodb describe-contributor-insights --table-name Music
The response will include the
ContributorInsightsMode
field showingACCESSED_AND_THROTTLED_KEYS
. -
List the status of the
Music
table and all its indexes.aws dynamodb list-contributor-insights --table-name Music
Enabling throttled keys mode
To enable Contributor Insights in throttled keys mode
-
Enable CloudWatch Contributor Insights for DynamoDB on the
Music
base table with throttled keys mode.aws dynamodb update-contributor-insights \ --table-name Music \ --contributor-insights-action=ENABLE \ --contributor-insights-mode=THROTTLED_KEYS
-
Enable Contributor Insights in throttled keys mode for the
AlbumTitle-index
global secondary index.aws dynamodb update-contributor-insights \ --table-name Music \ --index-name AlbumTitle-index \ --contributor-insights-action=ENABLE \ --contributor-insights-mode=THROTTLED_KEYS
-
Verify the mode by describing the Contributor Insights configuration.
aws dynamodb describe-contributor-insights --table-name Music
The response will show
ContributorInsightsMode
asTHROTTLED_KEYS
and fewer rules compared to the default mode.
Switching between modes
To switch Contributor Insights modes
-
Switch from throttled keys mode to accessed and throttled keys mode.
aws dynamodb update-contributor-insights \ --table-name Music \ --contributor-insights-action=ENABLE \ --contributor-insights-mode=ACCESSED_AND_THROTTLED_KEYS
-
Switch from accessed and throttled keys mode to throttled keys mode.
aws dynamodb update-contributor-insights \ --table-name Music \ --contributor-insights-action=ENABLE \ --contributor-insights-mode=THROTTLED_KEYS
-
Check the status during the transition.
aws dynamodb describe-contributor-insights --table-name Music
During the mode switch, the
ContributorInsightsStatus
will show asENABLING
. Once complete, it will show asENABLED
with the new mode.
Managing Contributor Insights
To manage Contributor Insights settings
-
Disable CloudWatch Contributor Insights for DynamoDB on the
AlbumTitle-index
global secondary index.aws dynamodb update-contributor-insights \ --table-name Music --index-name AlbumTitle-index \ --contributor-insights-action=DISABLE
-
List all Contributor Insights configurations in your account.
aws dynamodb list-contributor-insights
This shows all tables and indexes with Contributor Insights enabled, along with their modes.
-
Get detailed information about a specific configuration.
aws dynamodb describe-contributor-insights \ --table-name Music \ --index-name AlbumTitle-index
Example responses
Here are example responses showing the differences between modes:
Accessed and throttled keys mode response
{ "TableName": "Music", "ContributorInsightsRuleList": [ "DynamoDBContributorInsights-PKC-Music-1234567890123", "DynamoDBContributorInsights-PKT-Music-1234567890123", "DynamoDBContributorInsights-SKC-Music-1234567890123", "DynamoDBContributorInsights-SKT-Music-1234567890123" ], "ContributorInsightsStatus": "ENABLED", "ContributorInsightsMode": "ACCESSED_AND_THROTTLED_KEYS", "LastUpdateDateTime": "2024-01-15T10:30:00.000Z" }
Throttled keys mode response
{ "TableName": "Music", "ContributorInsightsRuleList": [ "DynamoDBContributorInsights-PKT-Music-1234567890123", "DynamoDBContributorInsights-SKT-Music-1234567890123" ], "ContributorInsightsStatus": "ENABLED", "ContributorInsightsMode": "THROTTLED_KEYS", "LastUpdateDateTime": "2024-01-15T10:35:00.000Z" }
Notice that throttled keys mode has fewer rules (only PKT and SKT), which corresponds to a more focused monitoring.