檢視變更請求的彙總計數 (命令列) - AWS Systems Manager

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

檢視變更請求的彙總計數 (命令列)

您可以使用 GetOpsSummary API 操作,在 Change Manager (AWS Systems Manager 的功能) 中,檢視變更請求的彙總計數,此 API 操作可以傳回單一 AWS 區域 或多個帳戶和多個區域中的單一 AWS 帳戶 的計數。

注意

如果您想要檢視多個 AWS 帳戶 和多個 AWS 區域 的變更請求的彙總計數,您必須安裝和設定資源資料同步。如需更多詳細資訊,請參閱 設定庫存的資源資料同步

下列程序說明如何使用 AWS Command Line Interface (AWS CLI) (位於 Linux、macOS 或 Windows) 來檢視變更請求的計數。

若有檢視變更請求的彙總計數
  1. 如果您尚未安裝並設定 AWS Command Line Interface (AWS CLI),請進行相應的操作。

    如需相關資訊,請參閱安裝或更新最新版本的 AWS CLI

  2. 請執行下列其中一個命令:

    單一帳戶和區域

    此命令會傳回針對為其設定 AWS CLI 工作階段的 AWS 帳戶 和 AWS 區域 的所有變更請求的計數。

    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" } ] } } } ] }

    多個帳戶及/或區域

    此命令會傳回針對資源資料同步中指定的 AWS 帳戶 和 AWS 區域 的所有變更請求的計數。

    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" } ] } } } ] }

    多個帳戶及特定區域

    此命令會傳回針對資源資料同步中指定的 AWS 帳戶 的所有變更請求的計數。但是,它只會傳回來自命令中指定的區域的資料

    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

    多個帳戶和區域 (具有按區域分組的輸出)

    此命令會傳回針對資源資料同步中指定的 AWS 帳戶 和 AWS 區域 的所有變更請求的計數。輸出會顯示每個區域的計數資訊。

    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" } ] } } } ] }

    多個帳戶和區域 (具有按區域分組的輸出)

    此命令會傳回針對資源資料同步中指定的 AWS 帳戶 和 AWS 區域 的所有變更請求的計數。輸出按帳戶和區域分組計數資訊。

    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" } ] } } } ] }