|Docs

RailQL data sources

RailQL reads metrics and events from the selected project environment. Use this reference to choose a source and the names it exposes.

Sources

Every query reads from at least one source.

SourceWhat it holds
metric <name>A metric, such as one of the built-in metrics
logsRuntime logs of every replica
build_logsBuild logs of every deployment
httpHTTP requests served through Railway's edge
dnsDNS queries made by replicas
flowsNetwork flows observed on replicas
spansSpans your services export with tracing
tracesTraces, one row per trace, built from their spans

A metric is always series. An event source on its own returns an event stream, and a rollup turns it into series.

Labels and fields

Each event source has a fixed set of built-in names. Labels describe an event, and you can filter on them and group by them. Fields hold an event's values, and a rollup can add up, average, or take the distribution of the numeric ones.

SourceLabelsFields
logsservice, deployment, replica, levelmessage (text)
build_logsservice, deployment, snapshot, levelmessage (text)
httpservice, deployment, replica, method, host, path, http_status, http_status_class, upstream_proto, downstream_proto, request_id, response_details, upstream_address, client_ua, upstream_errors, src_iphttp_status, total_duration (ms), upstream_req_duration (ms), tx_bytes, rx_bytes
dnsservice, replica, qtype, rcode, qname, zone, domain, status
flowsservice, replica, protocol, direction, peer_kind, peer, flow_state, drop_cause, dropped, status, dst_port, src_addr, dst_addrbyte_count, packet_count, l4_latency_ms (ms)
spansservice, deployment, replica, name, component, kind, status, trace_id, span_idduration (ms)
tracestrace_id, root_service, root_name, root_component, root_host, root_path, statusduration (ms), span_count, error_count

service takes a service name or ID, and deployment and replica take IDs. level is one of debug, info, warn, or error, which Railway reads from each log line and normalizes. A span's kind is server, client, producer, consumer, or internal, and its status is ok, error, or unset.

traces has one row per trace. Its root_ labels describe the trace's root span, root_host and root_path are empty when the root span records no host or path, and status is error when any span of the trace failed. A trace's duration runs from its first span's start to its last span's end. A traces filter is a spans filter: it takes the names spans has, and a trace matches when any of its spans does. traces{service=api status=error} lists every trace in which a span of the api service failed. The root_ labels are for grouping with by, not for filtering.

Choose a label or field

Labels identify groups, while numeric fields supply values to aggregate. Some names support both uses. For example, http_status is a label for grouping requests and a numeric field for filtering or aggregation.

TaskExample
Filter by a labelhttp{method=GET}
Filter by a numeric fieldhttp{total_duration>2s}
Group by a labelhttp rollup count by method
Aggregate a numeric fieldhttp rollup histogram(total_duration)
Group by application datalogs rollup count by @error.code

Filtering doesn't retain labels on an event rollup. http{service=api} rollup count by method produces series labeled only by method. Include service in by if later stages or arithmetic need it.

Custom attributes use the @ syntax described in Custom fields and attributes. They aren't available on HTTP, DNS, or flow events.

Built-in metrics

Metrics of replicas carry the labels service, deployment, replica, and host_type. Metrics of volumes carry service, volume, and volume_instance. volume accepts a name or ID.

MetricKindUnitMeasures
railway.cpu.timeCountersecondsCPU time used. Its rate is the number of cores in use
railway.cpu.limitGaugecoresThe vCPU limit of the replica
railway.memory.usageUpDownCounterbytesMemory in use
railway.memory.limitGaugebytesThe memory limit of the replica
railway.memory.byte_secondsCounterbyte-secondsMemory use over time, as billed
railway.network.tx, railway.network.rxCounterbytesBytes sent and received over the public network
railway.network.private.tx, railway.network.private.rxCounterbytesBytes sent and received over the private network
railway.volume.usageUpDownCounterbytesBytes stored on the volume
railway.volume.backupUpDownCounterbytesBytes held by the volume's backups
railway.volume.sizeGaugebytesThe provisioned size of the volume

Retention

How far back a RailQL query can read depends on its sources and your plan's log retention.

SourceRetention
Metrics90 days on every plan
logs, build_logs, http, spans, tracesYour plan's log retention
dns, flowsYour plan's log retention, up to 7 days

A query that reads several sources uses the shortest retention among them. If the selected range starts before the oldest available data, RailQL shortens it and reports W_RANGE_CLAMPED. A range that ends before the oldest available data fails with E_RANGE_BEFORE_RETENTION. See Permissions and limits.