使用 Application Auto Scaling 的定时扩展 Amazon CLI - Application Auto Scaling
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Application Auto Scaling 的定时扩展 Amazon CLI

这些示例 Amazon CLI 命令描述了使用与 Application Auto Scaling 集成的服务中的资源进行的扩展活动和计划操作。对于不同的可扩展目标,请在 --service-namespace 中指定其命名空间,在 --scalable-dimension 中指定其可扩展维度,并在 --resource-id 中指定其资源 ID。

使用时 Amazon CLI,请记住您的命令在 Amazon Web Services 区域 配置文件中运行。如果您想要在不同的区域中运行命令,可以为配置文件更改默认区域,或者与命令一起使用 --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-id spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE \ --scheduled-action-names my-one-time-action

Windows

aws application-autoscaling describe-scheduled-actions --service-namespace ec2 ^ --resource-id spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE ^ --scheduled-action-names my-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 } ] }