metrics
Creates, updates, deletes, gets or lists a metrics resource.
Overview​
| Name | metrics |
| Type | Resource |
| Id | railway.observability.metrics |
Fields​
The following fields are returned by SELECT queries:
- list
One row per MetricsResult. The result of a metrics query.
| Name | Datatype | Description |
|---|---|---|
measurement | string | The 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) |
tags | object | The tags that were used to group the metric. Only the tags that were used to by will be present. |
values_ | array | The samples of the metric. |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | measurements, start_date | averaging_window_seconds, end_date, environment_id, group_by, include_deleted, project_id, sample_rate_seconds, service_id, volume_id, volume_instance_external_id, workspace_id | Get 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.
| Name | Datatype | Description |
|---|---|---|
measurements | string | GraphQL list literal of MetricMeasurement values, for example [AGENT_CACHE_READ_TOKENS, AGENT_CACHE_WRITE_TOKENS]. |
start_date | string (date-time) | The start of the period to get metrics for. |
averaging_window_seconds | integer | The averaging window when computing CPU usage. By default, it is the same as the sampleRateSeconds. |
end_date | string (date-time) | The end of the period to get metrics for. If not provided, the current datetime is used. |
environment_id | string | |
group_by | string | What 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_deleted | boolean | Whether or not to include deleted projects in the results. |
project_id | string | |
sample_rate_seconds | integer | The frequency of data points in the response. If the sampleRateSeconds is 60, then the response will contain one data point per minute. |
service_id | string | |
volume_id | string | |
volume_instance_external_id | string | |
workspace_id | string |
SELECT examples​
- list
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 }}'
;