Skip to content

feat(server): write gateway OCSF events to JSONL - #3264

Open
krishicks wants to merge 1 commit into
mainfrom
hicks/push-zxnvvyptolyk
Open

feat(server): write gateway OCSF events to JSONL#3264
krishicks wants to merge 1 commit into
mainfrom
hicks/push-zxnvvyptolyk

Conversation

@krishicks

@krishicks krishicks commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Previously, gateway security activity was available only in diagnostic output, and there was no independent record of events that were not associated with a sandbox, such as TLS certificate reloads.

Now, configuring openshell.gateway.ocsf_log with a path writes every gateway-produced OCSF record to that JSONL file, independently of RUST_LOG. Records identify the gateway as their producer and report the gateway operating system even when they describe activity associated with a sandbox. By default, the file rotates daily in UTC, retains seven rotated files, and buffers up to 10,000 records or 16 MiB.

This means an external shipper can tail one file per gateway replica and own remote delivery or SIEM conversion. The file is best-effort: queue overflow and write failures discard records, failed writes are not retried, and warnings and metrics report known failures without stopping sandbox operation.

This does not include enabling configuration in helm; that will come in a subsequent PR.

Summary

Related Issue

This PR is plumbing that paves the way for 2762 and 2911 to be implemented

Changes

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

Previously, gateway security activity was available only in diagnostic output,
and there was no independent record of events that were not associated with a
sandbox, such as TLS certificate reloads.

Now, configuring `openshell.gateway.ocsf_log` with a path writes every
gateway-produced OCSF record to that JSONL file, independently of `RUST_LOG`.
Records identify the gateway as their producer and report the gateway operating
system even when they describe activity associated with a sandbox. By default,
the file rotates daily in UTC, retains seven rotated files, and buffers up to
10,000 records or 16 MiB.

This means an external shipper can tail one file per gateway replica and own
remote delivery or SIEM conversion. The file is best-effort: queue overflow and
write failures discard records, failed writes are not retried, and warnings and
metrics report known failures without stopping sandbox operation.

Refs #2762

Signed-off-by: Kris Hicks <khicks@nvidia.com>
@github-actions

Copy link
Copy Markdown

| 5019 | Device Config State Change | `CONFIG:` |
| 6002 | Application Lifecycle | `LIFECYCLE:` |

## SIEM Schema Version Compatibility

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we have a version compatibility option for gateway OCSF as well? Probably yes, so both the gateway and sandbox produced logs can be consumed. It could be a follow up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I hadn't realized that was merged; I'm going to look into this more.

type_label: DeviceTypeId::Server.to_string(),
name: Some(name.to_string()),
// Keep the replica identity opaque rather than encoding multiple fields in the UID.
uid: Some(hostname.to_string()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could device.uid include the gateway installation identity as well as the replica hostname? Hostnames such as openshell-gateway-0 can repeat across namespaces or clusters, so a SIEM aggregating multiple installations may merge distinct gateways under one device UID. For example, deriving the UID from both name and hostname—or omitting it when global uniqueness cannot be guaranteed—would better preserve the field’s uniqueness contract.

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.

2 participants