Amazon Elastic Compute Cloud

2025/12/15 - Amazon Elastic Compute Cloud - 2 updated api methods

Changes  EC2 Capacity Manager now supports SpotTotalCount, SpotTotalInterruptions and SpotInterruptionRate metrics for both vCPU and instance units.

GetCapacityManagerMetricData (updated) Link ¶
Changes (request, response)
Request
{'MetricNames': {'spot-interruption-rate-inst',
                 'spot-interruption-rate-vcpu',
                 'spot-total-count-inst',
                 'spot-total-count-vcpu',
                 'spot-total-interruptions-inst',
                 'spot-total-interruptions-vcpu'}}
Response
{'MetricDataResults': {'MetricValues': {'Metric': {'spot-interruption-rate-inst',
                                                   'spot-interruption-rate-vcpu',
                                                   'spot-total-count-inst',
                                                   'spot-total-count-vcpu',
                                                   'spot-total-interruptions-inst',
                                                   'spot-total-interruptions-vcpu'}}}}

Retrieves capacity usage metrics for your EC2 resources. Returns time-series data for metrics like unused capacity, utilization rates, and costs across On-Demand, Spot, and Capacity Reservations. Data can be grouped and filtered by various dimensions such as region, account, and instance family.

See also: AWS API Documentation

Request Syntax

client.get_capacity_manager_metric_data(
    MetricNames=[
        'reservation-total-capacity-hrs-vcpu'|'reservation-total-capacity-hrs-inst'|'reservation-max-size-vcpu'|'reservation-max-size-inst'|'reservation-min-size-vcpu'|'reservation-min-size-inst'|'reservation-unused-total-capacity-hrs-vcpu'|'reservation-unused-total-capacity-hrs-inst'|'reservation-unused-total-estimated-cost'|'reservation-max-unused-size-vcpu'|'reservation-max-unused-size-inst'|'reservation-min-unused-size-vcpu'|'reservation-min-unused-size-inst'|'reservation-max-utilization'|'reservation-min-utilization'|'reservation-avg-utilization-vcpu'|'reservation-avg-utilization-inst'|'reservation-total-count'|'reservation-total-estimated-cost'|'reservation-avg-future-size-vcpu'|'reservation-avg-future-size-inst'|'reservation-min-future-size-vcpu'|'reservation-min-future-size-inst'|'reservation-max-future-size-vcpu'|'reservation-max-future-size-inst'|'reservation-avg-committed-size-vcpu'|'reservation-avg-committed-size-inst'|'reservation-max-committed-size-vcpu'|'reservation-max-committed-size-inst'|'reservation-min-committed-size-vcpu'|'reservation-min-committed-size-inst'|'reserved-total-usage-hrs-vcpu'|'reserved-total-usage-hrs-inst'|'reserved-total-estimated-cost'|'unreserved-total-usage-hrs-vcpu'|'unreserved-total-usage-hrs-inst'|'unreserved-total-estimated-cost'|'spot-total-usage-hrs-vcpu'|'spot-total-usage-hrs-inst'|'spot-total-estimated-cost'|'spot-avg-run-time-before-interruption-inst'|'spot-max-run-time-before-interruption-inst'|'spot-min-run-time-before-interruption-inst'|'spot-total-interruptions-inst'|'spot-total-interruptions-vcpu'|'spot-total-count-inst'|'spot-total-count-vcpu'|'spot-interruption-rate-inst'|'spot-interruption-rate-vcpu',
    ],
    StartTime=datetime(2015, 1, 1),
    EndTime=datetime(2015, 1, 1),
    Period=123,
    GroupBy=[
        'resource-region'|'availability-zone-id'|'account-id'|'instance-family'|'instance-type'|'instance-platform'|'reservation-arn'|'reservation-id'|'reservation-type'|'reservation-create-timestamp'|'reservation-start-timestamp'|'reservation-end-timestamp'|'reservation-end-date-type'|'tenancy'|'reservation-state'|'reservation-instance-match-criteria'|'reservation-unused-financial-owner',
    ],
    FilterBy=[
        {
            'DimensionCondition': {
                'Dimension': 'resource-region'|'availability-zone-id'|'account-id'|'instance-family'|'instance-type'|'instance-platform'|'reservation-arn'|'reservation-id'|'reservation-type'|'reservation-create-timestamp'|'reservation-start-timestamp'|'reservation-end-timestamp'|'reservation-end-date-type'|'tenancy'|'reservation-state'|'reservation-instance-match-criteria'|'reservation-unused-financial-owner',
                'Comparison': 'equals'|'in',
                'Values': [
                    'string',
                ]
            }
        },
    ],
    MaxResults=123,
    NextToken='string',
    DryRun=True|False
)
type MetricNames:

