Skip to content

Add http logs#810

Merged
m-abdelwahab merged 5 commits intorailwayapp:masterfrom
dmedov:codex/add_http_logs
Mar 17, 2026
Merged

Add http logs#810
m-abdelwahab merged 5 commits intorailwayapp:masterfrom
dmedov:codex/add_http_logs

Conversation

@dmedov
Copy link
Contributor

@dmedov dmedov commented Mar 8, 2026

Summary

This adds HTTP request log support to railway logs and railway service logs.

Users can now query request logs from the CLI with the same workflow they already use for build and deploy logs, including filtering by Railway log query syntax and streaming live request traffic from an interactive terminal.

What changed

  • added --http to railway logs and railway service logs
  • added GraphQL query support for deployment HTTP logs
  • added plain-text and JSON formatting for HTTP log entries
  • added live follow support for HTTP logs
  • updated command help and examples
  • added parse coverage for the documented HTTP log example commands

Examples

railway logs --http --lines 50
railway logs --http --filter "@path:/api/users @httpStatus:200"
railway logs --http --json --filter "@requestId:abcd1234"
railway service logs --http --lines 10 --filter "@httpStatus:404"

@dmedov dmedov changed the title Codex/add http logs Add http logs Mar 8, 2026
@brody192 brody192 requested a review from Milo123459 March 9, 2026 15:29
@dmedov
Copy link
Contributor Author

dmedov commented Mar 13, 2026

@Milo123459 hello! could you check changes to support https logs, very useful for development via agents

Copy link
Collaborator

@Milo123459 Milo123459 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocked by previous comment. other then that, all good

filter: Option<String>,
on_log: impl Fn(queries::http_logs::HttpLogFields),
) -> Result<()> {
// HTTP log subscriptions currently return empty payloads for this backend
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think this is probably not the right approach- if we can use subscriptions we should. I'll have a look into it so we don't have to do a workaround like this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

Fixed this to use the subscription path instead of the polling workaround.

The HTTP logs subscription does work here, but it needed the subscription window args (anchorDate, afterDate, afterLimit) to behave like a live tail. I updated stream_http_logs to use that subscription shape and validated it against a real Railway service with fresh requests while the stream was attached

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've got this working locally using subscriptions. lmk if i should just push to this branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, i think you could push your implementation also or check mine, let's just make it happen in any way 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello! could we merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello @Milo123459! could we merge?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since HTTP logs are tied to a specific deployment rather than a service, a user could be watching HTTP logs, make a deployment, and the logs will just stop coming in without any indication of why.

So, to avoid this confusion, please implement a poller running on a 5-second loop to detect when the current deployment is removed, close the websocket connection, and notify the user that the deployment was removed.

@Milo123459 Milo123459 added the release/minor Author minor release label Mar 13, 2026
dmedov and others added 2 commits March 13, 2026 19:08
- Fix HTTP log fetch to use anchor-based pagination (beforeLimit/anchorDate)
  instead of limit/startDate/endDate which the backend ignores
- Add all 20 HttpLog fields to GraphQL fragments for full JSON output
  parity with the dashboard
- Add typed filter flags: --method (enum-validated), --status (supports
  200, >=400, 500..599), --path, --request-id (all require --http)
- Expand --filter help to list all filterable fields and operators

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@m-abdelwahab
Copy link
Collaborator

Hey @dmedov, thank you so much for the PR!

I tested this against a live account and pushed a follow-up commit with a few additions:

  • Bug fix: The httpLogs query was using limit/startDate/endDate params, but the backend resolver uses
    anchor-based pagination (beforeLimit/anchorDate/beforeDate). This caused --lines 50 to return only 1 result.
    Switched to the correct params.
  • JSON field parity: Added all 20 HttpLog fields to both GraphQL fragments so --json output matches the
    dashboard
  • Filter discoverability: Added --method, --status, --path, --request-id as typed flags (all require --http) so
    agents and new users can construct queries from --help alone.

Also expanded the --filter help text to list all available fields and operators

@dmedov
Copy link
Contributor Author

dmedov commented Mar 17, 2026

Hey @dmedov, thank you so much for the PR!

I tested this against a live account and pushed a follow-up commit with a few additions:

  • Bug fix: The httpLogs query was using limit/startDate/endDate params, but the backend resolver uses
    anchor-based pagination (beforeLimit/anchorDate/beforeDate). This caused --lines 50 to return only 1 result.
    Switched to the correct params.
  • JSON field parity: Added all 20 HttpLog fields to both GraphQL fragments so --json output matches the
    dashboard
  • Filter discoverability: Added --method, --status, --path, --request-id as typed flags (all require --http) so
    agents and new users can construct queries from --help alone.

Also expanded the --filter help text to list all available fields and operators

Thank you @m-abdelwahab , nice filters

When a deployment is removed while streaming HTTP logs, the CLI now
exits cleanly with a message instead of silently retrying forever.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@m-abdelwahab m-abdelwahab requested a review from brody192 March 17, 2026 19:53
@m-abdelwahab m-abdelwahab merged commit 33b1e91 into railwayapp:master Mar 17, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/minor Author minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants