---
title: "Indexes, services and sources"
description: "How indexes partition storage and how services and sources identify where events came from."
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/logbrook/llms.txt
> Use this file to discover all available pages before exploring further.

# Indexes, services and sources

Three names organize your logs: the index they are stored in, the service that produced them, and the source that delivered them.

## Indexes

An index is a named, isolated collection of events. Each index has its own DuckDB database, its own Parquet archives, and its own retention and disk-size settings. Searches never cross indexes, and event IDs are unique only within one index.

Use separate indexes when data needs a different lifetime or access boundary, such as application logs kept for 7 days and audit logs kept for 90.

### Names and the default index

An index name has 1 to 63 lowercase ASCII letters, digits, hyphens or underscores, and starts with a letter or digit. It becomes a directory name and a metric label.

The `default` index always exists. The unprefixed `/logs` routes address it; every other index is under `/indexes/{index}/logs`.

### How an index maps to disk

Each index lives in its own directory under `<data_dir>/indexes/`.

- data/
  - indexes/
    - default/
      - events.duckdb
      - events.duckdb.wal
      - archives/
        - ...
      - temp/
    - payments/
      - ...
  - .index-trash/

| Path | Contents |
| --- | --- |
| `events.duckdb` | Recent ("hot") events and the archive manifest. |
| `events.duckdb.wal` | DuckDB's write-ahead log, present while committed changes are not yet checkpointed into `events.duckdb`. |
| `archives/` | Parquet files for older events. |
| `temp/` | DuckDB spill files for large queries. |
| `.index-trash/` | Holds a deleted index's directory until cleanup finishes. It is not a backup. |

Logbrook discovers existing index directories at startup. Index directories and files can't be symlinks, and only one Logbrook process may use a data directory.

### How indexes get created

An index is created by any of these:

- The first authorized ingestion request to a new name.
- `PUT /indexes/{index}` or `logbrook indexes create`. The call is idempotent.
- An `[indexes.<name>]` table in the configuration, at startup.
- A name listed in `LOGBROOK_INDEXES`, at startup.

Reads never create an index. A read from an unknown index returns `404`.

`max_indexes` caps how many indexes can exist. It is 4 by default and counts `default`. Creating one past the limit returns `429`.

Only an admin token can delete an index. The `default` index and indexes declared in the configuration, including names in `LOGBROOK_INDEXES`, can't be deleted.

> **Index limits share memory**
>
> `max_indexes` is also the number of slots that `storage.memory_limit`, `storage.temp_limit` and `storage.queue_bytes` divide across. Unused slots still reserve their share. See [indexes and retention](https://sandrinodm.github.io/logbrook/configure/indexes-and-retention/).

## Services

A service is the application or component that produced an event, such as `api` or `billing-worker`. It comes from the event's own `service` field, and it is optional.

The producer sets it, so a service name is a label, not a security boundary. You can filter and facet on it, but you can't scope a credential to it. Use sources or indexes for access control.

## Sources

A source is a name that the server configuration assigns to an ingestion token. Logbrook stamps every event sent with that token with its source, and the payload can't override it.

```toml title="logbrook.toml"
[ingest_tokens]
"replace-with-token-for-checkout" = "checkout-prod"
"replace-with-token-for-batch" = "batch-prod"
```

A source names a delivery path: a deployment, a team, or a collector. One source can carry logs from several services, and one service can appear under several sources.

Source names have 1 to 128 ASCII letters, digits, hyphens, underscores or periods.

### Scoping read tokens

Read tokens are limited by source and, optionally, by index:

- In `[read_tokens]`, each token maps to a list of sources it may read. An empty list grants every source.
- In `[read_index_scopes]`, a token can map to a list of indexes. A missing entry or an empty list grants every index.

A request must satisfy both limits. A token scoped to the source `checkout-prod` and the index `payments` sees only `checkout-prod` events in `payments`. Requests to other indexes return `403`.

A request that names a source the token doesn't allow returns `403`. A request that names none gets the token's own sources. Live tail, facets and histograms are scoped the same way.

Ingestion tokens can also be limited to indexes with `[ingest_index_scopes]`. Their source is always fixed by the token.

Some endpoints return less detail to a source-scoped reader. `GET /indexes/{index}`, for example, returns only the index name.

See [credentials and roles](https://sandrinodm.github.io/logbrook/configure/credentials/) for the full configuration.

## Next steps

- [Credentials and roles](https://sandrinodm.github.io/logbrook/configure/credentials/) — Configure ingestion, read and admin tokens.
- [Indexes and retention](https://sandrinodm.github.io/logbrook/configure/indexes-and-retention/) — Set limits and per-index policy.
- [Search and live tail](https://sandrinodm.github.io/logbrook/concepts/search-and-tail/) — How reads work across hot and archived events.

Source: https://sandrinodm.github.io/logbrook/concepts/indexes-services-sources/index.mdx
