Documentation
Complete guide to install, configure, and use AI Observer to monitor your AI coding assistants. This page covers AI Observer v0.7.0.
Upgrading to 0.7.0
Back up your database first: on its first start, 0.7.0 updates the database once, which can take a while on large
databases. The binary now listens on 127.0.0.1 only, unknown host names are
rejected, and secrets are redacted before telemetry is stored. See the changelog for
all upgrade notes.
Installation
AI Observer can be installed using Docker, Homebrew (macOS), or as a standalone binary.
Docker (Recommended)
docker run -d \
--name ai-observer \
-p 127.0.0.1:8080:8080 \
-p 127.0.0.1:4318:4318 \
-v ai-observer-data:/app/data \
tobilg/ai-observer:latest
Dashboard: http://localhost:8080 |
OTLP endpoint: http://localhost:4318
The ports are published on 127.0.0.1 only, because stored telemetry can include
prompts, code and tool output. Drop the 127.0.0.1: prefix only on trusted
networks (see Network Access).
Using a Local Directory for Data
# Create a local data directory
mkdir -p ./ai-observer-data
# Run with local volume mount
docker run -d \
-p 127.0.0.1:8080:8080 \
-p 127.0.0.1:4318:4318 \
-v $(pwd)/ai-observer-data:/app/data \
-e AI_OBSERVER_DATABASE_PATH=/app/data/ai-observer.duckdb \
--name ai-observer \
tobilg/ai-observer:latest Homebrew (macOS Apple Silicon)
brew tap tobilg/ai-observer
brew install ai-observer
ai-observer Binary Download
Download the archive for your platform from GitHub Releases (Linux amd64, macOS arm64, Windows amd64), extract it and run the binary:
# Linux (amd64)
curl -L https://github.com/tobilg/ai-observer/releases/download/v0.7.0/ai-observer-linux-amd64-v0.7.0.tar.gz | tar -xz
./ai-observer
# macOS (Apple Silicon)
curl -L https://github.com/tobilg/ai-observer/releases/download/v0.7.0/ai-observer-darwin-arm64-v0.7.0.tar.gz | tar -xz
./ai-observer
The binary listens on 127.0.0.1. Set
AI_OBSERVER_HOST=0.0.0.0 to accept telemetry from other machines or containers.
Building from Source
Requires Go 1.26, Node 22, pnpm 10 and a C toolchain (CGO is needed for DuckDB).
git clone https://github.com/tobilg/ai-observer.git
cd ai-observer
make setup # Install dependencies
make all # Build single binary with embedded frontend
./bin/ai-observer Configuration
AI Observer uses environment variables for configuration.
Environment Variables
| Variable | Default | Description |
|---|---|---|
| AI_OBSERVER_HOST | 127.0.0.1 (binary), 0.0.0.0 (Docker) | Network interface both servers listen on |
| AI_OBSERVER_API_PORT | 8080 | HTTP server port (dashboard + API) |
| AI_OBSERVER_OTLP_PORT | 4318 | OTLP ingestion port |
| AI_OBSERVER_DATABASE_PATH | ./data/ai-observer.duckdb (binary), /app/data/ai-observer.duckdb (Docker) | DuckDB database file path |
| AI_OBSERVER_FRONTEND_URL | http://localhost:5173 | Allowed CORS origin (dev mode) |
| AI_OBSERVER_ALLOWED_HOSTS | (empty) | Comma-separated host names accepted by the dashboard/API and as browser origins, in addition to IP addresses and localhost; * disables both checks |
| AI_OBSERVER_LOG_LEVEL | INFO | Log level: DEBUG, INFO, WARN, ERROR |
| AI_OBSERVER_AUTH_TOKEN | (empty: no authentication) | Shared token required on OTLP and API requests |
| AI_OBSERVER_REDACT | secrets | What is replaced before telemetry is stored: secrets, all (secrets and personal data) or off |
| AI_OBSERVER_RETENTION_DAYS | (empty: keep all) | serve and watch delete telemetry older than this many days, on startup and then hourly |
| AI_OBSERVER_PRICING_DIR | (empty) | Directory with pricing files that add models or replace built-in prices, such as those written by pricing update |
| AI_OBSERVER_MCP | false | Serve the MCP endpoint for agents at /mcp on the API port (same as --mcp) |
Session file locations for import and watch
are set with their own variables.
Network Access
Stored telemetry can include prompts, code and tool output, so the binary listens on
127.0.0.1 only. To accept telemetry or dashboard requests from other machines or
a dev container, set AI_OBSERVER_HOST=0.0.0.0, on trusted networks only and
preferably together with AI_OBSERVER_AUTH_TOKEN. The Docker image listens on all
interfaces inside the container; publish its ports to 127.0.0.1 to keep them local.
The dashboard and API only answer requests whose Host header is an IP address,
localhost, or a name listed in
AI_OBSERVER_ALLOWED_HOSTS, which blocks DNS rebinding attacks. Both servers also
reject requests that a browser sends from another site's origin. Exporters and CLI tools send no
Origin header and are not affected.
Authentication
Set AI_OBSERVER_AUTH_TOKEN to require
Authorization: Bearer <token> on every OTLP and API request except
/health and the dashboard's static files. Requests without a valid token get
401.
# Start AI Observer with a long random token
export AI_OBSERVER_AUTH_TOKEN=$(openssl rand -hex 32)
ai-observer
# OTLP exporters send it as a header
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer $AI_OBSERVER_AUTH_TOKEN"
# Open the dashboard once with ?token=..., which sets a 30-day HttpOnly cookie
# http://localhost:8080/?token=<token> The dashboard cookie holds a value derived from the token, so it cannot be used to send telemetry. To sign out every browser, change the token and restart. Use HTTPS (for example a reverse proxy) when the token travels over a network.
Redaction
Before telemetry is stored, AI Observer replaces secrets in it: API keys and tokens of common services (Anthropic,
OpenAI, GitHub, GitLab, AWS, Google, Slack, Stripe, npm), JWTs, private keys, Authorization
header values, passwords in URLs, and values of assignments such as DB_PASSWORD=…,
for example with [REDACTED:github_token]. This applies to OTLP,
import and watch.
AI_OBSERVER_REDACT=secrets # default: credentials
AI_OBSERVER_REDACT=all # credentials and personal data
AI_OBSERVER_REDACT=off # store telemetry as received all also replaces personal data: emails (as stable pseudonyms), card numbers,
IBANs, phone numbers, US social security numbers and public IP addresses. Telemetry stored earlier is not changed.
CLI Commands
AI Observer provides several CLI commands for ingesting and managing your telemetry data.
ai-observer [command] [options] Available Commands
| Command | Description |
|---|---|
| serve | Start the OTLP and API servers (default if no command); --mcp serves the MCP endpoint |
| import | Import local sessions from AI tool files |
| watch | Watch local session files and import incrementally |
| export | Export telemetry data to Parquet files |
| delete | Delete telemetry data from the database |
| setup | Show setup instructions for an AI tool |
| pricing update | Fetch current model prices from models.dev into AI_OBSERVER_PRICING_DIR |
| -h, --help | Show help message and exit |
| -v, --version | Show version information and exit |
The database can only be opened by one process at a time: stop a running server or
watch before running import,
export or delete. Dates are days in your
local time zone.
Import Command
Import historical session data from local AI coding tool files.
ai-observer import [claude-code|codex|gemini|all] [options] | Option | Description |
|---|---|
| --from DATE | Only import sessions from DATE (YYYY-MM-DD, local time zone) |
| --to DATE | Only import sessions up to DATE (YYYY-MM-DD) |
| --force | Re-import already imported files (their stored records are replaced) |
| --dry-run | Show what would be imported without making changes |
| --yes | Skip confirmation prompt |
| --purge | Replace the imported tools' data in the time range, including live OTLP telemetry: delete it, then re-import all of their files in that range. Other tools' data is kept |
| --pricing-mode MODE | Cost calculation mode for Claude: auto (default), calculate, display |
| --verbose | Show detailed progress |
File Locations
| Tool | Default Location |
|---|---|
| Claude Code | ~/.claude/projects/**/*.jsonl |
| Codex CLI | ~/.codex/sessions/*.jsonl |
| Gemini CLI | ~/.gemini/tmp/**/session-*.json |
Override with environment variables: AI_OBSERVER_CLAUDE_PATH, AI_OBSERVER_CODEX_PATH, AI_OBSERVER_GEMINI_PATH
Examples
# Import from all file-backed tools
ai-observer import all
# Import Claude data from specific date range
ai-observer import claude-code --from 2025-01-01 --to 2025-12-31
# Dry run to see what would be imported
ai-observer import all --dry-run
# Force re-import and recalculate costs (replaces the files' stored records)
ai-observer import claude-code --force --pricing-mode calculate
Re-importing a changed or forced file replaces the records stored from it, so imports never duplicate data; live
OTLP telemetry is kept. import exits with status 1 when tools or files could not
be imported.
Watch Command
Watch local session files and import new data as it is written. This is an alternative to configuring OTLP exporters for Claude Code, Codex CLI and Gemini CLI: start the watcher and it picks up data from the tools' own session files.
ai-observer watch [claude-code|codex|gemini|all] [options] | Option | Description |
|---|---|
| --backfill | On first start, load all existing session data before watching |
| --mcp | Serve the MCP endpoint for agents (also AI_OBSERVER_MCP=true) |
- First start: records the current position in each file; only data written after startup is imported.
- First start with
--backfill: loads all existing session data, then watches for changes. - Restart: resumes where it left off, importing data written while the watcher was stopped.
Directories that don't exist yet are polled every 30 seconds and added when they appear. File locations are the same as for import.
# Watch all file-backed tools for new data
ai-observer watch all
# Watch only Claude Code sessions
ai-observer watch claude-code
# First run: load all historical data, then watch
ai-observer watch all --backfill
Watch mode and OTLP ingestion (serve) are mutually exclusive: watch starts only
the dashboard and API, and running both would store data twice. GitHub Copilot and OpenCode are OTLP-only.
Export Command
Export telemetry data to portable Parquet files with an optional DuckDB views database.
ai-observer export [claude-code|codex|gemini|opencode|copilot-chat|github-copilot|all] --output <directory> [options] | Option | Description |
|---|---|
| --output DIR | Output directory (required) |
| --from DATE | Start date filter (YYYY-MM-DD) |
| --to DATE | End date filter (YYYY-MM-DD) |
| --from-files | Read from raw JSON/JSONL session files instead of the database |
| --zip | Create a single ZIP archive of the exported files |
| --dry-run | Preview what would be exported |
| --verbose | Show detailed progress |
| --yes | Skip confirmation prompt |
Output: traces.parquet, logs.parquet,
metrics.parquet and a DuckDB views database
(ai-observer-export-SOURCE-RANGE.duckdb) with relative paths.
Examples
# Export all data from database
ai-observer export all --output ./export
# Export Claude data with date filter
ai-observer export claude-code --output ./export --from 2025-01-01 --to 2025-01-15
# Export GitHub Copilot VS Code Extension telemetry
ai-observer export copilot-chat --output ./export
# Export OpenCode telemetry
ai-observer export opencode --output ./export
# Export to ZIP archive
ai-observer export all --output ./export --zip
# Export directly from raw files (without prior import)
ai-observer export claude-code --output ./export --from-files --from-files is only available for local file sources
(claude-code, codex,
gemini, all). GitHub Copilot and OpenCode
export from the database.
Delete Command
Delete telemetry data from the database by time range.
ai-observer delete [logs|metrics|traces|all] --from DATE --to DATE [options] | Option | Description |
|---|---|
| --from DATE | Start date (YYYY-MM-DD, required) |
| --to DATE | End date (YYYY-MM-DD, required) |
| --service NAME | Only delete data for a specific service |
| --yes | Skip confirmation prompt |
Examples
# Delete all data in a date range
ai-observer delete all --from 2025-01-01 --to 2025-01-31
# Delete only logs in a date range
ai-observer delete logs --from 2025-01-01 --to 2025-01-31
# Delete only Claude Code data
ai-observer delete all --from 2025-01-01 --to 2025-01-31 --service claude-code
# Skip confirmation prompt
ai-observer delete all --from 2025-01-01 --to 2025-01-31 --yes
Deleting keeps the import state, so a later plain import skips the files;
import <tool> --force restores their records.
Setup Command
Print the setup instructions for an AI tool, the same as in AI Tool Setup:
ai-observer setup [claude-code|gemini|codex|opencode|github-copilot] Pricing Update
ai-observer pricing update fetches current model prices from
models.dev
and writes claude.json, codex.json,
gemini.json and github_copilot.json to
AI_OBSERVER_PRICING_DIR (or --output DIR),
where AI Observer reads them at startup. Changed prices are updated, new models added, and models that models.dev
does not list are kept. Changes of more than 10x are refused unless you pass
--allow-large-changes.
# Fetch current prices; AI Observer reads them at startup
export AI_OBSERVER_PRICING_DIR=~/.config/ai-observer/pricing
ai-observer pricing update
ai-observer
Stored costs keep the prices they were calculated with. Re-import session files with
--force to recalculate them.
AI Tool Setup
Point your AI coding assistant at the OTLP endpoint http://localhost:4318.
ai-observer setup <tool> prints the same instructions in your terminal.
With AI_OBSERVER_AUTH_TOKEN set, the exporter must also send the token (see
Authentication).
For Claude Code, Codex CLI and Gemini CLI you can skip this and use the watch command, which reads their session files directly.
Claude Code
Add the following environment variables to your shell profile (~/.bashrc or ~/.zshrc):
# Enable telemetry (required)
export CLAUDE_CODE_ENABLE_TELEMETRY=1
# Configure exporters
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
# Set OTLP endpoint (HTTP)
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
# Set shorter intervals
export OTEL_METRIC_EXPORT_INTERVAL=10000 # 10 seconds (default: 60000ms)
export OTEL_LOGS_EXPORT_INTERVAL=5000 # 5 seconds (default: 5000ms) Gemini CLI
Requires Gemini CLI v0.34.0 or later; earlier versions had a bug in OTLP publishing. Add to ~/.gemini/settings.json:
{
"telemetry": {
"enabled": true,
"target": "local",
"useCollector": true,
"otlpEndpoint": "http://localhost:4318",
"otlpProtocol": "http",
"logPrompts": true
}
} Also add these environment variables (workaround for Gemini CLI timing issues):
export OTEL_METRIC_EXPORT_TIMEOUT=10000
export OTEL_LOGS_EXPORT_TIMEOUT=5000 OpenAI Codex CLI
Add to ~/.codex/config.toml:
[otel]
log_user_prompt = true # set to false to redact prompts
exporter = { otlp-http = { endpoint = "http://localhost:4318/v1/logs", protocol = "binary" } }
trace_exporter = { otlp-http = { endpoint = "http://localhost:4318/v1/traces", protocol = "binary" } }
Note: Codex CLI exports logs and traces (no metrics). If trace_exporter is
omitted, traces are sent to the same endpoint as logs.
GitHub Copilot
GitHub Copilot exports OTLP telemetry from the VS Code extension and the CLI. AI Observer derives token and cost metrics from its chat spans. In VS Code, add to your settings:
{
"github.copilot.chat.otel.enabled": true,
"github.copilot.chat.otel.exporterType": "otlp-http",
"github.copilot.chat.otel.otlpEndpoint": "http://localhost:4318",
"github.copilot.chat.otel.captureContent": true
} For the CLI and other environment-based exporters, add to your shell profile:
export COPILOT_OTEL_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export COPILOT_OTEL_CAPTURE_CONTENT=true | Service | Source |
|---|---|
| copilot-chat | GitHub Copilot VS Code Extension |
| github-copilot | GitHub Copilot CLI |
Note: GitHub Copilot is OTLP-only; there is no file import or watcher. Content capture can include prompts, code, tool arguments and tool results; enable it only in trusted local environments.
OpenCode
OpenCode sends telemetry through the third-party @devtheops/opencode-plugin-otel plugin. Enable it in ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@devtheops/opencode-plugin-otel"]
}
Then add these environment variables to your shell profile. The plugin defaults to gRPC on port 4317, so set the protocol to http/protobuf to use the AI Observer HTTP endpoint on port 4318:
export OPENCODE_ENABLE_TELEMETRY=1
export OPENCODE_OTLP_ENDPOINT=http://localhost:4318
export OPENCODE_OTLP_PROTOCOL=http/protobuf Note: OpenCode is OTLP-only; there is no file import or watcher. It emits traces, metrics (including native plugin cost metrics), and logs.
Agent Access (MCP)
AI Observer can serve its data to AI agents over the
Model Context Protocol.
Claude Code, Codex CLI, Gemini CLI, GitHub Copilot or OpenCode can then search your earlier conversations, read
transcripts, and look at logs, traces, metrics, token usage and costs. The endpoint is
http://localhost:8080/mcp (Streamable HTTP) and is off by default.
AI_OBSERVER_MCP=true ai-observer
ai-observer serve --mcp
ai-observer watch all --mcp Connecting an Agent
Leave out the Authorization header when no
AI_OBSERVER_AUTH_TOKEN is set.
claude mcp add --transport http ai-observer http://localhost:8080/mcp \
--header "Authorization: Bearer $AI_OBSERVER_AUTH_TOKEN" # header only with a token [mcp_servers.ai-observer]
url = "http://localhost:8080/mcp"
bearer_token_env_var = "AI_OBSERVER_AUTH_TOKEN" # only with a token {
"mcpServers": {
"ai-observer": {
"httpUrl": "http://localhost:8080/mcp",
"headers": { "Authorization": "Bearer <token>" }
}
}
} {
"servers": {
"ai-observer": {
"type": "http",
"url": "http://localhost:8080/mcp",
"headers": { "Authorization": "Bearer <token>" }
}
}
} {
"mcp": {
"ai-observer": {
"type": "remote",
"url": "http://localhost:8080/mcp",
"headers": { "Authorization": "Bearer <token>" }
}
}
} Tools
All tools are read-only and none runs SQL. Time arguments accept RFC 3339 times, dates or ages such as
7d.
| Tool | Returns |
|---|---|
| search_conversations | Sessions with a prompt, reply or tool call containing all words of the query (or "quoted phrases"), newest match first, with a snippet |
| list_sessions | Sessions with activity in a range: tool, model, start, last activity, message count |
| get_transcript | A session's messages in order: role, content, model, tool input and output, tokens, cost |
| usage_summary | Tokens by type and cost in USD, grouped by tool, model, day or repository |
| search_logs | Log records, newest first |
| list_traces | Traces, newest first: root span, duration, span count, status |
| get_trace | A trace's spans as a tree |
| list_metric_names | Stored metric names |
| query_metrics | A metric as time buckets or totals per series |
What the tools return (prompts, code, tool output) is sent to the agent's model provider. The endpoint uses the same Host, Origin and token checks as the API, and results are redacted again before they are returned.
API Reference
AI Observer exposes two HTTP servers for ingestion and querying.
OTLP Ingestion (Port 4318)
Standard OpenTelemetry Protocol endpoints over HTTP/1.1 and h2c (no gRPC). JSON and protobuf are detected
automatically, and Content-Encoding: gzip is supported.
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/traces | Ingest trace spans (protobuf or JSON) |
| POST | /v1/metrics | Ingest metrics (protobuf or JSON) |
| POST | /v1/logs | Ingest logs (protobuf or JSON) |
| GET | /health | Health check |
Telemetry that cannot be stored is answered with 503 and
Retry-After, which exporters retry; payloads over 10 MB get
413.
Query API (Port 8080)
REST API for querying stored telemetry data.
from/toare RFC 3339 and default to the last 24 hours.-
List endpoints return
total,hasMoreandnextCursor; pass it ascursorfor the next page.offsetis deprecated and works up to 10,000 rows. - Queries stopped by the 5-second timeout return
504; request bodies are limited to 1 MB.
Traces
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/traces | List traces (service, search, from, to, limit, cursor) |
| GET | /api/traces/recent | Most recent traces (limit up to 100) |
| GET | /api/traces/{traceId}?kind={kind} | Spans of a trace row; kind is otel_trace or codex_operation, as returned in the list |
| GET | /api/traces/{traceId}/spans?kind={kind} | All spans of a trace row |
Metrics
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/metrics | List metric points (service, name, type, from, to, limit, cursor) |
| GET | /api/metrics/names | List metric names |
| GET | /api/metrics/breakdown-values | Values of an attribute for a metric (name, attribute, service) |
| GET | /api/metrics/series | Time series for a metric (name, service, from, to, interval, aggregate) |
| POST | /api/metrics/batch-series | Up to 50 time series in one request |
Logs
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/logs | List logs (service, severity, traceId, search, from, to, limit, cursor) |
| GET | /api/logs/levels | Log counts by severity level (optional from, to) |
Sessions
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/sessions | Sessions active in the range, each shown whole (service, from, to, limit, cursor) |
| GET | /api/sessions/{sessionId}/transcript | Transcript of a session; unknown sessions return 404 |
Dashboards
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/dashboards | List all dashboards |
| POST | /api/dashboards | Create a new dashboard |
| GET | /api/dashboards/default | Get the default dashboard with widgets |
| GET | /api/dashboards/{id} | Get a dashboard by ID |
| PUT | /api/dashboards/{id} | Update a dashboard |
| DELETE | /api/dashboards/{id} | Delete a dashboard |
| PUT | /api/dashboards/{id}/default | Set as default dashboard |
| POST | /api/dashboards/{id}/widgets | Add a widget |
| PUT | /api/dashboards/{id}/widgets/positions | Update widget positions |
| PUT | /api/dashboards/{id}/widgets/{widgetId} | Update a widget |
| DELETE | /api/dashboards/{id}/widgets/{widgetId} | Delete a widget |
Other Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/services | List all services sending telemetry |
| GET | /api/providers | List the supported AI coding tools with their service and display names |
| GET | /api/stats | Aggregate statistics (optional from, to) |
| GET | /ws | WebSocket that announces newly stored records |
| POST | /mcp | MCP endpoint for agents, when enabled |
| GET | /health | Health check |
Troubleshooting
Port Already in Use
AI Observer stops at startup when one of its ports is taken. Change the ports using environment variables:
AI_OBSERVER_API_PORT=9090 AI_OBSERVER_OTLP_PORT=4319 ./ai-observer No Data Appearing in Dashboard
- Verify your AI tool is configured correctly
- Check that the OTLP endpoint is reachable:
curl http://localhost:4318/health - Make sure AI Observer runs as a server, not in
watchmode, which does not accept OTLP - Look for errors in the AI Observer logs
CORS Errors in Browser Console
Set the AI_OBSERVER_FRONTEND_URL environment variable to match your frontend origin:
AI_OBSERVER_FRONTEND_URL=http://localhost:3000 ./ai-observer Other Machines or Containers Cannot Reach AI Observer
The binary listens on 127.0.0.1 by default. Set
AI_OBSERVER_HOST=0.0.0.0 to listen on all interfaces (see
Network Access).
"Database ... Is in Use by Another Process"
DuckDB allows one process per database file. Stop the running server or watch
before running import, export or
delete, or point the command at another database with
AI_OBSERVER_DATABASE_PATH.
Dashboard Shows "Authentication Required"
AI_OBSERVER_AUTH_TOKEN is set. Open the dashboard once with
?token=<token> (see Authentication).
Dashboard Returns "Host Not Allowed"
You are using a host name that is not on the allow list. Add it, for example
AI_OBSERVER_ALLOWED_HOSTS=observer.lan, or use
localhost or the IP address instead. The same applies to "origin not allowed"
errors, for example behind a reverse proxy.
Need More Help?
Check out the GitHub repository for additional documentation, examples, and community support.