DescribeScalingActivities 搭配 CLI 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

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

DescribeScalingActivities 搭配 CLI 使用

下列程式碼範例示範如何使用 DescribeScalingActivities

CLI
AWS CLI

範例 1:描述指定 Amazon ECS 服務的擴展活動

下列describe-scaling-activities範例說明default叢集中執行web-app的名為 的 Amazon ECS 服務的擴展活動。輸出會顯示由擴展政策啟動的擴展活動。

aws application-autoscaling describe-scaling-activities \ --service-namespace ecs \ --resource-id service/default/web-app

輸出:

{ "ScalingActivities": [ { "ScalableDimension": "ecs:service:DesiredCount", "Description": "Setting desired count to 1.", "ResourceId": "service/default/web-app", "ActivityId": "e6c5f7d1-dbbb-4a3f-89b2-51f33e766399", "StartTime": 1462575838.171, "ServiceNamespace": "ecs", "EndTime": 1462575872.111, "Cause": "monitor alarm web-app-cpu-lt-25 in state ALARM triggered policy web-app-cpu-lt-25", "StatusMessage": "Successfully set desired count to 1. Change successfully fulfilled by ecs.", "StatusCode": "Successful" } ] }

如需詳細資訊,請參閱 Application Auto Scaling 使用者指南中的 Application Auto Scaling 擴展活動 Auto Scaling

範例 2:描述指定 DynamoDB 資料表的擴展活動

下列describe-scaling-activities範例說明名為 的 DynamoDB 資料表的擴展活動TestTable。輸出會顯示由兩個不同的排程動作啟動的擴展活動。

aws application-autoscaling describe-scaling-activities \ --service-namespace dynamodb \ --resource-id table/TestTable

輸出:

{ "ScalingActivities": [ { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting write capacity units to 10.", "ResourceId": "table/my-table", "ActivityId": "4d1308c0-bbcf-4514-a673-b0220ae38547", "StartTime": 1561574415.086, "ServiceNamespace": "dynamodb", "EndTime": 1561574449.51, "Cause": "maximum capacity was set to 10", "StatusMessage": "Successfully set write capacity units to 10. Change successfully fulfilled by dynamodb.", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting min capacity to 5 and max capacity to 10", "ResourceId": "table/my-table", "ActivityId": "f2b7847b-721d-4e01-8ef0-0c8d3bacc1c7", "StartTime": 1561574414.644, "ServiceNamespace": "dynamodb", "Cause": "scheduled action name my-second-scheduled-action was triggered", "StatusMessage": "Successfully set min capacity to 5 and max capacity to 10", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting write capacity units to 15.", "ResourceId": "table/my-table", "ActivityId": "d8ea4de6-9eaa-499f-b466-2cc5e681ba8b", "StartTime": 1561574108.904, "ServiceNamespace": "dynamodb", "EndTime": 1561574140.255, "Cause": "minimum capacity was set to 15", "StatusMessage": "Successfully set write capacity units to 15. Change successfully fulfilled by dynamodb.", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting min capacity to 15 and max capacity to 20", "ResourceId": "table/my-table", "ActivityId": "3250fd06-6940-4e8e-bb1f-d494db7554d2", "StartTime": 1561574108.512, "ServiceNamespace": "dynamodb", "Cause": "scheduled action name my-first-scheduled-action was triggered", "StatusMessage": "Successfully set min capacity to 15 and max capacity to 20", "StatusCode": "Successful" } ] }

如需詳細資訊,請參閱 Application Auto Scaling 使用者指南中的 Application Auto Scaling 擴展活動 Auto Scaling

PowerShell
for PowerShell 工具

範例 1:提供過去六週內指定命名空間中擴展活動的描述性資訊。

Get-AASScalingActivity -ServiceNamespace AppStream

輸出:

ActivityId : 2827409f-b639-4cdb-a957-8055d5d07434 Cause : monitor alarm Appstream2-MyFleet-default-scale-in-Alarm in state ALARM triggered policy default-scale-in Description : Setting desired capacity to 2. Details : EndTime : 12/14/2019 11:32:49 AM ResourceId : fleet/MyFleet ScalableDimension : appstream:fleet:DesiredCapacity ServiceNamespace : appstream StartTime : 12/14/2019 11:32:14 AM StatusCode : Successful StatusMessage : Successfully set desired capacity to 2. Change successfully fulfilled by appstream.