---
title: "Quickstart"
description: "Run Logbrook with Docker, send an event, and search it in five minutes."
---

> 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.

# Quickstart

Run the published container image, send one event, and search it. Nothing persists after you remove the container; for a setup that keeps its data, use [Docker Compose](https://sandrinodm.github.io/logbrook/get-started/docker-compose/).

## Prerequisites

Docker, plus `curl` and `openssl` on the host.

## Run it

1. **Generate credentials**

   Logbrook needs a separate ingestion token and read token. Each must be 16 to 512 visible ASCII characters with no whitespace.

   ```sh
   export LOGBROOK_INGEST_TOKEN="$(openssl rand -hex 24)"
   export LOGBROOK_READ_TOKEN="$(openssl rand -hex 24)"
   ```
2. **Start the container**

   The image sets `LOGBROOK_BIND=0.0.0.0:3100` and stores data in `/data`. The `127.0.0.1:` prefix publishes the port on the loopback interface only.

   ```sh
   docker run -d --name logbrook \
     -p 127.0.0.1:3100:3100 \
     -e LOGBROOK_INGEST_TOKEN \
     -e LOGBROOK_READ_TOKEN \
     ghcr.io/sandrinodm/logbrook:0.5.0
   ```

   Check that it is up:

   ```sh
   docker exec logbrook logbrook healthcheck
   ```

   If the check fails, run `docker logs logbrook`. The server writes JSON logs to stderr.
3. **Send an event**

   This writes one event to an index named `payments`. The first authorized write to a new index creates it.

   ```sh
   curl --fail http://127.0.0.1:3100/indexes/payments/logs/ingest \
     -H "Authorization: Bearer $LOGBROOK_INGEST_TOKEN" \
     -H 'Content-Type: application/json' \
     --data "[{ \"time\": $(( $(date +%s) * 1000 )), \"level\": 30, \"service\": \"checkout\", \"msg\": \"Order accepted\", \"orderId\": \"demo-1\" }]"
   ```

   ```json
   { "accepted": 1 }
   ```

   `time` is a Unix timestamp in milliseconds, `level` is a nonnegative integer (30 is Pino's `info`), and `msg` is the message. Other fields, such as `orderId`, become attributes.
4. **Search with the CLI**

   The container already has the read token in its environment, so run the CLI inside it:

   ```sh
   docker exec logbrook logbrook query payments --since 1h
   ```

   Add `--json` to see the complete record, including the `orderId` attribute.
5. **Search with curl**

   Over HTTP, pass the read token and a time range: `from` (inclusive) and `to` (exclusive) in Unix milliseconds. This asks for the last hour:

   ```sh
   now=$(( $(date +%s) * 1000 ))
   curl --fail -H "Authorization: Bearer $LOGBROOK_READ_TOKEN" \
     "http://127.0.0.1:3100/indexes/payments/logs?from=$(( now - 3600000 ))&to=$(( now + 60000 ))&limit=10"
   ```
6. **Stop and clean up**

   ```sh
   docker rm -f logbrook
   ```

   Without a volume, removing the container deletes the data.

> **Image tags**
>
> The `0.5.0` tag is the release version without the Git `v` prefix. See [Releases and container images](https://sandrinodm.github.io/logbrook/project/releases/) for the tags that exist.

## Next steps

- [Run with Docker Compose](https://sandrinodm.github.io/logbrook/get-started/docker-compose/) — Keep your data across restarts.
- [Send logs over HTTP](https://sandrinodm.github.io/logbrook/send-logs/http/) — Batch formats, fields and limits.
- [Search and filter](https://sandrinodm.github.io/logbrook/query/search/) — Narrow results by level, service and attributes.

Source: https://sandrinodm.github.io/logbrook/get-started/quickstart/index.mdx
