Skip to main content

OpenTelemetry

Open WebUI supports distributed tracing and metrics export via the OpenTelemetry (OTel) protocol (OTLP). This enables integration with modern observability stacks such as Grafana LGTM (Loki, Grafana, Tempo, Mimir), as well as Jaeger, Tempo, and Prometheus to monitor requests, database/Redis queries, response times, and more in real-time.

Additional Dependencies

If you are running Open WebUI from source or via pip (outside of the official Docker images), OpenTelemetry dependencies may not be installed by default. You may need to install them manually:

pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp

Those three are not enough on their own: the setup also imports eight opentelemetry-instrumentation-* packages (FastAPI, SQLAlchemy, Redis, requests, httpx, aiohttp-client, logging and system-metrics). Install the ## Trace block from backend/requirements.txt, which pins all of them.

Quick Start with Docker Compose​

The fastest way to get started with observability is to download the example Compose file and start Open WebUI with a local Grafana LGTM stack:

curl -fsSLO https://docs.openwebui.com/docker-compose.otel.yaml
docker compose -f docker-compose.otel.yaml up -d

The docker-compose.otel.yaml file sets up these components:

ServicePort(s)Description
lgtm3000 (UI), 4317 (OTLP/gRPC), 4318 (HTTP)Grafana LGTM (Loki + Grafana + Tempo + Mimir) stack
open-webui8088 → 8080Open WebUI with OTEL export enabled

After startup:

Environment Variables​

You can configure OpenTelemetry in Open WebUI with these environment variables (as used in the Compose file). Outside that file the code defaults are all four ENABLE_OTEL* switches off, the endpoint http://localhost:4317, and OTEL_EXPORTER_OTLP_INSECURE off:

VariableDefaultDescription
ENABLE_OTELtrue in ComposeMaster switch to enable OpenTelemetry setup
ENABLE_OTEL_TRACEStrue in ComposeEnable distributed tracing export
ENABLE_OTEL_METRICStrue in ComposeEnable FastAPI HTTP metrics export
ENABLE_OTEL_LOGStrue in ComposeEnable OpenTelemetry log export
OTEL_EXPORTER_OTLP_ENDPOINThttp://lgtm:4317 in ComposeOTLP endpoint used for traces
OTEL_METRICS_EXPORTER_OTLP_ENDPOINThttp://lgtm:4317 in ComposeOTLP endpoint used for metrics
OTEL_LOGS_EXPORTER_OTLP_ENDPOINThttp://lgtm:4317 in ComposeOTLP endpoint used for logs
OTEL_EXPORTER_OTLP_INSECUREtrue in ComposeInsecure (no TLS) connection for OTLP
OTEL_SERVICE_NAMEopen-webuiService name (tagged in traces and metrics)
OTEL_OTLP_SPAN_EXPORTERgrpcExporter protocol: grpc (port 4317) or http (port 4318, with the signal path in the endpoint, such as /v1/traces, since the endpoint is passed to the exporter unchanged); OTEL_METRICS_OTLP_SPAN_EXPORTER and OTEL_LOGS_OTLP_SPAN_EXPORTER override it per signal
OTEL_METRICS_EXPORT_INTERVAL_MILLIS10000Metrics export interval in ms (10s = ~6 DPM; set 60000 for ~1 DPM)
OTEL_BASIC_AUTH_USERNAME / OTEL_BASIC_AUTH_PASSWORD(empty)Basic Auth credentials if Collector requires them
tip

Override defaults in your .env file or Compose file as needed.

  open-webui:
    environment:
      - ENABLE_OTEL=true
      - ENABLE_OTEL_TRACES=true
      - ENABLE_OTEL_METRICS=true
      - ENABLE_OTEL_LOGS=true
      - OTEL_EXPORTER_OTLP_INSECURE=true # Use insecure connection for OTLP, you may want to remove this in production
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://lgtm:4317
      - OTEL_METRICS_EXPORTER_OTLP_ENDPOINT=http://lgtm:4317
      - OTEL_LOGS_EXPORTER_OTLP_ENDPOINT=http://lgtm:4317
      - OTEL_SERVICE_NAME=open-webui
      # You may set OTEL_BASIC_AUTH_USERNAME/PASSWORD here if needed

Data Collection​

Distributed Tracing​

