Skip to content

feat(gateway): add option for outputting logs as JSON - #10620

Merged
thomaseizinger merged 2 commits into
mainfrom
feat/gateway-json-logs
Oct 22, 2025
Merged

thomaseizinger merged 2 commits into
mainfrom
feat/gateway-json-logs

Conversation

@thomaseizinger

Copy link
Copy Markdown
Member

To enable customers to ingest flow logs (#8353) into various SIEMS, outputting structured logs is crucial.

@vercel

vercel Bot commented Oct 19, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
firezone Ready Ready Preview Comment Oct 19, 2025 10:54pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-format CLI argument with json and human options
  • 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

Comment thread rust/logging/src/lib.rs
.with(match stdout_json {
true => fmt::layer()
.json()
.flatten_event(true)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending any Rust comments

@thomaseizinger

thomaseizinger commented Oct 22, 2025 •

Copy link
Copy Markdown
Member Author

Merging this to finish up flow logs. Rust comments can be addressed in a follow-up.

@thomaseizinger
thomaseizinger added this pull request to the merge queue Oct 22, 2025
Merged via the queue into main with commit 80331b4 Oct 22, 2025
1 check passed
@thomaseizinger
thomaseizinger deleted the feat/gateway-json-logs branch October 22, 2025 03:58

This branch was successfully deployed

1 active deployment
Preview — 916187e8 Deployed Oct 19, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants