本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 描述 Application Auto Scaling 的排程擴展 AWS CLI
這些範例 AWS CLI 命令描述使用與 Application Auto Scaling 整合之 服務的資源擴展活動和排程動作。對於不同的可擴展目標,請在 中指定其命名空間--service-namespace
、在 中指定其可擴展維度--scalable-dimension
,以及在 中指定其資源 ID--resource-id
。
使用 時 AWS CLI,請記住,您的命令會在為設定檔 AWS 區域 設定的 中執行。如果您想在不同區域中執行命令,則可變更設定檔的預設區域,或搭配 --region
參數使用命令。
描述服務的擴展活動
若要檢視指定服務命名空間中所有可擴展目標的擴展活動,請使用 describe-scaling-activities命令。
以下範例會擷取與 dynamodb
服務命名空間相關聯的擴展活動。
Linux、macOS 或 Unix
aws application-autoscaling describe-scaling-activities --service-namespace
dynamodb
Windows
aws application-autoscaling describe-scaling-activities --service-namespace
dynamodb
輸出
如果命令成功,則會傳回類似下列的輸出。
{
"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"
}
]
}
若要將此命令變更為只擷取其中一個可擴展目標的擴展活動,請增加 --resource-id
選項。
描述服務的排程動作
若要描述指定服務命名空間中所有可擴展目標的排程動作,請使用 describe-scheduled-actions命令。
以下範例會擷取與 ec2
服務命名空間相關聯的排定動作。
Linux、macOS 或 Unix
aws application-autoscaling describe-scheduled-actions --service-namespace
ec2
Windows
aws application-autoscaling describe-scheduled-actions --service-namespace
ec2
輸出
如果命令成功,則會傳回類似下列的輸出。
{
"ScheduledActions": [
{
"ScheduledActionName": "my-one-time-action",
"ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:493a6261-fbb9-432d-855d-3c302c14bdb9:resource/ec2/spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE:scheduledActionName/my-one-time-action",
"ServiceNamespace": "ec2",
"Schedule": "at(2021-01-31T17:00:00)",
"Timezone": "America/New_York",
"ResourceId": "spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE",
"ScalableDimension": "ec2:spot-fleet-request:TargetCapacity",
"ScalableTargetAction": {
"MaxCapacity": 1
},
"CreationTime": 1607454792.331
},
{
"ScheduledActionName": "my-recurring-action",
"ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:493a6261-fbb9-432d-855d-3c302c14bdb9:resource/ec2/spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE:scheduledActionName/my-recurring-action",
"ServiceNamespace": "ec2",
"Schedule": "rate(5 minutes)",
"ResourceId": "spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE",
"ScalableDimension": "ec2:spot-fleet-request:TargetCapacity",
"StartTime": 1604059200.0,
"EndTime": 1612130400.0,
"ScalableTargetAction": {
"MinCapacity": 3,
"MaxCapacity": 10
},
"CreationTime": 1607454949.719
},
{
"ScheduledActionName": "my-one-time-action",
"ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:4bce34c7-bb81-4ecf-b776-5c726efb1567:resource/ec2/spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE:scheduledActionName/my-one-time-action",
"ServiceNamespace": "ec2",
"Schedule": "at(2020-12-08T9:36:00)",
"Timezone": "America/New_York",
"ResourceId": "spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE",
"ScalableDimension": "ec2:spot-fleet-request:TargetCapacity",
"ScalableTargetAction": {
"MinCapacity": 1,
"MaxCapacity": 3
},
"CreationTime": 1607456031.391
}
]
}
描述可擴展目標的排程動作
若要擷取指定可擴展目標排程動作的相關資訊,請在使用 describe-scheduled-actions命令描述排程動作時新增 --resource-id
選項。
如果您包含 --scheduled-action-names
選項並指定排定動作的名稱作為值,則此命令只會傳回名稱相符的排定動作,如下列範例所示。
Linux、macOS 或 Unix
aws application-autoscaling describe-scheduled-actions --service-namespace
ec2
\ --resource-idspot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE
\ --scheduled-action-namesmy-one-time-action
Windows
aws application-autoscaling describe-scheduled-actions --service-namespace
ec2
^ --resource-idspot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE
^ --scheduled-action-namesmy-one-time-action
輸出
如果命令成功,則會傳回類似下列的輸出。如果您為 提供多個值--scheduled-action-names
,輸出會包含名稱相符的所有排程動作。
{
"ScheduledActions": [
{
"ScheduledActionName": "my-one-time-action",
"ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:4bce34c7-bb81-4ecf-b776-5c726efb1567:resource/ec2/spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE:scheduledActionName/my-one-time-action",
"ServiceNamespace": "ec2",
"Schedule": "at(2020-12-08T9:36:00)",
"Timezone": "America/New_York",
"ResourceId": "spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE",
"ScalableDimension": "ec2:spot-fleet-request:TargetCapacity",
"ScalableTargetAction": {
"MinCapacity": 1,
"MaxCapacity": 3
},
"CreationTime": 1607456031.391
}
]
}