Audit logs are the only stream where the cost of loss exceeds the cost of storage: they cannot be "caught up later" — they are either recorded at the moment of the event or not at all. Experience from building audit delivery from cloud infrastructure into a central store — and the list of places where it all breaks in practice.
Requirements for audit
- Completeness. Every administrative action is recorded: who, what, when, from where. A gap is not "incomplete data" but a hole in provability.
- Timeliness. Delivery lags in minutes, not hours: an incident investigation must not wait for the morning export.
- Immutability. A store you can't append to "after the fact" — otherwise it's not a journal, it's notes.
- Separability. Audit lives apart from ordinary logs: different retention, different access, different owner.
The channel map
Audit is not one stream but several, and mixing them is a way to lose everything at once:
| Channel | Sources | Particulars | Delivered to |
|---|---|---|---|
| Platform audit | API actions, administrative events, configuration changes | structured JSON, already user-tagged | a separate output into the central store |
| Peripheral services | network, proxies, access control systems | each with its own format and "empty" fields | its own parser, then the shared transport |
| Hypervisor layer and VM agents | virtual machine events, image operations | collected by different mechanisms | never converge into one pipeline without a source label |
Transport with a guarantee: disk buffering
The main way to lose audit is a network failure with no buffer. Shipping with a disk queue and retries:
action(type="omfwd" target="audit-collector.internal" port="6514"
protocol="tcp" template="audit_json"
queue.type="LinkedList"
queue.filename="audit-queue"
queue.maxDiskSpace="4g"
queue.saveOnShutdown="on"
action.resumeRetryCount="-1")
The gateway is down — the queue accumulates on disk and drains once it's back. Without this setting, "gateway unavailable" turns into "last night's audit is missing".
Where audit gets lost
- A wrong parser. The message is in the index, but the fields are empty — "there's a log, no meaning": search by user or action doesn't work. Fixed by versioning parsers and testing on real samples.
- Source-site failure. The collector's queue overflowed — delivery stalled and nobody noticed. Fixed by buffering (see above) and a lag alert.
- Rotation.
logrotateoverwrites the file before the collector has read it to the end. Fixed with the "rotate → copytruncate vs savelog" combo, read speed checks and inode tuning. - Silent empty fields.
x-forwarded-forbehind a proxy, the user shows "system" instead of the real one: audit without a request source is nearly useless. Fixed by validating the proxy chain in the pipeline. - Channel silence. A source stopped writing, no alerts — "silence means all is well" until the first investigation. Fixed by an alert on the absence of the stream.
Delivery monitoring
Audit that hasn't moved for N minutes is an alert, not silence. Two rules that catch most failures:
# the channel is silent for over 15 minutes - something broke along the way
absent_over_time(audit_events_total{channel="platform"}[15m])
# delivery lag over five minutes
audit_delivery_lag_seconds > 300
Plus a counter of received vs sent documents per source — the divergence grows when a parser silently drops events.
Storage: retention and immutability
- A separate retention for audit — longer than for regular logs: 30 days is enough for those; audit is kept per regulation requirements (often a year or more).
- Immutability. A bucket with a no-rewrite/no-delete policy (WORM-like) or an append-only store with separate rights: the platform writes, security reads, nobody has "admin" rights.
- Encryption in transit and at rest. TLS for transport, encryption on disk; an audit dump in the clear devalues all the effort.
- Restore verification — as with backups: a journal that can't be read from a backup is not a journal.
The audit channel launch checklist
- Map the channels: platform, periphery, hypervisor layer — separate streams with a source label.
- Enable the disk queue on every sender and verify it by switching the receiver off.
- Versioned parsers with tests on real samples from every source.
- Alerts on channel silence and delivery lag.
- Separate retention, immutable storage, encryption.
- A trial investigation: pick a real event from a week ago and find it in five minutes. If it isn't found — the channel isn't ready yet.
The maturity test of an audit channel is simple: ask to answer "who and when changed this configuration" using data the channel collected over the last month. If the answer took more than five minutes — the channel needs more work.
The parser as a release: tests on real samples
An audit-channel parser is code, and it gets versioned as code, not "tweaked in a console":
tests/
samples/
platform_action_001.json # samples gathered from production events (anonymized)
peripheral_proxy_001.raw
test_parser.py: # every commit runs the parser over the samples
- assert parse(sample).user == "..."
- assert parse(sample).action in KNOWN_ACTIONS
- assert parse(malformed) returns None # and the error counter grows instead of staying quiet
- A new source type = a new sample file — a comprehensible contract between whoever knows the source and whoever writes the parser.
- A parser failing silently is the worst scenario. Any line without a recognized field goes into a "quarantine index": the quarantine counter is under an alert, reviewed once a week.
What changes in monitoring when a source is added
| Check | Tool | Threshold |
|---|---|---|
| The source stream is alive | counter audit_events_total{source} | absence for 15 minutes |
| Share of "empty" events | quarantine / inbound stream | >1% — alert |
| Delivery lag | collector lag metric | >5 minutes |
| Reconciliation with the source | a reconciliation job: events at the receiver vs the sender | divergence grows over a day |
The last row is the rarest and most valuable: reconciliation catches "silent" losses invisible to any single alert, because every component by itself is "green".