Get Historical Usage Records

Get Historical Usage Records

This API lets you get a sortable and paginated list of historical usage records for a specific time period, service identifier, and metric identifier within your organization. You need to specify a valid start and end date for your time range, with the start date always before the end date. The API has different limitations on the time range based on the aggregation period you select. For example, if you choose HOURLY aggregation, you can set a time range up to 30 days from the current date. If you prefer DAILY or MONTHLY aggregation, the time range must fall within the past 2 years from the current date.

Request
URI
GET
https://console.cloud.vmware.com/commerce/cost-and-usage/api/{org_id}/usage/historical-records
COPY
Path Parameters
string
org_id
Required

Unique identifier (GUID) of the organization

Query Parameters
string
service_definition_id
Required

Unique identifier of the service

string
metric_id
Required

Unique identifier of the metric

string
seller
Optional

The name of the seller providing the usage. Default is multiple

string
locale
Optional

Locale with language preference (e.g. en_US)

string
start_date
Required

Beginning of the time range for which you want to retrieve usage records (yyyy-mm-dd)

string
end_date
Required

The end of the time range for which you want to retrieve usage records (yyyy-mm-dd)

string
aggregation_period
Optional

The frequency at which the usage records should be aggregated. Default is HOURLY

Possible values are : HOURLY, DAILY, MONTHLY,
string
aggregation_type
Optional

The type of aggregation to be performed on the usage records. Default is AVERAGE

Possible values are : AVERAGE, MIN, MAX,
integer
size
Optional

Size of each page. Default = 20

integer
page
Optional

The index of requested page (0-based). Default = 0

string of array
sort
Optional

Sorting criteria for the paginated request in the format: "property(,asc|desc)". For multiple sort criteria: "sort=property1(,asc|desc)&sort=property2(,asc|desc)". Supported sorting properties are "usage_date_time, commit_quantity, usage_quantity, (overage_quantity for hourly usage)". Default is "usage_date_time,desc"

string
resource_id
Optional

Unique identifier of the resource

string
project_id
Optional

Unique identifier of the project


Responses
200

OK

Returns HistoricalUsageResponse of type(s) application/json
{
    "metadata": {
        "metric_id": "<metric ID for vRNI vCPUs Public Cloud>",
        "service_definition_id": "<service definition ID for VMC-AWS>",
        "display_name": "i3en US West 2",
        "unit_of_measure_display_name": "Hosts",
        "charge_attributes": {
            "category": "HOST_USAGE"
        }
    },
    "content": [
        {
            "usage_datetime": "2023-03-25T07:00:00.000Z",
            "commitment": 3,
            "usage": 4,
            "overage": 1,
            "resources": [
                {
                    "resource_id": "res1",
                    "usage_quantity": 10
                }
            ],
            "projects": [
                {
                    "project_id": "proj1",
                    "usage_quantity": 10,
                    "commit_quantity": 5
                }
            ]
        }
    ],
    "empty": false,
    "first": false,
    "last": false,
    "number": 0,
    "number_of_elements": 0,
    "pageable": {
        "offset": 0,
        "page_number": 0,
        "page_size": 0,
        "paged": false,
        "sort": {
            "empty": false,
            "sorted": false,
            "unsorted": false
        },
        "unpaged": false
    },
    "size": 0,
    "sort": {
        "empty": false,
        "sorted": false,
        "unsorted": false
    },
    "total_elements": 0,
    "total_pages": 0
}
metadata
Optional

metadata

content
Optional

List of Historical Usage Record items

boolean
empty
Optional

True if no elements in the system match given request

boolean
first
Optional

True if this is the first page of items

boolean
last
Optional

True if this is the last page of MetricUsage items

number
Optional

number

integer As int32 As int32
number_of_elements
Optional

The number of HistoricalUsageRecord items in the response for given request after pagination operations. If number of items is less then size, it will be equal to total_elements.

pageable
Optional

pageable

integer As int32 As int32
size
Optional

Max number of HistoricalUsageRecord items in the response (controlled by query parameter size or system default)

sort
Optional

sort

integer As int64 As int64
total_elements
Optional

The total number of HistoricalUsageRecord items in the system for given request.

total_pages
Optional

total_pages


400

Bad Request

Returns ApiError of type(s) application/json
{
    "error_code": "string",
    "error_message": "string",
    "error_details": [
        {
            "error_code": "string",
            "error_message": "string"
        }
    ]
}
string
error_code
Required

The code associated with the error

string
error_message
Required

A description of the error that occurred

error_details
Optional

Additional error details for ValidationException errors


401

Unauthorized

Operation doesn't return any data structure

403

Forbidden

Operation doesn't return any data structure