Open MercatoDocsSearch docsAPI reference

User guide

Audit & Access Logs

Open the log when you need to explain who changed a record or viewed protected data. A recorded difference can show what changed and whether undo is available.

The Security → Audit Logs page surfaces every command executed through the new undo-aware pipeline.

Audit log timeline showing undoable entries

Undo support is currently available for directory tenants/organizations, auth users/roles, and example todos. Additional modules can opt-in by implementing command handlers with undo snapshots.

Undo and Diffs

Operation drawer highlighting changed fields and snapshots

The Undo banner auto-dismisses 10 seconds after the action is recorded. The timer pauses while an undo request is in flight so a slow API does not collapse the banner mid-click. Override the default by setting NEXT_PUBLIC_OM_UNDO_BANNER_TIMEOUT_MS (in milliseconds) at build time:

# .env (or .env.local)
NEXT_PUBLIC_OM_UNDO_BANNER_TIMEOUT_MS=15000

Non-numeric, zero, or negative values fall back to the 10s default. The variable is read at build time because it is a NEXT_PUBLIC_* env, so you must rebuild the app after changing it.

Retention

Access log retention is automatic and environment-configurable:

Configure these in your .env file to keep the volume of access logs under control while preserving critical trails for longer investigations.

Overload protection

Version. The capacity controls and metrics below are on the development branch after v0.10.0. Check your installed release before using these settings.

Access-log writes use two asynchronous stages: CRUD response dispatch and the audit-log service write. Each stage accepts up to 256 pending tasks per process by default. Set AUDIT_LOGS_MAX_PENDING to an integer of at least 2 to change that per-stage limit; invalid values, including 1, zero, and negative values use the default.

When a stage is full, the newest access-log task is skipped before parsing, encryption, or database work begins. The application request continues normally. Blocking mode does not wait for capacity: it returns the same deterministic skipped result. Warnings include the fixed stage, configured capacity, dropped tasks since the previous warning, totalDropped tasks over the tracker lifetime, and backlogDrained, even when telemetry is disabled. Capacity-rejection warnings are limited to once per minute per stage. Drops suppressed by that limit are reported by the next eligible warning or, at the latest, by one final warning with backlogDrained: true when the stage's backlog empties, so a burst that ends within the minute is still counted. Counts describe rejected tasks, so a rejected batch can contain multiple access-log records.

Retention sweeps are single-flight. Concurrent writes complete without waiting for an already-active sweep; shutdown flush still drains it. With AUDIT_LOGS_ROTATE_INTERVAL_MS=0, concurrent callers still avoid duplicate sweeps, while the next sequential write after rotation completes starts a new one.

When telemetry is enabled, the following low-cardinality metrics expose pressure without including tenant, organization, user, resource, or request values:

MetricMeaning
om.audit_logs.pending_writesCurrent accepted tasks, labelled by stage (crud_dispatch or service_write)
om.audit_logs.oldest_pending_ageAge in seconds of the oldest accepted task at that stage; zero when empty
om.audit_logs.droppedCapacity rejections, labelled by stage and fixed reason=capacity

Tenant admission during overload

AUDIT_LOGS_MAX_PENDING accepts integers of at least 2 (default 256; invalid values, including 1, use the default). Each tenant shares a quota across all its organizations: at most half the global cap, rounded down. This leaves room for another tenant when one is saturated. Mixed-tenant batches charge each distinct tenant. Counters are removed when work settles; tenant identities never become metric labels. The global cap still applies when several tenants are saturated, so logging remains best-effort rather than lossless. A write does not wait for an unrelated running retention sweep; shutdown flush still drains that sweep.

Previous: Attachments · Next: Autopay Payment Gateway