Skip to main content

usage

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

Overview​

Nameusage
TypeResource
Idrailway.billing.usage

Fields​

The following fields are returned by SELECT queries:

One row per AggregatedUsage. The aggregated usage of a single measurement.

NameDatatypeDescription
measurementstringThe measurement that was aggregated. (AGENT_CACHE_READ_TOKENS, AGENT_CACHE_WRITE_TOKENS, AGENT_INPUT_TOKENS, AGENT_OUTPUT_TOKENS, AGENT_SPEND_USD, BACKUP_USAGE_GB, CPU_LIMIT, CPU_USAGE, CPU_USAGE_2, DISK_USAGE_GB, EPHEMERAL_DISK_USAGE_GB, MEASUREMENT_UNSPECIFIED, MEMORY_LIMIT_GB, MEMORY_USAGE_GB, NETWORK_RX_GB, NETWORK_TX_GB, UNRECOGNIZED)
tagsobjectThe tags that were used to group the metric. Only the tags that were used in the groupBy will be present.
valuenumberThe aggregated value.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectmeasurementsend_date, group_by, include_deleted, project_id, start_date, workspace_idGet the usage for a single project or all projects for a user/workspace. If no projectId or workspaceId is provided, the usage for the current user is returned. If no startDate is provided, the usage for the current billing period of the project owner is returned. Backed by the Railway GraphQL query usage.

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
measurementsstringGraphQL list literal of MetricMeasurement values, for example [AGENT_CACHE_READ_TOKENS, AGENT_CACHE_WRITE_TOKENS].
end_datestring (date-time)
group_bystringWhat to group the aggregated usage by. By default, it is grouped over the entire project. GraphQL list literal of MetricTag values, for example [BILLABLE, DEPLOYMENT_ID].
include_deletedbooleanWhether to include deleted projects in the usage.
project_idstring
start_datestring (date-time)
workspace_idstring

SELECT examples​

Get the usage for a single project or all projects for a user/workspace. If no projectId or workspaceId is provided, the usage for the current user is returned. If no startDate is provided, the usage for the current billing period of the project owner is returned. Backed by the Railway GraphQL query usage.

SELECT
measurement,
tags,
value
FROM railway.billing.usage
WHERE measurements = '{{ measurements }}' -- required
AND end_date = '{{ end_date }}'
AND group_by = '{{ group_by }}'
AND include_deleted = '{{ include_deleted }}'
AND project_id = '{{ project_id }}'
AND start_date = '{{ start_date }}'
AND workspace_id = '{{ workspace_id }}'
;