Repository navigation
feat(gateway): add option for outputting logs as JSON - #10620
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for JSON-formatted log output in the gateway, enabling structured logs that can be ingested into SIEM systems. The change introduces a new command-line argument and environment variable to control the log output format.
- Adds a
--log-formatCLI argument withjsonandhumanoptions - Updates the logging infrastructure to support JSON formatting
- Maintains backward compatibility with human-readable logs as the default
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rust/logging/src/lib.rs | Modified setup_global_subscriber to accept a stdout_json parameter and conditionally apply JSON formatting |
| rust/logging/Cargo.toml | Added json feature to tracing-subscriber dependency |
| rust/headless-client/src/main.rs | Updated call to setup_global_subscriber to pass false for JSON output |
| rust/gateway/src/main.rs | Added LogFormat enum, CLI argument, and Display implementation; integrated JSON log format option |
| .with(match stdout_json { | ||
| true => fmt::layer() | ||
| .json() | ||
| .flatten_event(true) |
There was a problem hiding this comment.
I've opted to flatten the fields into the root object so logs will look like this:
{"timestamp":"2025-10-19T22:13:15.685936Z","level":"DEBUG","message":"Created new route","route":"172.31.0.0/24","iface_idx":"3","table_id":"539098368","target":"firezone_bin_shared::tun_device_manager::linux"}instead of this:
{"timestamp":"2025-10-19T22:11:54.941333Z","level":"DEBUG","fields":{"message":"Created new route","route":"172.31.0.0/24","iface_idx":"3","table_id":"539098368"},"target":"firezone_bin_shared::tun_device_manager::linux"}Thoughts?
There was a problem hiding this comment.
I think that makes sense, as long as the field names don't collide it's probably easier for ingesters to parse it this way
jamilbk
left a comment
There was a problem hiding this comment.
LGTM pending any Rust comments
|
Merging this to finish up flow logs. Rust comments can be addressed in a follow-up. |
To enable customers to ingest flow logs (#8353) into various SIEMS, outputting structured logs is crucial.