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.
Prerequisites
Docker, plus curl and openssl on the host.
Run it
Generate credentials
Logbrook needs a separate ingestion token and read token. Each must be 16 to 512 visible ASCII characters with no whitespace.
export LOGBROOK_INGEST_TOKEN="$(openssl rand -hex 24)" export LOGBROOK_READ_TOKEN="$(openssl rand -hex 24)"Start the container
The image sets
LOGBROOK_BIND=0.0.0.0:3100and stores data in/data. The127.0.0.1:prefix publishes the port on the loopback interface only.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.0Check that it is up:
docker exec logbrook logbrook healthcheckIf the check fails, run
docker logs logbrook. The server writes JSON logs to stderr.Send an event
This writes one event to an index named
payments. The first authorized write to a new index creates it.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\" }]"{ "accepted": 1 }timeis a Unix timestamp in milliseconds,levelis a nonnegative integer (30 is Pino’sinfo), andmsgis the message. Other fields, such asorderId, become attributes.Search with the CLI
The container already has the read token in its environment, so run the CLI inside it:
docker exec logbrook logbrook query payments --since 1hAdd
--jsonto see the complete record, including theorderIdattribute.Search with curl
Over HTTP, pass the read token and a time range:
from(inclusive) andto(exclusive) in Unix milliseconds. This asks for the last hour: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"Stop and clean up
docker rm -f logbrookWithout a volume, removing the container deletes the data.