> For the complete documentation index, see [llms.txt](https://docs.controltheory.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/railway.md).

# Railway

Railway emits deployment logs, the stdout and stderr of every service in a project. Dstl8 polls Railway's API as a single source, covering every persistent environment in the project, and infers a stream per service.

### Add a Railway source

The Project ID and the API token both come from Railway, so collect them before you open Dstl8.

#### 1. Get your Project ID and API token

In Railway, open the project, click **Settings** at the top right of the project view, and go to the **General** tab. Copy the **Project ID**. It's also the UUID in the project URL, `railway.com/project/<project-id>`.

Then create an API token:

1. Go to [Railway → Account → Tokens](https://railway.com/account/tokens).
2. Give the token a name. If the project belongs to a team workspace, select that workspace.
3. Create the token and copy it. Railway shows the value only once.

> Use an **Account** or **Workspace** token. A project token won't work, because it's scoped to a single environment while a Dstl8 source polls every persistent environment in the project.

#### 2. Open the Add Source dialog

In Dstl8, from **Sources**, click **Add Source** and select **Railway**.

#### 3. Configure the source

In the **Configure Railway Source** dialog:

| Field                               | Notes                                                                                                                                    |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**                            | A unique name to identify this source.                                                                                                   |
| **Project ID**                      | The Project ID you copied from Railway.                                                                                                  |
| **API Token**                       | The Account or Workspace token you created.                                                                                              |
| **Filter** *(optional)*             | Railway log query syntax, applied server-side. Leave empty to collect every log.                                                         |
| **Poll interval**                   | How often Dstl8 polls Railway: `1m` *(default)*, `5m`, or `15m`.                                                                         |
| **Include PR preview environments** | Off by default. Turn it on to collect from PR preview environments too. Each one Dstl8 polls counts against your Railway API rate limit. |

Filters use Railway's query syntax: `@level:error` matches an attribute, `-@level:debug` negates one, and `AND` / `OR` join terms. See [Railway's logs documentation](https://docs.railway.com/observability/logs) for the full reference.

Click **Test Connection**. You should see **Connection successful**.

#### 4. Create

Click **Create** to add the source.

### After creating

The source appears in the Sources list as **Waiting for logs**, with no streams listed yet. Railway history isn't backfilled, so the first streams appear a few minutes after your services next emit logs, and the source transitions to **Healthy**.

Every Railway stream has the **Stream Type** `railway`, and each stream is named after the Railway service that produced it. Logs that Railway can't attribute to a service, such as plugin logs, land in a stream named `unknown`. A service deployed to several environments is still one stream. Each log keeps its Railway environment as an attribute you can filter on in Dstl8.

### Assign streams to workspaces

Streams need to be assigned to a workspace to be accessible. Open the source's actions menu (gear icon) and select **Assign Streams**, then check the streams you want the **Default** workspace (or any other workspace) to receive and click **Save Assignments**.

See [Assigning streams to workspaces](/controltheory-documentation/dstl8-docs/sources.md#assigning-streams-to-workspaces) for details.

### Tips

* One source covers one Railway project. Railway's rate limit is hourly and per token (100 requests/hour on Free, 1,000 on Hobby, 10,000 on Pro), so sources sharing a token share one budget. On the lower plans, raise **Poll interval** to `5m` or `15m`.
* Use a **Filter** when you want only part of the logs. Railway applies it before sending, so it trims what Dstl8 ingests, though not API usage, which depends on how many environments you poll and how often.
* If **Test Connection** fails, re-check both **Project ID** and **API Token**. Railway returns the same `Project not found` response for an invalid token and for an unknown project, so the error can't tell you which of the two is wrong.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/railway.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
