usage_costs
Creates, updates, deletes, gets or lists a usage_costs resource.
Overview
| Name | usage_costs |
| Type | Resource |
| Id | clickhouse.organizations.usage_costs |
Fields
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
data_warehouse_id | string (uuid) | ID of the dataWarehouse this entity belongs to (or is). (wire: dataWarehouseId) |
entity_id | string (uuid) | Unique ID of the entity. (wire: entityId) |
service_id | string (uuid) | ID of the service this entity belongs to (or is). Set to null for dataWarehouse entities. (wire: serviceId) |
entity_name | string | Name of the entity. (wire: entityName) |
date | string (date) | Date of the usage. ISO-8601 date, based on the UTC timezone. |
entity_type | string | Type of the entity. (datawarehouse, service, clickpipe) (wire: entityType) |
locked | boolean | When true, the record is immutable. Unlocked records are subject to change until locked. |
metrics | object | |
total_chc | number | Total cost of usage in ClickHouse Credits (CHCs) for this entity. (wire: totalCHC) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | from_date, to_date, organization_id | filter | Returns a grand total and a list of daily, per-entity organization usage cost records for the organization in the queried time period (maximum 31 days). All days in both the request and the response are evaluated based on the UTC timezone. |
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.
| Name | Datatype | Description |
|---|---|---|
from_date | string (date) | Start date for the report, e.g. 2024-12-19. |
organization_id | string | ClickHouse Cloud organization ID. Resolved from the CLICKHOUSE_ORG_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every query as WHERE organization_id = <uuid>. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: CLICKHOUSE_ORG_ID) |
to_date | string (date) | End date (inclusive) for the report, e.g. 2024-12-20. This date cannot be more than 30 days after from_date (for a maximum queried period of 31 days). |
filter | array | Filter criteria to apply when retrieving the usage cost report. Currently, only filtering by resource tags is supported. (example: [tag:Environment=Production, tag:Department=Engineering, tag:isActive]) |
SELECT examples
- list
Returns a grand total and a list of daily, per-entity organization usage cost records for the organization in the queried time period (maximum 31 days). All days in both the request and the response are evaluated based on the UTC timezone.
SELECT
data_warehouse_id,
entity_id,
service_id,
entity_name,
date,
entity_type,
locked,
metrics,
total_chc
FROM clickhouse.organizations.usage_costs
WHERE from_date = '{{ from_date }}' -- required
AND to_date = '{{ to_date }}' -- required
AND organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
AND filter = '{{ filter }}'
;