The Open WebUI backend automatically instruments:

  • FastAPI (routes)
  • SQLAlchemy (the sync engine only: the /ready and /health/db pings, the user-count gauges, and pgvector or openGauss when they share the main database; request-time queries run on the async engine)
  • Redis
  • requests, httpx, aiohttp (external calls)
  • logging (trace and span ids on log records) and host system metrics

Log export needs both ENABLE_OTEL and ENABLE_OTEL_LOGS.

Each trace span includes rich data such as:

  • db.instance, db.statement, redis.args
  • http.url, http.method, http.status_code
  • Error details (error.message, error.kind) on exceptions

Metrics Collection​

WebUI exports the following metrics via OpenTelemetry:

InstrumentTypeUnitLabels
http.server.requestsCounter1http.method, http.route, http.status_code
http.server.durationHistogramms(same as above)
webui.users.totalGaugeusers(none)
webui.users.activeGaugeusers(none)
webui.users.active.todayGaugeusers(none)

The three user gauges are read from the database at each export:

  • webui.users.total: registered users.
  • webui.users.active: users active in the last 3 minutes.
  • webui.users.active.today: users active since midnight UTC today, not local midnight.

Metrics are sent via OTLP (default every 10 seconds, configurable via OTEL_METRICS_EXPORT_INTERVAL_MILLIS) and can be visualized in Grafana (via Prometheus/Mimir).

To leave routes such as health checks out of both traces and HTTP metrics, set OTEL_PYTHON_FASTAPI_EXCLUDED_URLS (or OTEL_PYTHON_EXCLUDED_URLS) to comma-separated regular expressions. Each is matched anywhere in the request URL, so /health,/_app/immutable/.* also covers /health/db.

Custom Collector Setup​

To use a different (external) OpenTelemetry Collector/Stack:

docker run -d --name open-webui \
  -p 8088:8080 \
  -e ENABLE_OTEL=true \
  -e ENABLE_OTEL_TRACES=true \
  -e ENABLE_OTEL_METRICS=true \
  -e OTEL_EXPORTER_OTLP_ENDPOINT=http://your-collector:4317 \
  -e OTEL_EXPORTER_OTLP_INSECURE=true \
  -e OTEL_METRICS_EXPORTER_OTLP_ENDPOINT=http://your-collector:4317 \
  -e OTEL_LOGS_EXPORTER_OTLP_ENDPOINT=http://your-collector:4317 \
  -e OTEL_SERVICE_NAME=open-webui \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main

Troubleshooting​

Traces/metrics not appearing in Grafana?

  • Double-check ENABLE_OTEL, ENABLE_OTEL_TRACES, and ENABLE_OTEL_METRICS are all set to true
  • Is the endpoint correct? In the example Compose file it must be reachable as http://lgtm:4317 from the Open WebUI container.
  • Inspect logs from Open WebUI (docker logs open-webui-otel) for OTLP errors
  • Check that the collector is reachable from the Open WebUI container. A plain HTTP curl request to port 4317 cannot verify that the collector accepts OTLP over gRPC.

OTLP reports UNAVAILABLE​

If the exporter logs UNAVAILABLE even though the port is reachable, check that the exporter protocol matches the listener on the collector. The default ports are 4317 for gRPC and 4318 for HTTP. With HTTP, check the path for the failing signal, such as /v1/traces, /v1/metrics, or /v1/logs. OTLP protocol specification

Check OTEL_OTLP_SPAN_EXPORTER for traces. Metrics and logs can override that choice with OTEL_METRICS_OTLP_SPAN_EXPORTER and OTEL_LOGS_OTLP_SPAN_EXPORTER, respectively.

Authentication required?

  • Set OTEL_BASIC_AUTH_USERNAME and OTEL_BASIC_AUTH_PASSWORD for auth-protected collectors
  • Set the standard OpenTelemetry variable OTEL_EXPORTER_OTLP_HEADERS to comma-separated key=value pairs (for example x-api-key=your-key,x-team-id=your-team) for backends that expect other headers, such as an API key. It is ignored while the basic auth variables are set.
  • If using SSL/TLS, adjust or remove OTEL_EXPORTER_OTLP_INSECURE as appropriate
This content is for informational purposes only and does not constitute a warranty, guarantee, or contractual commitment. Open WebUI is provided "as is." See your license for applicable terms.