Hello, we run a simple Deno backend app in Fly from which we output console.log, console.error, and console.info statements. We have two types of logs: simple one-liner logs for simple data logs and JSON object logs when an error occurs. However, when we go to the machine’s live logs, we see each new line of the object of the JSON as an independent log.
How can I get Fly IO to log JSON outputs as a single log? Thanks for the help.
(Their house illustrator has a really impressively broad style.)
Anyway, here’s the relevant part of the docs:
The init program […] gather[s] process output from stdout and redirects it to a socket.
Outside of the Machine, on the [physical] host, we take that output and send it to Vector via yet another socket. Vector ships logs (your app’s output) to an internal NATS cluster. Clients can subscribe to specific topics, and NATS sends the requested data to those subscribers.
This is the “everything is a stream of bytes” approach, in other words: it’s up to the process (Deno, in this case) to turn whatever it wants to log into strings.
Hope this helps a little!
Aside: There is some discussion over on the Quickwit thread about ways to retroactively parse JSON—at the end of the stdout → Vector → NATS → ⋯ chain. Each entry is a string all along, but perhaps with structure-aware indexing of any detected JSON fields · at the very end. It looks like those would/will require you to serialize your objects to fit on a single line, however.
Thanks for the response! Im new to the logging world and I see NATS, Vector, etc and its all new to me. I managed to log my JSON objects in string format now at least
Now Im trying to use Grafana in fly-metrics to actually query the log data but I cant figure out how to parse and treat the field as a JSON, it is seen as a whole string.