GetReservationUtilizationCommand

Retrieves the reservation utilization for your account. Management account in an organization have access to member accounts. You can filter data by dimensions in a time period. You can use GetDimensionValues to determine the possible dimension values. Currently, you can group only by SUBSCRIPTION_ID.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CostExplorerClient, GetReservationUtilizationCommand } from "@aws-sdk/client-cost-explorer"; // ES Modules import
// const { CostExplorerClient, GetReservationUtilizationCommand } = require("@aws-sdk/client-cost-explorer"); // CommonJS import
const client = new CostExplorerClient(config);
const input = { // GetReservationUtilizationRequest
  TimePeriod: { // DateInterval
    Start: "STRING_VALUE", // required
    End: "STRING_VALUE", // required
  },
  GroupBy: [ // GroupDefinitions
    { // GroupDefinition
      Type: "DIMENSION" || "TAG" || "COST_CATEGORY",
      Key: "STRING_VALUE",
    },
  ],
  Granularity: "DAILY" || "MONTHLY" || "HOURLY",
  Filter: { // Expression
    Or: [ // Expressions
      {
        Or: [
          "<Expression>",
        ],
        And: [
          "<Expression>",
        ],
        Not: "<Expression>",
        Dimensions: { // DimensionValues
          Key: "AZ" || "INSTANCE_TYPE" || "LINKED_ACCOUNT" || "LINKED_ACCOUNT_NAME" || "OPERATION" || "PURCHASE_TYPE" || "REGION" || "SERVICE" || "SERVICE_CODE" || "USAGE_TYPE" || "USAGE_TYPE_GROUP" || "RECORD_TYPE" || "OPERATING_SYSTEM" || "TENANCY" || "SCOPE" || "PLATFORM" || "SUBSCRIPTION_ID" || "LEGAL_ENTITY_NAME" || "DEPLOYMENT_OPTION" || "DATABASE_ENGINE" || "CACHE_ENGINE" || "INSTANCE_TYPE_FAMILY" || "BILLING_ENTITY" || "RESERVATION_ID" || "RESOURCE_ID" || "RIGHTSIZING_TYPE" || "SAVINGS_PLANS_TYPE" || "SAVINGS_PLAN_ARN" || "PAYMENT_OPTION" || "AGREEMENT_END_DATE_TIME_AFTER" || "AGREEMENT_END_DATE_TIME_BEFORE" || "INVOICING_ENTITY" || "ANOMALY_TOTAL_IMPACT_ABSOLUTE" || "ANOMALY_TOTAL_IMPACT_PERCENTAGE",
          Values: [ // Values
            "STRING_VALUE",
          ],
          MatchOptions: [ // MatchOptions
            "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
          ],
        },
        Tags: { // TagValues
          Key: "STRING_VALUE",
          Values: [
            "STRING_VALUE",
          ],
          MatchOptions: [
            "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
          ],
        },
        CostCategories: { // CostCategoryValues
          Key: "STRING_VALUE",
          Values: [
            "STRING_VALUE",
          ],
          MatchOptions: [
            "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
          ],
        },
      },
    ],
    And: [
      "<Expression>",
    ],
    Not: "<Expression>",
    Dimensions: {
      Key: "AZ" || "INSTANCE_TYPE" || "LINKED_ACCOUNT" || "LINKED_ACCOUNT_NAME" || "OPERATION" || "PURCHASE_TYPE" || "REGION" || "SERVICE" || "SERVICE_CODE" || "USAGE_TYPE" || "USAGE_TYPE_GROUP" || "RECORD_TYPE" || "OPERATING_SYSTEM" || "TENANCY" || "SCOPE" || "PLATFORM" || "SUBSCRIPTION_ID" || "LEGAL_ENTITY_NAME" || "DEPLOYMENT_OPTION" || "DATABASE_ENGINE" || "CACHE_ENGINE" || "INSTANCE_TYPE_FAMILY" || "BILLING_ENTITY" || "RESERVATION_ID" || "RESOURCE_ID" || "RIGHTSIZING_TYPE" || "SAVINGS_PLANS_TYPE" || "SAVINGS_PLAN_ARN" || "PAYMENT_OPTION" || "AGREEMENT_END_DATE_TIME_AFTER" || "AGREEMENT_END_DATE_TIME_BEFORE" || "INVOICING_ENTITY" || "ANOMALY_TOTAL_IMPACT_ABSOLUTE" || "ANOMALY_TOTAL_IMPACT_PERCENTAGE",
      Values: [
        "STRING_VALUE",
      ],
      MatchOptions: [
        "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
      ],
    },
    Tags: {
      Key: "STRING_VALUE",
      Values: [
        "STRING_VALUE",
      ],
      MatchOptions: [
        "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
      ],
    },
    CostCategories: {
      Key: "STRING_VALUE",
      Values: "<Values>",
      MatchOptions: "<MatchOptions>",
    },
  },
  SortBy: { // SortDefinition
    Key: "STRING_VALUE", // required
    SortOrder: "ASCENDING" || "DESCENDING",
  },
  NextPageToken: "STRING_VALUE",
  MaxResults: Number("int"),
};
const command = new GetReservationUtilizationCommand(input);
const response = await client.send(command);
// { // GetReservationUtilizationResponse
//   UtilizationsByTime: [ // UtilizationsByTime // required
//     { // UtilizationByTime
//       TimePeriod: { // DateInterval
//         Start: "STRING_VALUE", // required
//         End: "STRING_VALUE", // required
//       },
//       Groups: [ // ReservationUtilizationGroups
//         { // ReservationUtilizationGroup
//           Key: "STRING_VALUE",
//           Value: "STRING_VALUE",
//           Attributes: { // Attributes
//             "<keys>": "STRING_VALUE",
//           },
//           Utilization: { // ReservationAggregates
//             UtilizationPercentage: "STRING_VALUE",
//             UtilizationPercentageInUnits: "STRING_VALUE",
//             PurchasedHours: "STRING_VALUE",
//             PurchasedUnits: "STRING_VALUE",
//             TotalActualHours: "STRING_VALUE",
//             TotalActualUnits: "STRING_VALUE",
//             UnusedHours: "STRING_VALUE",
//             UnusedUnits: "STRING_VALUE",
//             OnDemandCostOfRIHoursUsed: "STRING_VALUE",
//             NetRISavings: "STRING_VALUE",
//             TotalPotentialRISavings: "STRING_VALUE",
//             AmortizedUpfrontFee: "STRING_VALUE",
//             AmortizedRecurringFee: "STRING_VALUE",
//             TotalAmortizedFee: "STRING_VALUE",
//             RICostForUnusedHours: "STRING_VALUE",
//             RealizedSavings: "STRING_VALUE",
//             UnrealizedSavings: "STRING_VALUE",
//           },
//         },
//       ],
//       Total: {
//         UtilizationPercentage: "STRING_VALUE",
//         UtilizationPercentageInUnits: "STRING_VALUE",
//         PurchasedHours: "STRING_VALUE",
//         PurchasedUnits: "STRING_VALUE",
//         TotalActualHours: "STRING_VALUE",
//         TotalActualUnits: "STRING_VALUE",
//         UnusedHours: "STRING_VALUE",
//         UnusedUnits: "STRING_VALUE",
//         OnDemandCostOfRIHoursUsed: "STRING_VALUE",
//         NetRISavings: "STRING_VALUE",
//         TotalPotentialRISavings: "STRING_VALUE",
//         AmortizedUpfrontFee: "STRING_VALUE",
//         AmortizedRecurringFee: "STRING_VALUE",
//         TotalAmortizedFee: "STRING_VALUE",
//         RICostForUnusedHours: "STRING_VALUE",
//         RealizedSavings: "STRING_VALUE",
//         UnrealizedSavings: "STRING_VALUE",
//       },
//     },
//   ],
//   Total: "<ReservationAggregates>",
//   NextPageToken: "STRING_VALUE",
// };

