logbrook import loads events from a file straight into a data directory. Unlike HTTP ingestion, it accepts events older than the retention window, so use it to backfill history or migrate logs you already have on disk.
File format
The file holds events in the same shape as HTTP ingestion: each needs time (Unix milliseconds), level (integer) and msg (string).
| Format | Flag | Contents |
|---|---|---|
| JSON | none | One nonempty JSON array of event objects. It must fit within the body limit (1 MiB by default). |
| NDJSON | --ndjson |
One event object per line. Blank lines are skipped. The file is streamed in bounded batches. |
Use NDJSON for large files. A JSON file over the body limit fails with JSON import exceeds body limit; use batched NDJSON. An NDJSON line longer than the event limit (64 KiB by default) also fails.
Run an import
Stop the server
Stop the process or container that uses the data directory.
Set retention to cover the history
Retention works on event time. Set it to cover the imported history before you start the server again, or the events expire. See indexes and retention.
Import the file
Use the same config file or environment variables as the server:
logbrook --config logbrook.toml --index payments import events.ndjson --source checkout --ndjsonFor a JSON array:
logbrook --config logbrook.toml --index payments import events.json --source checkoutOn success the command prints the number of events committed:
{ "imported": 1250 }Start the server and check
Start the server again and count the events:
logbrook count payments --since 30d --source checkoutFor history older than that, pass
--fromand--toinstead. One query spans at most 31 days by default, so count longer history in adjacent windows.
Options
| Option | Meaning |
|---|---|
<file> |
Path of the JSON or NDJSON file. |
--source <name> |
Required. The source stored on every imported event, in place of the one an ingestion token would set. 1 to 128 ASCII letters, digits, -, _ or .. |
--ndjson |
Read the file as NDJSON instead of one JSON array. |
--index <name> |
Global option. Destination index, default if omitted. The index is created if it doesn’t exist. |
--config <file> |
Global option. The server’s TOML file. |
A new index still counts against max_indexes, and the command fails if creating it would exceed the limit.
Failures and retries
Each batch commits on its own. If a later batch is invalid or the process stops, earlier batches stay in the index. Rerunning the whole import then stores them a second time, because Logbrook doesn’t deduplicate.
For a clean retry, import into a new data directory. The { "imported": N } line is printed only after a complete run, so for a failed run use the error message: an over-long NDJSON line reports how many events were already committed.