Returns cost efficiency metrics aggregated over time and optionally grouped by a specified dimension. The metrics provide insights into your cost optimization progress by tracking estimated savings, spending, and measures how effectively you're optimizing your Cloud resources.
The operation supports both daily and monthly time granularities and allows grouping results by account ID, Amazon Web Services Region. Results are returned as time-series data, enabling you to analyze trends in your cost optimization performance over the specified time period.
Parameters:
-
group_by
(Optional[str], default:
None
)
–
The dimension by which to group the cost efficiency metrics. Valid values include account ID, Amazon Web Services Region. When no grouping is specified, metrics are aggregated across all resources in the specified time period.
-
granularity
(GranularityType)
–
The time granularity for the cost efficiency metrics. Specify Daily for metrics aggregated by day, or Monthly for metrics aggregated by month.
-
time_period
(TimePeriod)
–
The time period for which to retrieve the cost efficiency metrics. The start date is inclusive and the end date is exclusive. Dates can be specified in either YYYY-MM-DD format or YYYY-MM format depending on the desired granularity.
-
max_results
(Optional[MaxResults], default:
None
)
–
The maximum number of groups to return in the response. Valid values range from 0 to 1000. Use in conjunction with nextToken to paginate through results when the total number of groups exceeds this limit.
-
order_by
(Optional[OrderBy], default:
None
)
–
The ordering specification for the results. Defines which dimension to sort by and whether to sort in ascending or descending order.
-
next_token
(Optional[str], default:
None
)
–
The token to retrieve the next page of results. This value is returned in the response when the number of groups exceeds the specified maxResults value.
Raises:
Source code in docs_src/capo_cost_optimization_hub/_services/cost_optimization_hub.py
| def list_efficiency_metrics(
self,
granularity: "capo_cost_optimization_hub.types.granularity_type.GranularityType",
time_period: "capo_cost_optimization_hub.types.time_period.TimePeriod",
*,
config_overrides: Optional[CostOptimizationHubClientConfig] = None,
group_by: Optional[str] = None,
max_results: Optional[
"capo_cost_optimization_hub.types.max_results.MaxResults"
] = None,
order_by: Optional["capo_cost_optimization_hub.types.order_by.OrderBy"] = None,
next_token: Optional[str] = None,
) -> "capo_cost_optimization_hub.types.list_efficiency_metrics_response.ListEfficiencyMetricsResponse":
"""<p>Returns cost efficiency metrics aggregated over time and optionally grouped by a specified dimension. The metrics provide insights into your cost optimization progress by tracking estimated savings, spending, and measures how effectively you're optimizing your Cloud resources.</p> <p>The operation supports both daily and monthly time granularities and allows grouping results by account ID, Amazon Web Services Region. Results are returned as time-series data, enabling you to analyze trends in your cost optimization performance over the specified time period.</p>
Args:
group_by: <p>The dimension by which to group the cost efficiency metrics. Valid values include account ID, Amazon Web Services Region. When no grouping is specified, metrics are aggregated across all resources in the specified time period.</p>
granularity: <p>The time granularity for the cost efficiency metrics. Specify <code>Daily</code> for metrics aggregated by day, or <code>Monthly</code> for metrics aggregated by month.</p>
time_period: <p>The time period for which to retrieve the cost efficiency metrics. The start date is inclusive and the end date is exclusive. Dates can be specified in either YYYY-MM-DD format or YYYY-MM format depending on the desired granularity.</p>
max_results: <p>The maximum number of groups to return in the response. Valid values range from 0 to 1000. Use in conjunction with <code>nextToken</code> to paginate through results when the total number of groups exceeds this limit.</p>
order_by: <p>The ordering specification for the results. Defines which dimension to sort by and whether to sort in ascending or descending order.</p>
next_token: <p>The token to retrieve the next page of results. This value is returned in the response when the number of groups exceeds the specified <code>maxResults</code> value.</p>
Raises:
capo_cost_optimization_hub.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to use this operation with the given parameters.</p>
capo_cost_optimization_hub.errors.internal_server_exception.InternalServerException: <p>An error on the server occurred during the processing of your request. Try again later.</p>
capo_cost_optimization_hub.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
capo_cost_optimization_hub.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</p>
capo_cost_optimization_hub.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cost_optimization_hub.types.list_efficiency_metrics_request.ListEfficiencyMetricsRequest]",
) -> OperationResponse[
"capo_cost_optimization_hub.types.list_efficiency_metrics_response.ListEfficiencyMetricsResponse"
]:
import capo_cost_optimization_hub._operations.cost_optimization_hub_service.list_efficiency_metrics
output, http_response = (
capo_cost_optimization_hub._operations.cost_optimization_hub_service.list_efficiency_metrics.list_efficiency_metrics(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("ListEfficiencyMetrics")
)
input_: capo_cost_optimization_hub.types.list_efficiency_metrics_request.ListEfficiencyMetricsRequest = {
"granularity": granularity,
"time_period": time_period,
}
if group_by is not None:
input_["group_by"] = group_by
if max_results is not None:
input_["max_results"] = max_results
if order_by is not None:
input_["order_by"] = order_by
if next_token is not None:
input_["next_token"] = next_token
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|