Skip to main content

usage_histories

Creates, updates, deletes, gets or lists a usage_histories resource.

Overview​

Nameusage_histories
TypeResource
Idovh.cloud.usage_histories

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
idstringUsage id
hourly_usageobjectHourly usage (wire: hourlyUsage)
last_updatestring (date-time)Entry last update (wire: lastUpdate)
monthly_usageobjectMonthly usage (wire: monthlyUsage)
periodobjectUsage dates (from/to)
resources_usagearrayResource usage (billed per hour/minute/second/unit) (wire: resourcesUsage)
total_priceobjectTotal price (wire: totalPrice)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectusage_id, service_nameReturns the usage and price of the project for one past period, by resource type.
listselectservice_namefrom, toReturns the past usage periods of the project. Filter them with the from and to dates, then get the details of one period with its ID.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
service_namestringThe Public Cloud project ID. Resolved from OVH_CLOUD_PROJECT_SERVICE when set.
usage_idstringUsage ID (wire: usageId)
fromstring (date-time)Filter results having date superior to from
tostring (date-time)Filter results having date inferior to

SELECT examples​

Returns the usage and price of the project for one past period, by resource type.

SELECT
id,
hourly_usage,
last_update,
monthly_usage,
period,
resources_usage,
total_price
FROM ovh.cloud.usage_histories
WHERE usage_id = '{{ usage_id }}' -- required
AND service_name = '{{ service_name }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
;