AutoScaling / Client / describe_scaling_activities

describe_scaling_activities

AutoScaling.Client.describe_scaling_activities(**kwargs)

Gets information about the scaling activities in the account and Region.

When scaling events occur, you see a record of the scaling activity in the scaling activities. For more information, see Verify a scaling activity for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

If the scaling event succeeds, the value of the StatusCode element in the response is Successful. If an attempt to launch instances failed, the StatusCode value is Failed or Cancelled and the StatusMessage element in the response indicates the cause of the failure. For help interpreting the StatusMessage, see Troubleshooting Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

See also: AWS API Documentation

Request Syntax

response = client.describe_scaling_activities(
    ActivityIds=[
        'string',
    ],
    AutoScalingGroupName='string',
    IncludeDeletedGroups=True|False,
    MaxRecords=123,
    NextToken='string',
    Filters=[
        {
            'Name': 'string',
            'Values': [
                'string',
            ]
        },
    ]
)
Parameters:
  • ActivityIds (list) –

    The activity IDs of the desired scaling activities. If unknown activity IDs are requested, they are ignored with no error. Only activities started within the last six weeks can be returned regardless of the activity IDs specified. If other filters are specified with the request, only results matching all filter criteria can be returned.

    Array Members: Maximum number of 50 IDs.

    • (string) –

  • AutoScalingGroupName (string) –

    The name of the Auto Scaling group.

    Warning

    Omitting this property performs an account-wide operation, which can result in slower or timed-out requests.

  • IncludeDeletedGroups (boolean) – Indicates whether to include scaling activity from deleted Auto Scaling groups.

  • MaxRecords (integer) – The maximum number of items to return with this call. The default value is 100 and the maximum value is 100.

  • NextToken (string) – The token for the next set of items to return. (You received this token from a previous call.)

  • Filters (list) –

    One or more filters to limit the results based on specific criteria. The following filters are supported:

    • StartTimeLowerBound - The earliest scaling activities to return based on the activity start time. Scaling activities with a start time earlier than this value are not included in the results. Only activities started within the last six weeks can be returned regardless of the value specified.

    • StartTimeUpperBound - The latest scaling activities to return based on the activity start time. Scaling activities with a start time later than this value are not included in the results. Only activities started within the last six weeks can be returned regardless of the value specified.

    • Status - The StatusCode value of the scaling activity. This filter can only be used in combination with the AutoScalingGroupName parameter. For valid StatusCode values, see Activity in the Amazon EC2 Auto Scaling API Reference.

    • (dict) –

      Describes a filter that is used to return a more specific list of results from a describe operation.

      If you specify multiple filters, the filters are automatically logically joined with an AND, and the request returns only the results that match all of the specified filters.

      For more information, see Tag Auto Scaling groups and instances in the Amazon EC2 Auto Scaling User Guide.

      • Name (string) –

        The name of the filter.

        The valid values for Name depend on which API operation you’re using with the filter.

        DescribeAutoScalingGroups

        Valid values for Name include the following:

        • tag-key - Accepts tag keys. The results only include information about the Auto Scaling groups associated with these tag keys.

        • tag-value - Accepts tag values. The results only include information about the Auto Scaling groups associated with these tag values.

        • tag:<key> - Accepts the key/value combination of the tag. Use the tag key in the filter name and the tag value as the filter value. The results only include information about the Auto Scaling groups associated with the specified key/value combination.

        DescribeTags

        Valid values for Name include the following:

        • auto-scaling-group - Accepts the names of Auto Scaling groups. The results only include information about the tags associated with these Auto Scaling groups.

        • key - Accepts tag keys. The results only include information about the tags associated with these tag keys.

        • value - Accepts tag values. The results only include information about the tags associated with these tag values.

        • propagate-at-launch - Accepts a Boolean value, which specifies whether tags propagate to instances at launch. The results only include information about the tags associated with the specified Boolean value.

        DescribeScalingActivities

        Valid values for Name include the following:

        • StartTimeLowerBound - The earliest scaling activities to return based on the activity start time. Scaling activities with a start time earlier than this value are not included in the results. Only activities started within the last six weeks can be returned regardless of the value specified.

        • StartTimeUpperBound - The latest scaling activities to return based on the activity start time. Scaling activities with a start time later than this value are not included in the results. Only activities started within the last six weeks can be returned regardless of the value specified.

        • Status - The StatusCode value of the scaling activity. This filter can only be used in combination with the AutoScalingGroupName parameter. For valid StatusCode values, see Activity in the Amazon EC2 Auto Scaling API Reference.

      • Values (list) –

        One or more filter values. Filter values are case-sensitive.

        If you specify multiple values for a filter, the values are automatically logically joined with an OR, and the request returns all results that match any of the specified values.

        DescribeAutoScalingGroups example: Specify “tag:environment” for the filter name and “production,development” for the filter values to find Auto Scaling groups with the tag “environment=production” or “environment=development”.

        DescribeScalingActivities example: Specify “Status” for the filter name and “Successful,Failed” for the filter values to find scaling activities with a status of either “Successful” or “Failed”.

        • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'Activities': [
        {
            'ActivityId': 'string',
            'AutoScalingGroupName': 'string',
            'Description': 'string',
            'Cause': 'string',
            'StartTime': datetime(2015, 1, 1),
            'EndTime': datetime(2015, 1, 1),
            'StatusCode': 'PendingSpotBidPlacement'|'WaitingForSpotInstanceRequestId'|'WaitingForSpotInstanceId'|'WaitingForInstanceId'|'PreInService'|'InProgress'|'WaitingForELBConnectionDraining'|'MidLifecycleAction'|'WaitingForInstanceWarmup'|'Successful'|'Failed'|'Cancelled'|'WaitingForConnectionDraining'|'WaitingForInPlaceUpdateToStart'|'WaitingForInPlaceUpdateToFinalize'|'InPlaceUpdateInProgress',
            'StatusMessage': 'string',
            'Progress': 123,
            'Details': 'string',
            'AutoScalingGroupState': 'string',
            'AutoScalingGroupARN': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • Activities (list) –

      The scaling activities. Activities are sorted by start time. Activities still in progress are described first.

      • (dict) –

        Describes scaling activity, which is a long-running process that represents a change to your Auto Scaling group, such as changing its size or replacing an instance.

        • ActivityId (string) –

          The ID of the activity.

        • AutoScalingGroupName (string) –

          The name of the Auto Scaling group.

        • Description (string) –

          A friendly, more verbose description of the activity.

        • Cause (string) –

          The reason the activity began.

        • StartTime (datetime) –

          The start time of the activity.

        • EndTime (datetime) –

          The end time of the activity.

        • StatusCode (string) –

          The current status of the activity.

        • StatusMessage (string) –

          A friendly, more verbose description of the activity status.

        • Progress (integer) –

          A value between 0 and 100 that indicates the progress of the activity.

        • Details (string) –

          The details about the activity.

        • AutoScalingGroupState (string) –

          The state of the Auto Scaling group, which is either InService or Deleted.

        • AutoScalingGroupARN (string) –

          The Amazon Resource Name (ARN) of the Auto Scaling group.

    • NextToken (string) –

      A string that indicates that the response contains more items than can be returned in a single response. To receive additional items, specify this string for the NextToken value when requesting the next set of items. This value is null when there are no more items to return.

Exceptions

Examples

This example describes the scaling activities for the specified Auto Scaling group.

response = client.describe_scaling_activities(
    AutoScalingGroupName='my-auto-scaling-group',
)

print(response)

Expected Output:

{
    'Activities': [
        {
            'ActivityId': 'f9f2d65b-f1f2-43e7-b46d-d86756459699',
            'AutoScalingGroupARN': 'arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:12345678-1234-1234-1234-123456789012:autoScalingGroupName/my-auto-scaling-group',
            'AutoScalingGroupName': 'my-auto-scaling-group',
            'Cause': 'At 2013-08-19T20:53:25Z a user request created an AutoScalingGroup changing the desired capacity from 0 to 1.  At 2013-08-19T20:53:29Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1.',
            'Description': 'Launching a new EC2 instance: i-4ba0837f',
            'Details': 'details',
            'EndTime': datetime(2013, 8, 19, 20, 54, 2, 0, 231, 0),
            'Progress': 100,
            'StartTime': datetime(2013, 8, 19, 20, 53, 29, 0, 231, 0),
            'StatusCode': 'Successful',
        },
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}