CloudWatch Contributor Insights for DynamoDB 入门 - Amazon DynamoDB
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

CloudWatch Contributor Insights for DynamoDB 入门

本节介绍如何将 Amazon CloudWatch Contributor Insights 与 Amazon DynamoDB 控制台或 Amazon Command Line Interface (Amazon CLI) 一起使用。

在以下示例中,您将使用 DynamoDB 入门教程中定义的 DynamoDB 表。

使用 Contributor Insights(控制台)

  1. 登录 Amazon Web Services Management Console,打开 API Gateway 控制台:https://console.aws.amazon.com/dynamodb/

  2. 在控制台左侧的导航窗格中,选择

  3. 选择 Music 表。

  4. 选择 Contributor Insights 选项卡。

  5. 选择管理 Contributor Insights

    
                        显示 Contributor Insights 选项卡和按钮的控制台屏幕截图。
  6. Manage Contributor Insights (管理 Contributor Insights) 对话框的 Contributor Insights Status (Conductor Insights 状态) 下方,为 Music 基表和 AlbumTitle-index 全局二级索引选择 Enabled (已启用)。然后,选择确认

    
                        显示 Contributor Insights 状态列表选项的控制台屏幕截图。

    如果操作失败,请参阅 Amazon DynamoDB API 参考中的 DescribeContributorInsights FailureException 了解可能的原因。

  7. 选择 View in DynamoDB (在 DynamoDB 中查看)

    
                        显示 Contributor Insights 设置中的“在 DynamoDB 中查看”按钮的控制台屏幕截图。
  8. Contributor Insights 图表现在可以在 Music 表的 Contributor Insights 选项卡查看。

    
                        显示 Contributor Insights 选项卡和 music 表多个图表的控制台屏幕截图。

创建 CloudWatch 告警

请按照以下步骤创建 CloudWatch 告警,并在任何分区键占用超过 50,000 ConsumedThroughputUnits 时收到通知。

  1. 登录 Amazon Web Services Management Console,打开 CloudWatch 控制台:https://console.aws.amazon.com/cloudwatch/

  2. 在控制台左侧的导航窗格中,选择 Contributor Insights

  3. 选择 DynamoDBContributorInsights-PKC-Music 规则。

  4. 选择 Actions (操作) 下拉菜单。

  5. 选择 View in metrics (查看指标)

  6. 选择 Max Contributor Value (最大贡献者值)

    注意

    Max Contributor ValueMaximum 返回有用的统计信息。此列表中的其他统计信息不返回有意义的值。

    
                        显示 Contributor Insights 选项卡和按钮的控制台屏幕截图。
  7. Actions (操作) 列选择 Create Alarm (创建告警)

    
                        显示 Contributor Insights 状态列表选项的控制台屏幕截图。
  8. 阈值输入值 50000,然后选择 Next (下一步)

    
                        显示 Contributor Insights 选项卡和按钮的控制台屏幕截图。
  9. 有关如何为警报配置通知的详细信息,请参阅使用 Amazon CloudWatch 警报

使用 Contributor Insights(Amazon CLI)

  1. Music 基表启用 CloudWatch Contributor Insights for DynamoDB。

    aws dynamodb update-contributor-insights --table-name Music --contributor-insights-action=ENABLE
  2. AlbumTitle-index 全局二级索引启用 Contributor Insights for DynamoDB。

    aws dynamodb update-contributor-insights --table-name Music --index-name AlbumTitle-index --contributor-insights-action=ENABLE
  3. 获取 Music 表及其所有索引的状态与规则。

    aws dynamodb describe-contributor-insights --table-name Music
  4. AlbumTitle-index 全局二级索引禁用 CloudWatch Contributor Insights for DynamoDB。

    aws dynamodb update-contributor-insights --table-name Music --index-name AlbumTitle-index --contributor-insights-action=DISABLE
  5. 获取 Music 表及其所有索引的状态。

    aws dynamodb list-contributor-insights --table-name Music