---
title: RailQL data sources
description: Metrics, event sources, labels, fields, custom attributes, and retention available in RailQL.
---
RailQL reads metrics and events from the selected project environment. Use this reference to choose a source and the names it exposes.

<Banner variant="primary">RailQL is available through <a href="/platform/priority-boarding">Priority Boarding</a>. Breaking changes may occur.</Banner>

## Sources

Every query reads from at least one source.

| Source | What it holds |
|---|---|
| `metric <name>` | A metric, such as one of the [built-in metrics](#built-in-metrics) |
| `logs` | Runtime logs of every replica |
| `build_logs` | Build logs of every deployment |
| `http` | HTTP requests served through Railway's edge |
| `dns` | DNS queries made by replicas |
| `flows` | Network flows observed on replicas |
| `spans` | Spans your services export with [tracing](/observability/tracing) |
| `traces` | Traces, 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](/observability/railql/language-reference#event-rollups) 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.

| Source | Labels | Fields |
|---|---|---|
| `logs` | `service`, `deployment`, `replica`, `level` | `message` (text) |
| `build_logs` | `service`, `deployment`, `snapshot`, `level` | `message` (text) |
| `http` | `service`, `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_ip` | `http_status`, `total_duration` (ms), `upstream_req_duration` (ms), `tx_bytes`, `rx_bytes` |
| `dns` | `service`, `replica`, `qtype`, `rcode`, `qname`, `zone`, `domain`, `status` | |
| `flows` | `service`, `replica`, `protocol`, `direction`, `peer_kind`, `peer`, `flow_state`, `drop_cause`, `dropped`, `status`, `dst_port`, `src_addr`, `dst_addr` | `byte_count`, `packet_count`, `l4_latency_ms` (ms) |
| `spans` | `service`, `deployment`, `replica`, `name`, `component`, `kind`, `status`, `trace_id`, `span_id` | `duration` (ms) |
| `traces` | `trace_id`, `root_service`, `root_name`, `root_component`, `root_host`, `root_path`, `status` | `duration` (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.

| Task | Example |
|---|---|
| Filter by a label | `http{method=GET}` |
| Filter by a numeric field | `http{total_duration>2s}` |
| Group by a label | `http rollup count by method` |
| Aggregate a numeric field | `http rollup histogram(total_duration)` |
| Group by application data | `logs 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](/observability/railql/language-reference#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.

| Metric | Kind | Unit | Measures |
|---|---|---|---|
| `railway.cpu.time` | Counter | seconds | CPU time used. Its `rate` is the number of cores in use |
| `railway.cpu.limit` | Gauge | cores | The vCPU limit of the replica |
| `railway.memory.usage` | UpDownCounter | bytes | Memory in use |
| `railway.memory.limit` | Gauge | bytes | The memory limit of the replica |
| `railway.memory.byte_seconds` | Counter | byte-seconds | Memory use over time, as billed |
| `railway.network.tx`, `railway.network.rx` | Counter | bytes | Bytes sent and received over the public network |
| `railway.network.private.tx`, `railway.network.private.rx` | Counter | bytes | Bytes sent and received over the [private network](/networking/private-networking) |
| `railway.volume.usage` | UpDownCounter | bytes | Bytes stored on the volume |
| `railway.volume.backup` | UpDownCounter | bytes | Bytes held by the volume's backups |
| `railway.volume.size` | Gauge | bytes | The provisioned size of the volume |

## Retention

How far back a RailQL query can read depends on its sources and your plan's [log retention](/observability/logs#log-retention).

| Source | Retention |
|---|---|
| Metrics | 90 days on every plan |
| `logs`, `build_logs`, `http`, `spans`, `traces` | Your plan's log retention |
| `dns`, `flows` | Your 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](/observability/railql/errors-and-limits).