Every index inherits a global retention period and disk-size target, and [indexes.<name>] tables override them per index. Archives, retention and backups explains how archival and expiry work.
Index limits
max_indexes caps the number of indexes, including default. The default is 4 and the range is 1 to 64.
max_indexes = 8Env: LOGBROOK_MAX_INDEXES. At startup, Logbrook counts the default index, every [indexes.<name>] table and LOGBROOK_INDEXES name, and the index directories already on disk. It refuses to start if the total exceeds the limit.
At the limit, a request that would create another index fails with 429 and maximum index count reached; increase max_indexes and restart. Raise the limit and restart, or delete an index.
The limit also splits memory
DuckDB memory, DuckDB spill space and the ingestion queue byte budget are process-wide totals divided by max_indexes. Unused slots keep their share, so creating an index doesn’t add memory.
| Setting | Default total | Per slot with max_indexes = 4 |
|---|---|---|
storage.memory_limit |
512 MB | 128 MB |
storage.temp_limit |
2 GB | 500 MB |
storage.queue_bytes |
32 MiB | 8 MiB |
Thread settings apply per index, so each index adds threads and connections. For a single-index deployment, set max_indexes = 1. If you raise the limit, raise the totals too.
Create indexes
An index can be created in four ways:
- First authorized write. An ingestion request to
POST /indexes/payments/logs/ingestcreatespaymentsif the token is allowed to write there. Reads never create an index. - Explicit creation.
logbrook indexes create paymentsorPUT /indexes/payments, with an ingestion or admin token. It is idempotent. - TOML. An
[indexes.payments]table creates it at startup, even if the table is empty. - Environment.
LOGBROOK_INDEXES=payments,auditcreates those indexes at startup. Existing tables keep their policies. Empty entries are ignored and whitespace is not trimmed.
Names have 1 to 63 lowercase ASCII letters, digits, hyphens or underscores, and start with a letter or digit.
ingest_index_scopes restricts where a token may write. A token scoped to payments can’t create audit by writing to it.
The default index and indexes declared in TOML or LOGBROOK_INDEXES can’t be deleted. An admin token can delete the others:
logbrook indexes delete audit --yesDeletion is permanent. Stop producers first, because the next ingestion request recreates the index.
Retention
Retention is how long events are kept, measured against event time. Set the global default at the top level of the file.
retention_days = 30
archive_after_ms = 86400000| Key | Env | Default |
|---|---|---|
retention_days |
LOGBROOK_RETENTION_DAYS |
unset |
retention_ms |
LOGBROOK_RETENTION_MS |
604800000 (7 days) |
archive_after_ms |
LOGBROOK_ARCHIVE_AFTER_MS |
86400000 (1 day) |
- Values must be positive integers.
- Retention must be longer than the archive age. For one-day retention, also lower
archive_after_ms, for example to3600000. - In the file,
retention_dayswins overretention_msif both are set. - Retention applies to each index separately.
The shipped container Compose file sets LOGBROOK_RETENTION_DAYS to 7 unless you override it.
Disk-size targets
A disk-size target makes an index expire its oldest events before they reach the age limit. It is off by default.
max_size_gb = 20| Key | Env | Default |
|---|---|---|
max_size_gb |
LOGBROOK_MAX_SIZE_GB |
disabled |
storage.max_size_bytes |
LOGBROOK_MAX_SIZE_BYTES |
disabled |
max_size_gbis decimal: 20 means 20,000,000,000 bytes.- The smallest byte target is 16 MiB (16777216).
- In the file,
max_size_gbwins overstorage.max_size_bytesif both are set. - In the environment, set only one of
LOGBROOK_MAX_SIZE_GBandLOGBROOK_MAX_SIZE_BYTES. - The target applies to each index: 20 GB means 20 GB for every index.
- The Compose file defaults to 20 GB. Running the binary without a file or variable gives no target.
The target counts the database, WAL, archives, spill files and other files Logbrook owns in the index directory. Over the target, maintenance expires the oldest events first, and ingestion returns 507 while the index stays at its target.
Per-index overrides
An [indexes.<name>] table overrides the inherited values for one index. Omitted keys inherit the resolved global value.
retention_days = 30
max_size_gb = 20
[indexes.audit]
retention_days = 90
max_size_gb = 5
[indexes.payments]
retention_ms = 1209600000
archive_after_ms = 43200000Per-index keys: retention_days, retention_ms, archive_after_ms, max_size_gb, max_size_bytes and promoted_string_keys.
- In one table, use
retention_daysorretention_ms, not both. Likewisemax_size_gbormax_size_bytes. - Per-index values override the global file values and the global environment variables. There are no per-index environment overrides.
- A per-index retention must still exceed that index’s archive age, whether the archive age is its own or inherited.
- Changing a global value later doesn’t change an index that overrides it.
Check what an index resolved to:
logbrook indexes show auditThe output shows the measured size, the size target, the retention and whether the index is ready. With --json it includes the raw retention_ms and max_size_bytes.
Change retention
Policy changes apply on restart. Maintenance runs once at startup and then at each maintenance_interval_secs.
- Shortening retention can expire existing events on the first pass. This can’t be undone.
- Lengthening retention doesn’t bring back expired events. The stored expiry cutoff only moves forward, and ingestion keeps rejecting events older than it.
- Raising a disk-size target stops further size-based expiry but doesn’t restore expired events.
Before you shorten retention, check what the new window removes, and take a backup if you may want the data.
Validate the file before restarting:
logbrook --config logbrook.toml check-config