OpenObserve Docs

LobeChat → OpenObserve

Capture per-request latency and status codes for every chat completion processed by LobeChat. LobeChat is a self-hosted ChatGPT-like application with built-in OpenTelemetry support. Pass OTLP environment variables at startup and traces flow directly into OpenObserve.

Prerequisites

  • Docker
  • An OpenObserve account (cloud or self-hosted)
  • Your OpenObserve organisation ID and Base64-encoded auth token
  • An API key for at least one LLM provider (e.g. OpenAI)

Installation

Pull the LobeChat image:

docker pull lobehub/lobe-chat:latest

Configuration

Start LobeChat with ENABLE_TELEMETRY=1 and the standard OTLP environment variables. The exporter appends /v1/traces to OTEL_EXPORTER_OTLP_ENDPOINT automatically, so set the endpoint without the path suffix.

docker run -d --name lobechat \
  -p 3210:3210 \
  -e OPENAI_API_KEY=your_openai_api_key \
  -e OPENAI_MODEL_LIST=gpt-4o-mini \
  -e ENABLE_TELEMETRY=1 \
  -e OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:5080/api/default \
  -e "OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <your_base64_token>" \
  -e OTEL_SERVICE_NAME=lobechat \
  lobehub/lobe-chat:latest

For OpenObserve Cloud replace the endpoint and token:

OTEL_EXPORTER_OTLP_ENDPOINT=https://api.openobserve.ai/api/your_org_id
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <your_base64_token>

OPENAI_MODEL_LIST restricts the available models. Without it LobeChat may default to a model your account cannot access, causing all requests to fail with no spans emitted.

Viewing Traces

Open LobeChat at http://localhost:3210, select a model, and send a chat message. Each request appears in OpenObserve as a server span on the /webapi/chat/openai route.

  1. Log in to OpenObserve and navigate to Traces
  2. Filter by service_name = lobechat
  3. Each span covers the full round-trip from the browser request to the LLM provider response
  4. Use http_status_code to identify failed requests
  5. Sort by duration to find slow completions

LobeChat trace in OpenObserve

What Gets Captured

LobeChat exports HTTP server spans — one span per chat request. These are infrastructure-level spans: they capture route, latency, and status but not LLM-specific fields like token counts or model name.

AttributeDescription
operation_namePOST
http_target/webapi/chat/openai
http_methodPOST
http_status_codeHTTP response code (e.g. 200)
http_status_textOK on success
http_urlFull request URL
http_hostHost and port
http_request_content_length_uncompressedRequest body size in bytes
http_user_agentBrowser or client user agent
net_transportip_tcp
span_kindServer
span_statusUNSET on success, ERROR on failure
durationEnd-to-end request latency
service_service_versionLobeChat version (e.g. 1.143.3)
service_process_runtime_namenodejs

Next Steps

With LobeChat instrumented, every chat request is recorded in OpenObserve. From here you can monitor response latency, track error rates by route, and set up alerts when the chat API degrades.

Read More

Was this page helpful?

Last updated on

On this page