Parseable
AI InfrastructureCoding assistants

Claude Code

Send Claude Code events, metrics and traces directly to Parseable through OpenTelemetry


Claude Code exports usage events, metrics and beta traces through OpenTelemetry. Send each signal directly to a separate Parseable dataset to inspect sessions, model requests, token use, tool activity, cost, latency and errors.

Claude Code
  |-- logs ----> Parseable: claudecode-logs
  |-- metrics --> Parseable: claudecode-metrics
  +-- traces ---> Parseable: claudecode-traces (optional beta)

Anthropic treats metrics and events as stable telemetry signals. Enhanced telemetry remains in beta and enables distributed traces. See Monitoring Claude Code usage for the current schema and version requirements.

Prerequisites

  • Claude Code installed and authenticated
  • A Parseable instance reachable from the developer machine
  • A Parseable API key with ingest access

Enable Claude Code telemetry

Set separate OTLP endpoints and headers for logs and metrics before starting Claude Code:

export PARSEABLE_URL="https://<your-parseable-host>:8000"
export PARSEABLE_API_KEY="<parseable-api-key>"

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=otlp

export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/json
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="${PARSEABLE_URL}/v1/logs"
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="X-P-API-Key=${PARSEABLE_API_KEY},X-P-Stream=claudecode-logs,X-P-Log-Source=otel-logs"

export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/json
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="${PARSEABLE_URL}/v1/metrics"
export OTEL_EXPORTER_OTLP_METRICS_HEADERS="X-P-API-Key=${PARSEABLE_API_KEY},X-P-Stream=claudecode-metrics,X-P-Log-Source=otel-metrics"

claude

For a self-hosted deployment that uses basic authentication, replace X-P-API-Key=${PARSEABLE_API_KEY} in each header value with Authorization=Basic <base64-encoded-username-and-password>.

Enable beta traces

Add the trace exporter configuration before starting Claude Code:

export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/json
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${PARSEABLE_URL}/v1/traces"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="X-P-API-Key=${PARSEABLE_API_KEY},X-P-Stream=claudecode-traces,X-P-Log-Source=otel-traces"

Claude Code requires both CLAUDE_CODE_ENABLE_TELEMETRY=1 and CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 for traces. Anthropic may change the beta schema between releases.

Configure a team

Administrators can place the same values in Claude Code managed settings. Replace the URL and API key placeholders before deployment:

{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL": "http/json",
    "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT": "https://<your-parseable-host>:8000/v1/logs",
    "OTEL_EXPORTER_OTLP_LOGS_HEADERS": "X-P-API-Key=<parseable-api-key>,X-P-Stream=claudecode-logs,X-P-Log-Source=otel-logs",
    "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL": "http/json",
    "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT": "https://<your-parseable-host>:8000/v1/metrics",
    "OTEL_EXPORTER_OTLP_METRICS_HEADERS": "X-P-API-Key=<parseable-api-key>,X-P-Stream=claudecode-metrics,X-P-Log-Source=otel-metrics"
  }
}

Add the beta trace variables from the previous section if your team collects traces. Managed settings let administrators lock the organization's OTLP destination. Check Anthropic's managed settings documentation before rollout.

Verify ingestion

Start Claude Code and submit one prompt. Then check:

  1. claudecode-logs contains a claude_code.user_prompt event.
  2. claudecode-metrics contains claude_code.session.count.
  3. If you enabled beta traces, claudecode-traces contains a claude_code.interaction root span.

Run Claude Code with debug logging if no telemetry arrives:

claude --debug

Import the dashboard

Download the Claude Code Usage dashboard and import its JSON file in Parseable. Map:

  • Logs Dataset to claudecode-logs
  • Metrics Dataset to claudecode-metrics

Use the dashboard to track cost, API requests, sessions, tokens, tools, errors and code activity.

Claude Code cost and token usage dashboard

Protect sensitive content

Claude Code redacts prompts, responses, tool details and tool content by default. Keep these defaults unless your data policy permits content capture.

SettingCaptured data
OTEL_LOG_USER_PROMPTS=1User prompt text
OTEL_LOG_ASSISTANT_RESPONSES=1Assistant response text
OTEL_LOG_TOOL_DETAILS=1Tool parameters, commands, file paths and MCP names
OTEL_LOG_TOOL_CONTENT=1Tool input and output content in trace events

Troubleshooting

  • No datasets appear: confirm Claude Code can reach Parseable and that each signal has the correct endpoint, X-P-Stream and X-P-Log-Source value.
  • Metrics arrive but logs do not: confirm OTEL_LOGS_EXPORTER=otlp and submit a prompt after restarting Claude Code.
  • Traces do not arrive: set both beta variables and confirm your Claude Code version supports enhanced telemetry.
  • Parseable rejects exports: verify the API key and use the Parseable ingestor URL, including its port.
  • The dashboard is empty: map its dataset variables to claudecode-logs and claudecode-metrics.

Was this page helpful?

On this page