查看更改请求的聚合计数(命令行) - Amazon Systems Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

查看更改请求的聚合计数(命令行)

您可以使用 GetOpsSummary API 操作,查看 Amazon Systems Manager 的功能 Change Manager 中的更改请求的聚合计数。此 API 操作可以返回单个 Amazon Web Services 区域中的单个 Amazon Web Services 账户的计数,或者多个账户和多个区域的计数。

注意

如果您要查看多个 Amazon Web Services 账户 和多个 Amazon Web Services 区域 的聚合计数,必须设置和配置资源数据同步。有关更多信息,请参阅 为 Inventory 配置资源数据同步

以下过程介绍了如何使用 Amazon Command Line Interface (Amazon CLI)(在 Linux、macOS 或 Windows 上)查看更改请求的聚合计数。

查看更改请求的聚合计数

  1. 安装并配置 Amazon Command Line Interface (Amazon CLI)(如果尚未执行该操作)。

    想要了解有关信息,请参阅安装或升级Amazon命令行工具.

  2. 运行以下命令之一。

    Single account and Region (单个账户和区域

    此命令将返回为其配置您的 Amazon CLI 会话的 Amazon Web Services 账户 和 Amazon Web Services 区域 的所有更改请求的计数。

    Linux & macOS
    aws ssm get-ops-summary \ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal \ --aggregators AggregatorType=count,AttributeName=Status,TypeName=AWS:OpsItem
    Windows
    aws ssm get-ops-summary ^ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal ^ --aggregators AggregatorType=count,AttributeName=Status,TypeName=AWS:OpsItem

    该调用将返回类似于以下内容的信息。

    { "Entities": [ { "Data": { "AWS:OpsItem": { "Content": [ { "Count": "38", "Status": "Open" } ] } } } ] }

    Multiple accounts and/or Regions (多个账户和/或区域

    此命令将返回在资源数据同步中指定的 Amazon Web Services 账户和 Amazon Web Services 区域的所有更改请求的计数。

    Linux & macOS
    aws ssm get-ops-summary \ --sync-name resource_data_sync_name \ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal \ --aggregators AggregatorType=count,AttributeName=Status,TypeName=AWS:OpsItem
    Windows
    aws ssm get-ops-summary ^ --sync-name resource_data_sync_name ^ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal ^ --aggregators AggregatorType=count,AttributeName=Status,TypeName=AWS:OpsItem

    该调用将返回类似于以下内容的信息。

    { "Entities": [ { "Data": { "AWS:OpsItem": { "Content": [ { "Count": "43", "Status": "Open" }, { "Count": "2", "Status": "Resolved" } ] } } } ] }

    Multiple accounts and a specific Region (多个账户和某一特定区域

    此命令将返回在资源数据同步中指定的 Amazon Web Services 账户 的所有更改请求的计数。但是,它只会返回该命令中指定的区域中的数据。

    Linux & macOS
    aws ssm get-ops-summary \ --sync-name resource_data_sync_name \ --filters Key=AWS:OpsItem.SourceRegion,Values='Region',Type=Equal Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal \ --aggregators AggregatorType=count,AttributeName=Status,TypeName=AWS:OpsItem
    Windows
    aws ssm get-ops-summary ^ --sync-name resource_data_sync_name ^ --filters Key=AWS:OpsItem.SourceRegion,Values='Region',Type=Equal Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal ^ --aggregators AggregatorType=count,AttributeName=Status,TypeName=AWS:OpsItem

    Multiple accounts and Regions with output grouped by Region (输出按区域分组的多个账户和区域

    此命令将返回在资源数据同步中指定的 Amazon Web Services 账户和 Amazon Web Services 区域的所有更改请求的计数。输出将显示每个区域的计数信息。

    Linux & macOS
    aws ssm get-ops-summary \ --sync-name resource_data_sync_name \ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal \ --aggregators '[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"Status","Aggregators":[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"SourceRegion"}]}]'
    Windows
    aws ssm get-ops-summary ^ --sync-name resource_data_sync_name ^ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal ^ --aggregators '[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"Status","Aggregators":[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"SourceRegion"}]}]'

    该调用将返回类似于以下内容的信息。

    { "Entities": [ { "Data": { "AWS:OpsItem": { "Content": [ { "Count": "38", "SourceRegion": "us-east-1", "Status": "Open" }, { "Count": "4", "SourceRegion": "us-east-2", "Status": "Open" }, { "Count": "1", "SourceRegion": "us-west-1", "Status": "Open" }, { "Count": "2", "SourceRegion": "us-east-2", "Status": "Resolved" } ] } } } ] }

    Multiple accounts and Regions with output grouped by accounts and Regions (输出按帐户和区域分组的多个账户和区域

    此命令将返回在资源数据同步中指定的 Amazon Web Services 账户和 Amazon Web Services 区域的所有更改请求的计数。输出将按账户和区域对计数信息进行分组。

    Linux & macOS
    aws ssm get-ops-summary \ --sync-name resource_data_sync_name \ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal \ --aggregators '[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"Status","Aggregators":[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"SourceAccountId","Aggregators":[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"SourceRegion"}]}]}]'
    Windows
    aws ssm get-ops-summary ^ --sync-name resource_data_sync_name ^ --filters Key=AWS:OpsItem.OpsItemType,Values="/aws/changerequests",Type=Equal ^ --aggregators '[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"Status","Aggregators":[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"SourceAccountId","Aggregators":[{"AggregatorType":"count","TypeName":"AWS:OpsItem","AttributeName":"SourceRegion"}]}]}]'

    该调用将返回类似于以下内容的信息。

    { "Entities": [ { "Data": { "AWS:OpsItem": { "Content": [ { "Count": "38", "SourceAccountId": "123456789012", "SourceRegion": "us-east-1", "Status": "Open" }, { "Count": "4", "SourceAccountId": "111122223333", "SourceRegion": "us-east-2", "Status": "Open" }, { "Count": "1", "SourceAccountId": "111122223333", "SourceRegion": "us-west-1", "Status": "Open" }, { "Count": "2", "SourceAccountId": "444455556666", "SourceRegion": "us-east-2", "Status": "Resolved" }, { "Count": "1", "SourceAccountId": "222222222222", "SourceRegion": "us-east-1", "Status": "Open" } ] } } } ] }