Add DNS logs to railway logs - #1025
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…/rcode - Extract stream_anchored_logs, giving network flow and DNS streams the same reconnect policy as stream_http_logs_inner: mid-stream errors are retried with backoff instead of aborting, every reconnect waits at least the initial delay, and retry state only resets once a connection proves stable - Scope DNS row deduplication to reconnect replays (rows at or before the previous connection's watermark); identical queries arriving live on a healthy connection are all emitted, and serialization failures fail open instead of collapsing rows - Accept any --qtype/--rcode value as an uppercase-normalized string so registered DNS values the enums omitted (PTR, SOA, CAA, FORMERR, ...) and future backend values work without a CLI release Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Addressed all three review findings in c550f09: 1. Stream retry policy — Extracted a 2. Full-row deduplication — Dedupe is now replay-scoped: a row is only suppressed when it was already seen and its timestamp is at or before the previous connection's watermark (i.e. it falls in the reconnect lookback replay window). Identical queries arriving live on a healthy connection are all emitted, and serialization failures now fail open instead of collapsing rows onto a shared empty key. The residual gap is an out-of-order duplicate landing inside the 30s replay window right after a reconnect — a server-provided query ID (like 3. Closed enums — Validation: 482 tests pass (new coverage for replay-cutoff detection and uncommon qtype/rcode values), fmt clean, clippy has no warnings in the changed files. 🤖 Generated with Claude Code |
Summary
Adds
railway logs --dnsfor viewing the DNS query logs that shipped in the dashboard this week (deployment → Network tab → DNS). Streams live queries by default, or fetches history with--lines,--since, or--until.DNS joins
--deployment,--build,--http, and--networkin the mutually exclusive log-type group, and follows the same conventions: typed filter flags mirror the filter attributes, and compose with a raw--filterexpression.API
Typed flags (all require
--dns):--domain@domain--qname@qname--qtype@qtypeA,AAAA,CNAME,PTR,SOA)--rcode@rcodeNOERROR,NXDOMAIN,FORMERR, plus syntheticTIMEOUT/ERROR)--zone@zoneinternal,external--status@statusok,failed(shared flag, mode-validated like--network)--qtypeand--rcodeare open string values rather than closed enums so registered DNS values and future backend additions work without a CLI release.--zonestays a closed enum since it mirrors the API'sDnsQueryZoneenum.Output is a table (Time, Zone, Type, Rcode, Name, Answers) with
--jsonemitting one object per row includinganswers,cnameChain, and IDs.What changed
src/gql/schema.json: adds theDnsQueryLogtype,DnsQueryZoneenum, anddnsQueryLogsquery/subscription fields (both are on the public subgraph in backboard).src/gql/{queries,subscriptions}/strings/DnsQueryLogs.graphql+ codegen registration.src/controllers/deployment.rs:fetch_dns_query_logsmirrorsfetch_network_flow_logs(same anchor-window semantics).stream_anchored_logshelper drives both the network flow and DNS subscriptions with the same reconnect policy asstream_http_logs_inner: mid-stream errors are retried with backoff instead of aborting, every reconnect waits at least the initial delay (no hot reconnect loops on short-lived connections), and retry state only resets once a connection proves stable. This also fixes the pre-existing retry gaps in--networkstreaming.anchored_log_window,StreamedLogDedupe,stream_before_date,update_max_stream_timestamp,should_reset_stream_retry_state).src/util/logs.rs:DnsQueryLogLiketrait, table header/row formatters, JSON output with atimestampalias matching the network flow convention.src/commands/logs.rs:--dnsmode, typed flags, filter composition, validation, help text, and examples.Validation
cargo test --bin railway(482 passed), including unit tests for filter composition, invalid--statusvalues, mode mutual exclusion, typed-flag mode validation, uncommon--qtype/--rcodevalues, and replay-cutoff detectioncargo fmt --all -- --checkcargo clippy— no warnings in changed files--dnsstreaming and history against a live service🤖 Generated with Claude Code