GetReservationUtilizationCommand Input

Parameter
Type
Description
TimePeriod
Required
DateInterval | undefined

Sets the start and end dates for retrieving Reserved Instance (RI) utilization. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01, then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01.

Filter
Expression | undefined

Filters utilization data by dimensions. You can filter by the following dimensions:

  • AZ

  • CACHE_ENGINE

  • DEPLOYMENT_OPTION

  • INSTANCE_TYPE

  • LINKED_ACCOUNT

  • OPERATING_SYSTEM

  • PLATFORM

  • REGION

  • SERVICE

    If not specified, the SERVICE filter defaults to Amazon Elastic Compute Cloud - Compute. Supported values for SERVICE are Amazon Elastic Compute Cloud - Compute, Amazon Relational Database Service, Amazon ElastiCache, Amazon Redshift, and Amazon Elasticsearch Service. The value for the SERVICE filter should not exceed "1".

  • SCOPE

  • TENANCY

GetReservationUtilization uses the same Expression  object as the other operations, but only AND is supported among each dimension, and nesting is supported up to only one level deep. If there are multiple values for a dimension, they are OR'd together.

Granularity
Granularity | undefined

If GroupBy is set, Granularity can't be set. If Granularity isn't set, the response object doesn't include Granularity, either MONTHLY or DAILY. If both GroupBy and Granularity aren't set, GetReservationUtilization defaults to DAILY.

The GetReservationUtilization operation supports only DAILY and MONTHLY granularities.

GroupBy
GroupDefinition[] | undefined

Groups only by SUBSCRIPTION_ID. Metadata is included.

MaxResults
number | undefined

The maximum number of objects that you returned for this request. If more objects are available, in the response, Amazon Web Services provides a NextPageToken value that you can use in a subsequent call to get the next batch of objects.

NextPageToken
string | undefined

The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.

SortBy
SortDefinition | undefined

The value that you want to sort the data by.

The following values are supported for Key:

  • UtilizationPercentage

  • UtilizationPercentageInUnits

  • PurchasedHours

  • PurchasedUnits

  • TotalActualHours

  • TotalActualUnits

  • UnusedHours

  • UnusedUnits

  • OnDemandCostOfRIHoursUsed

  • NetRISavings

  • TotalPotentialRISavings

  • AmortizedUpfrontFee

  • AmortizedRecurringFee

  • TotalAmortizedFee

  • RICostForUnusedHours

  • RealizedSavings

  • UnrealizedSavings

The supported values for SortOrder are ASCENDING and DESCENDING.

GetReservationUtilizationCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
UtilizationsByTime
Required
UtilizationByTime[] | undefined

The amount of time that you used your Reserved Instances (RIs).

NextPageToken
string | undefined

The token for the next set of retrievable results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.

Total
ReservationAggregates | undefined

The total amount of time that you used your Reserved Instances (RIs).

Throws

Name
Fault
Details
DataUnavailableException
client

The requested data is unavailable.

InvalidNextTokenException
client

The pagination token is invalid. Try again without a pagination token.

LimitExceededException
client

You made too many calls in a short period of time. Try again later.

CostExplorerServiceException
Base exception class for all service exceptions from CostExplorer service.