list

param MetricNames:

[REQUIRED]

The names of the metrics to retrieve. Maximum of 10 metrics per request.

  • (string) --

type StartTime:

datetime

param StartTime:

[REQUIRED]

The start time for the metric data query, in ISO 8601 format. The time range (end time - start time) must be a multiple of the specified period.

type EndTime:

datetime

param EndTime:

[REQUIRED]

The end time for the metric data query, in ISO 8601 format. If the end time is beyond the latest ingested data, it will be automatically adjusted to the latest available data point.

type Period:

integer

param Period:

[REQUIRED]

The granularity, in seconds, of the returned data points.

type GroupBy:

list

param GroupBy:

The dimensions by which to group the metric data. This determines how the data is aggregated and returned.

  • (string) --

type FilterBy:

list

param FilterBy:

Conditions to filter the metric data. Each filter specifies a dimension, comparison operator ('equals', 'in'), and values to match against.

  • (dict) --

    Represents a filter condition for Capacity Manager queries. Contains dimension-based filtering criteria used to narrow down metric data and dimension results.

    • DimensionCondition (dict) --

      The dimension-based condition that specifies how to filter the data based on dimension values.

      • Dimension (string) --

        The name of the dimension to filter by.

      • Comparison (string) --

        The comparison operator to use for the filter.

      • Values (list) --

        The list of values to match against the specified dimension. For 'equals' comparison, only the first value is used. For 'in' comparison, any matching value will satisfy the condition.

        • (string) --

type MaxResults:

integer

param MaxResults:

The maximum number of data points to return. Valid range is 1 to 100,000. Use with NextToken for pagination of large result sets.

type NextToken:

string

param NextToken:

The token for the next page of results. Use this value in a subsequent call to retrieve additional data points.

type DryRun:

boolean

param DryRun:

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

rtype:

dict

returns:

Response Syntax

