Skip to content

get_capacity_manager_metric_data

get_capacity_manager_metric_data(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    metric_names: Optional[MetricSet] = None,
    start_time: Optional[MillisecondDateTime] = None,
    end_time: Optional[MillisecondDateTime] = None,
    period: Optional[Period] = None,
    group_by: Optional[GroupBySet] = None,
    filter_by: Optional[CapacityManagerConditionSet] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[NextToken] = None,
    dry_run: Optional[Boolean] = None,
) -> GetCapacityManagerMetricDataResult

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.

Parameters:

  • metric_names (Optional[MetricSet], default: None ) –

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

  • start_time (Optional[MillisecondDateTime], default: None ) –

    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.

  • end_time (Optional[MillisecondDateTime], default: None ) –

    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.

  • period (Optional[Period], default: None ) –

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

  • group_by (Optional[GroupBySet], default: None ) –

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

  • filter_by (Optional[CapacityManagerConditionSet], default: None ) –

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

  • max_results (Optional[MaxResults], default: None ) –

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

  • next_token (Optional[NextToken], default: None ) –

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

  • dry_run (Optional[Boolean], default: None ) –

    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.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def get_capacity_manager_metric_data(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    metric_names: Optional["capo_ec2.types.metric_set.MetricSet"] = None,
    start_time: Optional[
        "capo_ec2.types.millisecond_date_time.MillisecondDateTime"
    ] = None,
    end_time: Optional[
        "capo_ec2.types.millisecond_date_time.MillisecondDateTime"
    ] = None,
    period: Optional["capo_ec2.types.period.Period"] = None,
    group_by: Optional["capo_ec2.types.group_by_set.GroupBySet"] = None,
    filter_by: Optional[
        "capo_ec2.types.capacity_manager_condition_set.CapacityManagerConditionSet"
    ] = None,
    max_results: Optional["capo_ec2.types.max_results.MaxResults"] = None,
    next_token: Optional["capo_ec2.types.next_token.NextToken"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.get_capacity_manager_metric_data_result.GetCapacityManagerMetricDataResult":
    """<p> 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. </p>

    Args:
        metric_names: <p> The names of the metrics to retrieve. Maximum of 10 metrics per request. </p>
        start_time: <p> 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. </p>
        end_time: <p> 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. </p>
        period: <p> The granularity, in seconds, of the returned data points. </p>
        group_by: <p> The dimensions by which to group the metric data. This determines how the data is aggregated and returned. </p>
        filter_by: <p> Conditions to filter the metric data. Each filter specifies a dimension, comparison operator ('equals', 'in'), and values to match against. </p>
        max_results: <p> The maximum number of data points to return. Valid range is 1 to 100,000. Use with NextToken for pagination of large result sets. </p>
        next_token: <p> The token for the next page of results. Use this value in a subsequent call to retrieve additional data points. </p>
        dry_run: <p> 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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>. </p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.get_capacity_manager_metric_data_request.GetCapacityManagerMetricDataRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.get_capacity_manager_metric_data_result.GetCapacityManagerMetricDataResult"
    ]:
        import capo_ec2._operations.amazon_ec2.get_capacity_manager_metric_data

        output, http_response = (
            capo_ec2._operations.amazon_ec2.get_capacity_manager_metric_data.get_capacity_manager_metric_data(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetCapacityManagerMetricData")
    )
    input_: capo_ec2.types.get_capacity_manager_metric_data_request.GetCapacityManagerMetricDataRequest = {}
    if metric_names is not None:
        input_["metric_names"] = metric_names
    if start_time is not None:
        input_["start_time"] = start_time
    if end_time is not None:
        input_["end_time"] = end_time
    if period is not None:
        input_["period"] = period
    if group_by is not None:
        input_["group_by"] = group_by
    if filter_by is not None:
        input_["filter_by"] = filter_by
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output