Search code examples
amazon-dynamodbamazon-cloudwatch

Creating a DynamoDB Cloudwatch metric grouped by partitionKey


Im am trying to find if it is even possible to create a cloudwatch metric for a dynamoDB table that is grouped by the partitionkey of said table. For example, showing the number of writes to the table grouped by PartitionKey over the last 24 hours, or even just total count by partition key.


Solution

  • I imagine you are trying to understand the traffic in your partitions, You can enable Amazon CloudWatch Contributor Insights to provide information about the most accessed and throttled items in a table or global secondary index.

    Once you enable it you can create graphics with this detailed information to perform the analysis you want. (Here is the link from the official documentation). You will have 4 rules created in CloudWatch:

    If your table has partition key only:

    • Most accessed items: The most popular partition keys accessed in your table or GSI (global secondary index).
    • Most throttled keys: The keys that have been throttled the most in your table or GSI.

    IF your table has partition and sort key:

    • Most accessed keys: Identity the partition and sort key most accessed in your table or GSI.
    • Most throttled keys. Highlights the partition and sort key of your most throttled items in your table or GSI.

    You can enable it in the console as the picture below indicates.

    Enabling CloudWatch contributor insights