{
    'MetricDataResults': [
        {
            'Dimension': {
                'ResourceRegion': 'string',
                'AvailabilityZoneId': 'string',
                'AccountId': 'string',
                'InstanceFamily': 'string',
                'InstanceType': 'string',
                'InstancePlatform': 'string',
                'ReservationArn': 'string',
                'ReservationId': 'string',
                'ReservationType': 'capacity-block'|'odcr',
                'ReservationCreateTimestamp': datetime(2015, 1, 1),
                'ReservationStartTimestamp': datetime(2015, 1, 1),
                'ReservationEndTimestamp': datetime(2015, 1, 1),
                'ReservationEndDateType': 'limited'|'unlimited',
                'Tenancy': 'default'|'dedicated',
                'ReservationState': 'active'|'expired'|'cancelled'|'scheduled'|'pending'|'failed'|'delayed'|'unsupported'|'payment-pending'|'payment-failed'|'retired',
                'ReservationInstanceMatchCriteria': 'string',
                'ReservationUnusedFinancialOwner': 'string'
            },
            'Timestamp': datetime(2015, 1, 1),
            'MetricValues': [
                {
                    'Metric': 'reservation-total-capacity-hrs-vcpu'|'reservation-total-capacity-hrs-inst'|'reservation-max-size-vcpu'|'reservation-max-size-inst'|'reservation-min-size-vcpu'|'reservation-min-size-inst'|'reservation-unused-total-capacity-hrs-vcpu'|'reservation-unused-total-capacity-hrs-inst'|'reservation-unused-total-estimated-cost'|'reservation-max-unused-size-vcpu'|'reservation-max-unused-size-inst'|'reservation-min-unused-size-vcpu'|'reservation-min-unused-size-inst'|'reservation-max-utilization'|'reservation-min-utilization'|'reservation-avg-utilization-vcpu'|'reservation-avg-utilization-inst'|'reservation-total-count'|'reservation-total-estimated-cost'|'reservation-avg-future-size-vcpu'|'reservation-avg-future-size-inst'|'reservation-min-future-size-vcpu'|'reservation-min-future-size-inst'|'reservation-max-future-size-vcpu'|'reservation-max-future-size-inst'|'reservation-avg-committed-size-vcpu'|'reservation-avg-committed-size-inst'|'reservation-max-committed-size-vcpu'|'reservation-max-committed-size-inst'|'reservation-min-committed-size-vcpu'|'reservation-min-committed-size-inst'|'reserved-total-usage-hrs-vcpu'|'reserved-total-usage-hrs-inst'|'reserved-total-estimated-cost'|'unreserved-total-usage-hrs-vcpu'|'unreserved-total-usage-hrs-inst'|'unreserved-total-estimated-cost'|'spot-total-usage-hrs-vcpu'|'spot-total-usage-hrs-inst'|'spot-total-estimated-cost'|'spot-avg-run-time-before-interruption-inst'|'spot-max-run-time-before-interruption-inst'|'spot-min-run-time-before-interruption-inst'|'spot-total-interruptions-inst'|'spot-total-interruptions-vcpu'|'spot-total-count-inst'|'spot-total-count-vcpu'|'spot-interruption-rate-inst'|'spot-interruption-rate-vcpu',
                    'Value': 123.0
                },
            ]
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • MetricDataResults (list) --

      The metric data points returned by the query. Each result contains dimension values, timestamp, and metric values with their associated statistics.

      • (dict) --

        Contains a single data point from a capacity metrics query, including the dimension values, timestamp, and metric values for that specific combination.

        • Dimension (dict) --

          The dimension values that identify this specific data point, such as account ID, region, and instance family.

          • ResourceRegion (string) --

            The Amazon Web Services Region where the capacity resource is located.

          • AvailabilityZoneId (string) --

            The unique identifier of the Availability Zone where the capacity resource is located.

          • AccountId (string) --

            The Amazon Web Services account ID that owns the capacity resource.

          • InstanceFamily (string) --

            The EC2 instance family of the capacity resource.

          • InstanceType (string) --

            The specific EC2 instance type of the capacity resource.

          • InstancePlatform (string) --

            The platform or operating system of the instance.

          • ReservationArn (string) --

            The Amazon Resource Name (ARN) of the capacity reservation. This provides a unique identifier that can be used across Amazon Web Services services to reference the specific reservation.

          • ReservationId (string) --

            The unique identifier of the capacity reservation.

          • ReservationType (string) --

            The type of capacity reservation.

          • ReservationCreateTimestamp (datetime) --

            The timestamp when the capacity reservation was originally created, in milliseconds since epoch. This differs from the start timestamp as reservations can be created before they become active.

          • ReservationStartTimestamp (datetime) --

            The timestamp when the capacity reservation becomes active and available for use, in milliseconds since epoch. This is when the reservation begins providing capacity.

          • ReservationEndTimestamp (datetime) --

            The timestamp when the capacity reservation expires and is no longer available, in milliseconds since epoch. After this time, the reservation will not provide any capacity.

          • ReservationEndDateType (string) --

            The type of end date for the capacity reservation. This indicates whether the reservation has a fixed end date, is open-ended, or follows a specific termination pattern.

          • Tenancy (string) --

            The tenancy of the EC2 instances associated with this capacity dimension. Valid values are 'default' for shared tenancy, 'dedicated' for dedicated instances, or 'host' for dedicated hosts.

          • ReservationState (string) --

            The current state of the capacity reservation.

          • ReservationInstanceMatchCriteria (string) --

            The instance matching criteria for the capacity reservation, determining how instances are matched to the reservation.

          • ReservationUnusedFinancialOwner (string) --

            The Amazon Web Services account ID that is financially responsible for unused capacity reservation costs.

        • Timestamp (datetime) --

          The timestamp for this data point, indicating when the capacity usage occurred.

        • MetricValues (list) --

          The metric values and statistics for this data point, containing the actual capacity usage numbers.

          • (dict) --

            Represents a single metric value with its associated statistic, such as the sum or average of unused capacity hours.

            • Metric (string) --

              The name of the metric.

            • Value (float) --

              The numerical value of the metric for the specified statistic and time period.

    • NextToken (string) --

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.

GetCapacityManagerMetricDimensions (updated) Link ¶
Changes (request)
{'MetricNames': {'spot-interruption-rate-inst',
                 'spot-interruption-rate-vcpu',
                 'spot-total-count-inst',
                 'spot-total-count-vcpu',
                 'spot-total-interruptions-inst',
                 'spot-total-interruptions-vcpu'}}

Retrieves the available dimension values for capacity metrics within a specified time range. This is useful for discovering what accounts, regions, instance families, and other dimensions have data available for filtering and grouping.

See also: AWS API Documentation

Request Syntax

client.get_capacity_manager_metric_dimensions(
    GroupBy=[
        'resource-region'|'availability-zone-id'|'account-id'|'instance-family'|'instance-type'|'instance-platform'|'reservation-arn'|'reservation-id'|'reservation-type'|'reservation-create-timestamp'|'reservation-start-timestamp'|'reservation-end-timestamp'|'reservation-end-date-type'|'tenancy'|'reservation-state'|'reservation-instance-match-criteria'|'reservation-unused-financial-owner',
    ],
    FilterBy=[
        {
            'DimensionCondition': {
                'Dimension': 'resource-region'|'availability-zone-id'|'account-id'|'instance-family'|'instance-type'|'instance-platform'|'reservation-arn'|'reservation-id'|'reservation-type'|'reservation-create-timestamp'|'reservation-start-timestamp'|'reservation-end-timestamp'|'reservation-end-date-type'|'tenancy'|'reservation-state'|'reservation-instance-match-criteria'|'reservation-unused-financial-owner',
                'Comparison': 'equals'|'in',
                'Values': [
                    'string',
                ]
            }
        },
    ],
    StartTime=datetime(2015, 1, 1),
    EndTime=datetime(2015, 1, 1),
    MetricNames=[
        'reservation-total-capacity-hrs-vcpu'|'reservation-total-capacity-hrs-inst'|'reservation-max-size-vcpu'|'reservation-max-size-inst'|'reservation-min-size-vcpu'|'reservation-min-size-inst'|'reservation-unused-total-capacity-hrs-vcpu'|'reservation-unused-total-capacity-hrs-inst'|'reservation-unused-total-estimated-cost'|'reservation-max-unused-size-vcpu'|'reservation-max-unused-size-inst'|'reservation-min-unused-size-vcpu'|'reservation-min-unused-size-inst'|'reservation-max-utilization'|'reservation-min-utilization'|'reservation-avg-utilization-vcpu'|'reservation-avg-utilization-inst'|'reservation-total-count'|'reservation-total-estimated-cost'|'reservation-avg-future-size-vcpu'|'reservation-avg-future-size-inst'|'reservation-min-future-size-vcpu'|'reservation-min-future-size-inst'|'reservation-max-future-size-vcpu'|'reservation-max-future-size-inst'|'reservation-avg-committed-size-vcpu'|'reservation-avg-committed-size-inst'|'reservation-max-committed-size-vcpu'|'reservation-max-committed-size-inst'|'reservation-min-committed-size-vcpu'|'reservation-min-committed-size-inst'|'reserved-total-usage-hrs-vcpu'|'reserved-total-usage-hrs-inst'|'reserved-total-estimated-cost'|'unreserved-total-usage-hrs-vcpu'|'unreserved-total-usage-hrs-inst'|'unreserved-total-estimated-cost'|'spot-total-usage-hrs-vcpu'|'spot-total-usage-hrs-inst'|'spot-total-estimated-cost'|'spot-avg-run-time-before-interruption-inst'|'spot-max-run-time-before-interruption-inst'|'spot-min-run-time-before-interruption-inst'|'spot-total-interruptions-inst'|'spot-total-interruptions-vcpu'|'spot-total-count-inst'|'spot-total-count-vcpu'|'spot-interruption-rate-inst'|'spot-interruption-rate-vcpu',
    ],
    MaxResults=123,
    NextToken='string',
    DryRun=True|False
)
type GroupBy:

list

param GroupBy:

[REQUIRED]

The dimensions to group by when retrieving available dimension values. This determines which dimension combinations are returned. Required parameter.

  • (string) --

type FilterBy:

list

param FilterBy:

Conditions to filter which dimension values are returned. Each filter specifies a dimension, comparison operator, and values to match against.

  • (dict) --

    Represents a filter condition for Capacity Manager queries. Contains dimension-based filtering criteria used to narrow down metric data and dimension results.

    • DimensionCondition (dict) --

      The dimension-based condition that specifies how to filter the data based on dimension values.

      • Dimension (string) --

        The name of the dimension to filter by.

      • Comparison (string) --

        The comparison operator to use for the filter.

      • Values (list) --

        The list of values to match against the specified dimension. For 'equals' comparison, only the first value is used. For 'in' comparison, any matching value will satisfy the condition.

        • (string) --

type StartTime:

datetime

param StartTime:

[REQUIRED]

The start time for the dimension query, in ISO 8601 format. Only dimensions with data in this time range will be returned.

type EndTime:

datetime

param EndTime:

[REQUIRED]

The end time for the dimension query, in ISO 8601 format. Only dimensions with data in this time range will be returned.

type MetricNames:

list

param MetricNames:

[REQUIRED]

The metric names to use as an additional filter when retrieving dimensions. Only dimensions that have data for these metrics will be returned. Required parameter with maximum size of 1 for v1.

  • (string) --

type MaxResults:

integer

param MaxResults:

The maximum number of dimension combinations to return. Valid range is 1 to 1000. Use with NextToken for pagination.

type NextToken:

string

param NextToken:

The token for the next page of results. Use this value in a subsequent call to retrieve additional dimension values.

type DryRun:

boolean

param DryRun:

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

rtype:

dict

returns:

Response Syntax

{
    'MetricDimensionResults': [
        {
            'ResourceRegion': 'string',
            'AvailabilityZoneId': 'string',
            'AccountId': 'string',
            'InstanceFamily': 'string',
            'InstanceType': 'string',
            'InstancePlatform': 'string',
            'ReservationArn': 'string',
            'ReservationId': 'string',
            'ReservationType': 'capacity-block'|'odcr',
            'ReservationCreateTimestamp': datetime(2015, 1, 1),
            'ReservationStartTimestamp': datetime(2015, 1, 1),
            'ReservationEndTimestamp': datetime(2015, 1, 1),
            'ReservationEndDateType': 'limited'|'unlimited',
            'Tenancy': 'default'|'dedicated',
            'ReservationState': 'active'|'expired'|'cancelled'|'scheduled'|'pending'|'failed'|'delayed'|'unsupported'|'payment-pending'|'payment-failed'|'retired',
            'ReservationInstanceMatchCriteria': 'string',
            'ReservationUnusedFinancialOwner': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • MetricDimensionResults (list) --

      The available dimension combinations that have data within the specified time range and filters.

      • (dict) --

        Represents dimension values for capacity metrics, including resource identifiers, geographic information, and reservation details used for grouping and filtering capacity data.

        • ResourceRegion (string) --

          The Amazon Web Services Region where the capacity resource is located.

        • AvailabilityZoneId (string) --

          The unique identifier of the Availability Zone where the capacity resource is located.

        • AccountId (string) --

          The Amazon Web Services account ID that owns the capacity resource.

        • InstanceFamily (string) --

          The EC2 instance family of the capacity resource.

        • InstanceType (string) --

          The specific EC2 instance type of the capacity resource.

        • InstancePlatform (string) --

          The platform or operating system of the instance.

        • ReservationArn (string) --

          The Amazon Resource Name (ARN) of the capacity reservation. This provides a unique identifier that can be used across Amazon Web Services services to reference the specific reservation.

        • ReservationId (string) --

          The unique identifier of the capacity reservation.

        • ReservationType (string) --

          The type of capacity reservation.

        • ReservationCreateTimestamp (datetime) --

          The timestamp when the capacity reservation was originally created, in milliseconds since epoch. This differs from the start timestamp as reservations can be created before they become active.

        • ReservationStartTimestamp (datetime) --

          The timestamp when the capacity reservation becomes active and available for use, in milliseconds since epoch. This is when the reservation begins providing capacity.

        • ReservationEndTimestamp (datetime) --

          The timestamp when the capacity reservation expires and is no longer available, in milliseconds since epoch. After this time, the reservation will not provide any capacity.

        • ReservationEndDateType (string) --

          The type of end date for the capacity reservation. This indicates whether the reservation has a fixed end date, is open-ended, or follows a specific termination pattern.

        • Tenancy (string) --

          The tenancy of the EC2 instances associated with this capacity dimension. Valid values are 'default' for shared tenancy, 'dedicated' for dedicated instances, or 'host' for dedicated hosts.

        • ReservationState (string) --

          The current state of the capacity reservation.

        • ReservationInstanceMatchCriteria (string) --

          The instance matching criteria for the capacity reservation, determining how instances are matched to the reservation.

        • ReservationUnusedFinancialOwner (string) --

          The Amazon Web Services account ID that is financially responsible for unused capacity reservation costs.

    • NextToken (string) --

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.