Overview
If you have an existing audit log implementation (database tables, log files, or another service), you can migrate to Immutable incrementally without downtime.Strategy
Map your schema
Map your existing audit log fields to Immutable’s event structure:
| Your Field | Immutable Field |
|---|---|
user_id | actor_id |
user_email | actor_name |
event_type | action |
target_type | resource (resource type) |
target_id | resource_id |
details | metadata |
organization_id | tenant_id |
created_at | occurred_at |
Dual-write in production
Start writing to both your existing system and Immutable simultaneously. This lets you validate that Immutable captures everything correctly before cutting over.
Backfill historical data
Use the batch endpoint to import historical events. Use
idempotency_key to make the import safe to retry:Use a unique
idempotency_key per historical event (e.g. prefixed with migration_). This ensures safe replay — if the import job crashes partway through, you can re-run it without creating duplicate events.Validate
Compare event counts and spot-check specific events between your old system and Immutable:Check the
pagination.total field in the response to compare against your old system’s count.Gradual Rollout
If you prefer a more cautious approach, roll out by tenant:- Start tracking events to Immutable for a single tenant.
- Verify the data is correct.
- Gradually add more tenants.
- Once all tenants are migrated, remove the old system.
tenant_id field to isolate events per customer, making it easy to query and verify each tenant’s data independently.
Tips
- Set
occurred_aton backfilled events to preserve the original timestamp. Without it, all imported events will have the import time as theiroccurred_at. - The hash chain is built based on
created_at(server time), so backfilled events will have a different chain order than their original chronological order. This is expected and correct. - Use event schemas in permissive mode during migration to discover all action strings your old system uses, then switch to strict mode once you have defined patterns for all of them.