Fly.ioProblem & solution
Multiple Logs for Resiliency
Summary
An unexpected network outage can make an application misbehave while also removing crucial log data from the normal Fly.io pipeline. The post traces that pipeline from application STDOUT through Fly.io, NATS, the Log Shipper, Vector, and a third-party provider, then presents two ways to add redundancy. One strategy broadcasts framework logs to a separate file on each machine, preferably on a persistent volume with rotation; a Rails example uses ActiveSupport::Logger.broadcast. The other runs a separate app that subscribes directly to NATS, parses messages, and writes selected fields to disk, with a Fly authentication token and provisions for reconnection and error handling. File copies are more failsafe but raw and harder to fetch, while a custom shipper can produce more usable data but is less bulletproof.
Context
A network outage can cause application problems while crucial logs are lost through the normal chain from STDOUT to Fly.io, NATS, the Log Shipper, Vector, and a third-party logging provider. The post considers how to retain log data when that pipeline fails.
Approach / What changed
The post proposes adding one or both of two redundant logging strategies: writing application logs to per-machine files on persistent volumes, or operating a separate app that subscribes directly to NATS and stores selected log fields. It also covers log rotation, Fly authentication, reconnection, filtering, and write-error handling.
Takeaways
Per-machine log files provide the most failsafe redundancy, but they are raw and must be fetched from each machine; persistent volumes and rotation help preserve them without filling available storage.
A Rails implementation can use ActiveSupport::Logger.broadcast to send entries to STDOUT and a separate production log file.
A custom shipper can subscribe to the logs.> NATS subject, parse JSON messages, and write timestamp, instance, region, level, and message fields to disk, but it needs safeguards for write failures and lost NATS connections.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.