/AWS1/IF_EC2=>GETCAPACITYMANAGERMETRICDATA()¶
About GetCapacityManagerMetricData¶
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.
Method Signature¶
METHODS /AWS1/IF_EC2~GETCAPACITYMANAGERMETRICDATA
IMPORTING
!IT_METRICNAMES TYPE /AWS1/CL_EC2METRICSET_W=>TT_METRICSET OPTIONAL
!IV_STARTTIME TYPE /AWS1/EC2MILLISECONDDATETIME OPTIONAL
!IV_ENDTIME TYPE /AWS1/EC2MILLISECONDDATETIME OPTIONAL
!IV_PERIOD TYPE /AWS1/EC2PERIOD OPTIONAL
!IT_GROUPBY TYPE /AWS1/CL_EC2GROUPBYSET_W=>TT_GROUPBYSET OPTIONAL
!IT_FILTERBY TYPE /AWS1/CL_EC2CAPMANAGERCOND=>TT_CAPACITYMANAGERCONDITIONSET OPTIONAL
!IV_MAXRESULTS TYPE /AWS1/EC2MAXRESULTS OPTIONAL
!IV_NEXTTOKEN TYPE /AWS1/EC2NEXTTOKEN OPTIONAL
!IV_DRYRUN TYPE /AWS1/EC2BOOLEAN OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_ec2getcapmanagermet01
RAISING
/AWS1/CX_EC2CLIENTEXC
/AWS1/CX_EC2SERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
it_metricnames TYPE /AWS1/CL_EC2METRICSET_W=>TT_METRICSET TT_METRICSET¶
The names of the metrics to retrieve. Maximum of 10 metrics per request.
iv_starttime TYPE /AWS1/EC2MILLISECONDDATETIME /AWS1/EC2MILLISECONDDATETIME¶
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.
iv_endtime TYPE /AWS1/EC2MILLISECONDDATETIME /AWS1/EC2MILLISECONDDATETIME¶
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.
iv_period TYPE /AWS1/EC2PERIOD /AWS1/EC2PERIOD¶
The granularity, in seconds, of the returned data points.
Optional arguments:¶
it_groupby TYPE /AWS1/CL_EC2GROUPBYSET_W=>TT_GROUPBYSET TT_GROUPBYSET¶
The dimensions by which to group the metric data. This determines how the data is aggregated and returned.
it_filterby TYPE /AWS1/CL_EC2CAPMANAGERCOND=>TT_CAPACITYMANAGERCONDITIONSET TT_CAPACITYMANAGERCONDITIONSET¶
Conditions to filter the metric data. Each filter specifies a dimension, comparison operator ('equals', 'in'), and values to match against.
iv_maxresults TYPE /AWS1/EC2MAXRESULTS /AWS1/EC2MAXRESULTS¶
The maximum number of data points to return. Valid range is 1 to 100,000. Use with NextToken for pagination of large result sets.
iv_nexttoken TYPE /AWS1/EC2NEXTTOKEN /AWS1/EC2NEXTTOKEN¶
The token for the next page of results. Use this value in a subsequent call to retrieve additional data points.
iv_dryrun TYPE /AWS1/EC2BOOLEAN /AWS1/EC2BOOLEAN¶
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 isUnauthorizedOperation.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_ec2getcapmanagermet01 /AWS1/CL_EC2GETCAPMANAGERMET01¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->getcapacitymanagermetricdata(
it_filterby = VALUE /aws1/cl_ec2capmanagercond=>tt_capacitymanagerconditionset(
(
new /aws1/cl_ec2capmanagercond(
io_dimensioncondition = new /aws1/cl_ec2dimensioncondition(
it_values = VALUE /aws1/cl_ec2condvaluelist_w=>tt_conditionvaluelist(
( new /aws1/cl_ec2condvaluelist_w( |string| ) )
)
iv_comparison = |string|
iv_dimension = |string|
)
)
)
)
it_groupby = VALUE /aws1/cl_ec2groupbyset_w=>tt_groupbyset(
( new /aws1/cl_ec2groupbyset_w( |string| ) )
)
it_metricnames = VALUE /aws1/cl_ec2metricset_w=>tt_metricset(
( new /aws1/cl_ec2metricset_w( |string| ) )
)
iv_dryrun = ABAP_TRUE
iv_endtime = '20150101000000.0000000'
iv_maxresults = 123
iv_nexttoken = |string|
iv_period = 123
iv_starttime = '20150101000000.0000000'
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
LOOP AT lo_result->get_metricdataresults( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lo_capacitymanagerdimensio = lo_row_1->get_dimension( ).
IF lo_capacitymanagerdimensio IS NOT INITIAL.
lv_string = lo_capacitymanagerdimensio->get_resourceregion( ).
lv_string = lo_capacitymanagerdimensio->get_availabilityzoneid( ).
lv_string = lo_capacitymanagerdimensio->get_accountid( ).
lv_string = lo_capacitymanagerdimensio->get_instancefamily( ).
lv_string = lo_capacitymanagerdimensio->get_instancetype( ).
lv_string = lo_capacitymanagerdimensio->get_instanceplatform( ).
lv_string = lo_capacitymanagerdimensio->get_reservationarn( ).
lv_string = lo_capacitymanagerdimensio->get_reservationid( ).
lv_reservationtype = lo_capacitymanagerdimensio->get_reservationtype( ).
lv_milliseconddatetime = lo_capacitymanagerdimensio->get_resvcreatetimestamp( ).
lv_milliseconddatetime = lo_capacitymanagerdimensio->get_rsvtarttimestamp( ).
lv_milliseconddatetime = lo_capacitymanagerdimensio->get_reservationendtimestamp( ).
lv_reservationenddatetype = lo_capacitymanagerdimensio->get_reservationenddatetype( ).
lv_capacitytenancy = lo_capacitymanagerdimensio->get_tenancy( ).
lv_reservationstate = lo_capacitymanagerdimensio->get_reservationstate( ).
lv_string = lo_capacitymanagerdimensio->get_resvinstmatchcriteria( ).
lv_string = lo_capacitymanagerdimensio->get_resvunusedfinancialowner( ).
ENDIF.
lv_milliseconddatetime = lo_row_1->get_timestamp( ).
LOOP AT lo_row_1->get_metricvalues( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_metric = lo_row_3->get_metric( ).
lv_double = lo_row_3->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
lv_nexttoken = lo_result->get_nexttoken( ).
ENDIF.