Skip to content
Kaiov0.8.0

Langfuse

Langfuse records what agents do: every model call, its prompt, its cost and its latency, grouped into traces. Self-hosted, it is seven services: the web app, a worker, an AI gateway, Postgres, ClickHouse, Redis and MinIO.

Its Compose file is written the way Kaio wants one: every setting is a ${VARIABLE:-default}, so the file deploys unchanged and the variables do the rest. Upgrading means taking their next file as it is.

Terminal window
curl -fsSL -o compose.yml https://raw.githubusercontent.com/langfuse/langfuse/main/docker-compose.yml

Read it before deploying it, as you would any file you are about to run. The lines marked # CHANGEME are the ones the variables below replace.

LANGFUSE_IMAGE_TAG=4
TELEMETRY_ENABLED=false
NEXTAUTH_URL=http://localhost:3000
POSTGRES_PASSWORD=generate-with-openssl-rand-hex-32
DATABASE_URL=postgresql://postgres:same-postgres-password@postgres:5432/postgres
SALT=generate-with-openssl-rand-hex-32
ENCRYPTION_KEY=generate-with-openssl-rand-hex-32
NEXTAUTH_SECRET=generate-with-openssl-rand-hex-32
CLICKHOUSE_PASSWORD=generate-with-openssl-rand-hex-32
REDIS_AUTH=generate-with-openssl-rand-hex-32
MINIO_ROOT_PASSWORD=generate-with-openssl-rand-hex-32
LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY=same-minio-password
LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY=same-minio-password
LANGFUSE_S3_BATCH_EXPORT_SECRET_ACCESS_KEY=same-minio-password
LANGFUSE_INIT_ORG_ID=agents
LANGFUSE_INIT_ORG_NAME=Agents
LANGFUSE_INIT_PROJECT_ID=hermes
LANGFUSE_INIT_PROJECT_NAME=Hermes
LANGFUSE_INIT_PROJECT_PUBLIC_KEY=pk-lf-generate-one
LANGFUSE_INIT_PROJECT_SECRET_KEY=sk-lf-generate-one
LANGFUSE_INIT_USER_EMAIL=you@example.net
LANGFUSE_INIT_USER_NAME=you
LANGFUSE_INIT_USER_PASSWORD=generate-with-openssl-rand-hex-16
  • DATABASE_URL carries the Postgres password a second time, and the three *_SECRET_ACCESS_KEY repeat the MinIO one: the file reads them separately.
  • ENCRYPTION_KEY must be 64 hex characters, which is what openssl rand -hex 32 prints.
  • The LANGFUSE_INIT_* variables create the organisation, the project, its API keys and the first user at first start. Langfuse ships no default login, so without them the first person to open the page and sign up owns it. With them, an agent’s tracing keys exist before anyone opens a browser.
  • TELEMETRY_ENABLED defaults to true in their file.

Kaio flags most of these as secrets by name, but not SALT, REDIS_AUTH or DATABASE_URL, which carry one without saying so. Flag them on the deploy itself.

Terminal window
kaio-cli stack deploy langfuse ./compose.yml --env-file .env \
--secret SALT --secret REDIS_AUTH --secret DATABASE_URL
kaio-cli stack logs langfuse --follow

The three are masked from the first version on, never readable in clear from stack env ls or the API. The first start takes two to three minutes, while the web container runs its migrations, until it logs Ready. The UI answers on http://localhost:3000.

stack logs merges the seven services into one stream, each line prefixed by its service, which is the quickest way to see which one is holding the others back: the web app and the worker wait for the four stores to report healthy.

Their file publishes the web app on 3000, MinIO on 9090 and the AI gateway on 3031 on every interface; the stores and the worker stay on the loopback. MinIO is public because the browser uploads media straight to it. On a host reachable from outside, put a proxy in front or change those three lines, and set NEXTAUTH_URL and LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT to the addresses the browser actually uses.

Changing them is an edit Kaio keeps: the next version of the stack shows the diff, and stack deploy --dry-run shows what the deploy would change before it runs, as the review step does in the web UI.

Terminal window
curl -fsSL -o compose.yml https://raw.githubusercontent.com/langfuse/langfuse/main/docker-compose.yml
kaio-cli stack deploy langfuse ./compose.yml --dry-run
kaio-cli stack deploy langfuse ./compose.yml
kaio-cli stack versions langfuse

The dry run lists the services their new file adds, removes or recreates and the images it pulls, and changes nothing. Redeploying their newer file keeps the stored variables and records a version, so a release that breaks is stack rollback away for the Compose file. The data is another matter: migrations Langfuse ran on Postgres and ClickHouse are not undone by a rollback, so back the volumes up before a major version.

Terminal window
kaio-cli stack copy langfuse --to prod-02 --with-volumes --dry-run

The plan lists the five data volumes with their sizes, and the ports already taken on prod-02. ClickHouse can grow large on a busy project: read the sizes before dropping --dry-run.

Kaio, built by Régis Gaidot