Skip to main content
Open WebUI provides comprehensive observability through OpenTelemetry, enabling production monitoring with distributed tracing, metrics collection, and centralized logging.

Overview

OpenTelemetry integration provides:
  • Distributed Tracing - Track requests across services and workers
  • Metrics Collection - Monitor performance, usage, and system health
  • Structured Logging - Centralized log aggregation and analysis
  • Auto-Instrumentation - Automatic instrumentation of FastAPI, SQLAlchemy, Redis, and HTTP clients

Configuration

Enable OpenTelemetry

Set these environment variables to enable observability:

OTLP Exporter Configuration

Configure the OpenTelemetry Protocol (OTLP) endpoint:

Transport Protocol

Choose between HTTP and gRPC:

Authentication

For authenticated endpoints:

Resource Attributes

Add custom resource attributes:

Sampling Configuration

Observability Backend Integration

Datadog

New Relic

Honeycomb

Grafana Cloud

Self-Hosted OpenTelemetry Collector

Docker Compose with OpenTelemetry Collector

OpenTelemetry Collector Configuration

otel-collector-config.yaml:

Auto-Instrumented Components

Open WebUI automatically instruments:

FastAPI

  • HTTP request/response traces
  • Endpoint latency metrics
  • Error rates and status codes
  • Request attributes (method, path, status)

SQLAlchemy

  • Database query traces
  • Query execution time
  • Connection pool metrics
  • Database type and operations

Redis

  • Redis command traces
  • Command execution time
  • Connection metrics
  • Cache hit/miss rates

HTTP Clients (httpx, aiohttp, requests)

  • External API call traces
  • Request/response attributes
  • Latency and error tracking

Custom Instrumentation

Add custom spans and metrics in your code:

Structured Logging

Enable JSON-formatted logs for centralized log aggregation:
JSON log output:

Metrics

Key metrics collected:
  • HTTP Metrics
    • http.server.duration - Request latency
    • http.server.active_requests - Concurrent requests
    • http.server.request.size - Request body size
    • http.server.response.size - Response body size
  • Database Metrics
    • db.client.connections.usage - Connection pool usage
    • db.client.operation.duration - Query execution time
  • Redis Metrics
    • redis.command.duration - Command execution time
    • redis.connections - Active connections

Troubleshooting

Traces Not Appearing

Check:
  • ENABLE_OTEL=true and ENABLE_OTEL_TRACES=true
  • Collector endpoint is reachable: telnet otel-collector 4317
  • Check collector logs for connection errors
  • Verify authentication credentials

High Overhead

Reduce sampling:

Collector Connection Refused

For gRPC:
For HTTP:

TLS Certificate Errors

Implementation Details

  • Telemetry setup: backend/open_webui/utils/telemetry/setup.py
  • Metrics configuration: backend/open_webui/utils/telemetry/metrics.py
  • Logs configuration: backend/open_webui/utils/telemetry/logs.py
  • Auto-instrumentation: backend/open_webui/utils/telemetry/instrumentors.py
  • Uses OpenTelemetry SDK 1.39.1 with OTLP exporters

Security Considerations

Observability Security:
  1. Sensitive Data - Ensure traces/logs don’t contain passwords, API keys, or PII
  2. Authentication - Use Basic Auth or API keys for collector endpoints
  3. TLS/SSL - Enable TLS for production collector connections
  4. Network Isolation - Restrict collector access to application network
  5. Sampling - Use sampling to reduce data volume and costs

Next Steps