Skip to main content

metrics

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

Overview​

Namemetrics
TypeResource
Idrailway.observability.metrics

Fields​

The following fields are returned by SELECT queries:

One row per MetricsResult. The result of a metrics query.

NameDatatypeDescription
measurementstringThe measurement of the metric. (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 to by will be present.
values_arrayThe samples of the metric.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectmeasurements, start_dateaveraging_window_seconds, end_date, environment_id, group_by, include_deleted, project_id, sample_rate_seconds, service_id, volume_id, volume_instance_external_id, workspace_idGet metrics for a project, environment, and service. Backed by the Railway GraphQL query metrics.

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].
start_datestring (date-time)The start of the period to get metrics for.
averaging_window_secondsintegerThe averaging window when computing CPU usage. By default, it is the same as the sampleRateSeconds.
end_datestring (date-time)The end of the period to get metrics for. If not provided, the current datetime is used.
environment_idstring
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 or not to include deleted projects in the results.
project_idstring
sample_rate_secondsintegerThe frequency of data points in the response. If the sampleRateSeconds is 60, then the response will contain one data point per minute.
service_idstring
volume_idstring
volume_instance_external_idstring
workspace_idstring

SELECT examples​

Get metrics for a project, environment, and service. Backed by the Railway GraphQL query metrics.

SELECT
measurement,
tags,
values_
FROM railway.observability.metrics
WHERE measurements = '{{ measurements }}' -- required
AND start_date = '{{ start_date }}' -- required
AND averaging_window_seconds = '{{ averaging_window_seconds }}'
AND end_date = '{{ end_date }}'
AND environment_id = '{{ environment_id }}'
AND group_by = '{{ group_by }}'
AND include_deleted = '{{ include_deleted }}'
AND project_id = '{{ project_id }}'
AND sample_rate_seconds = '{{ sample_rate_seconds }}'
AND service_id = '{{ service_id }}'
AND volume_id = '{{ volume_id }}'
AND volume_instance_external_id = '{{ volume_instance_external_id }}'
AND workspace_id = '{{ workspace_id }}'
;