I was getting duplicate log entries when using the Fly Log Shipper app (shipping to Logtail) and couldn’t figure out why until I realized that starting a new app on Apps v2 always creates two instances.
For now I fixed it by running fly scale count 1 under my logshipper app, so there was just one instance running.
The current docs don’t mention anything about this “gotcha”:
Given Fly recommends having two instances via the warning message when viewing the app that says
Your app is running on 1 machine. We’d strongly recommend running at least 2 instances to ensure high availability. Check out the documentation for more details on scaling.
What’s the ideal way this should be configured without shipping duplicate logs?
This doesn’t solve the problem I explained. I want logs from all my app production instances, I just want them once.
The issue is that Fly recommends having two instances of the same app for high availability and that following the doc instructions for the fly logshipper app does not mention that by running fly launchyou’d spin up two instances of the logshipper app, which in turn would ship the logs twice.
Either the docs are outdated and they actually recommend only having one instance of the logshipper app, or that app needs to somehow be updated to know if other instance had already shipped the log.
Yea the change to deploy two instances by default in my opinion was a bandaid for users who don’t understand what high availability requires. Fly have also dropped the ball on updating all previous docs that were impacted by this change.
Luckily a fix for you should be pretty simple, you just need to set another environment variable. Set QUEUE to pretty much any value and you should be good to go.
I think @charsleysa’s suggestion (QUEUE) is the proper solution for the Log Shipper, but I just want to mention that instead of fly scale count 1 you can deploy using fly launch --ha=false (which I think is cleaner).