Expand description
§Chronix Audit — Structured Audit Logging
Captures security-relevant operations as structured audit events with pluggable sinks (memory, file, tracing) and queryable storage.
§Architecture
Authorization Decision ──┐
Authentication Event ──┤
Admin Operation ──┤──→ AuditLogger ──→ AuditSink(s)
Signal / Trigger Event ──┘ │ ├── MemorySink (queryable)
│ ├── WriterSink (JSON lines)
│ ├── TracingSink (structured logs)
│ └── WebhookSink (HTTP POST, JSON/CEF)
│
└── Sequence numbers + metrics§SIEM Integration
Built-in WebhookSink forwards events via HTTP POST (JSON or CEF
format) with configurable auth, retries, and backpressure. Additional
integration options:
- Webhook: use
WebhookSink(featurewebhook) to POST events directly to Splunk HEC, Elastic, Sentinel, or any HTTP endpoint. Supports JSON and CEF formats. - File → agent: use
WriterSinkwith JSON-lines output and configure a log shipper (Filebeat, Fluentd, Vector) to ingest the file into your SIEM pipeline. - Custom sink: implement
AuditSinkand push events directly via the SIEM’s HTTP/gRPC ingest API. - Tracing → OTLP: use
TracingSinkcombined with thechronixd’s OTLP exporter; many SIEMs accept OTLP.
Option 1 is recommended for most deployments. Option 2 is preferred when you need to decouple audit durability from network availability.
§Example
use chronix_security::audit::{AuditLogger, AuditEvent, AuditAction, AuditDecision, MemorySink};
use std::sync::Arc;
// Create logger with memory sink
let sink = Arc::new(MemorySink::new(10_000));
let mut logger = AuditLogger::new();
// Log an authorization decision
let event = AuditEvent::new("alice", AuditAction::Write, "cpu", AuditDecision::Allow)
.with_source_ip("10.0.0.1")
.with_request_id("req-001");
// logger.log(event);Re-exports§
pub use error::AuditError;
Modules§
- error
- Error types for the audit logging system.
Structs§
- Audit
Event - A structured audit event capturing a security-relevant operation.
- Audit
Logger - The main audit logger, dispatching events to configured sinks.
- File
Sink - An append-only audit file, one JSON event per line.
- Memory
Sink - In-memory audit sink, useful for testing and querying.
- Tracing
Sink - Emits audit events as structured tracing events.
- Webhook
Config - Configuration for the webhook sink.
- Webhook
Sink - HTTP webhook audit sink for SIEM integration.
- Writer
Sink - Writes audit events as JSON lines to an
io::Writedestination.
Enums§
- Audit
Action - Category of auditable actions.
- Audit
Decision - The result of an authorization decision or operation.
- Webhook
Format - Output format for webhook events.
Traits§
- Audit
Sink - Pluggable sink for audit event output.
Functions§
- last_
event - The last event of an audit log, for anchoring a new chain onto it.
- read_
events - Read every sealed event from an audit log, oldest first.
- verify_
chain_ from - Verify a chain that continues from an earlier one.
- verify_
hash_ chain - Verify the integrity of a hash chain produced by
AuditLogger. - verify_
hash_ chain_ with_ key - Verify the hash chain with an optional HMAC key.