Configure OpenClaw's built-in OpenTelemetry diagnostics via ~/.openclaw/openclaw.json.
{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4318",
"protocol": "http/protobuf",
"headers": {
"Authorization": "Api-Token dt0c01.xxx"
},
"serviceName": "openclaw-gateway",
"traces": true,
"metrics": true,
"logs": true,
"sampleRate": 1.0,
"flushIntervalMs": 5000
}
}
}Top-level diagnostics configuration.
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | false |
Enable the diagnostics system |
OpenTelemetry export configuration.
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | false |
Enable OTel export |
endpoint |
string | — | OTLP endpoint URL (required) |
protocol |
string | "http/protobuf" |
Protocol: "http/protobuf" or "grpc" |
headers |
object | {} |
Custom HTTP headers (e.g., auth tokens) |
serviceName |
string | "openclaw" |
OTel service name attribute |
traces |
boolean | true |
Enable trace export |
metrics |
boolean | true |
Enable metrics export |
logs |
boolean | false |
Enable log forwarding |
sampleRate |
number | 1.0 |
Trace sampling rate (0.0–1.0) |
flushIntervalMs |
number | — | Export flush interval in milliseconds |
For OTLP/HTTP endpoints (port 4318):
{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4318",
"protocol": "http/protobuf"
}
}
}The endpoint auto-appends /v1/traces, /v1/metrics, /v1/logs as needed.
For OTLP/gRPC endpoints (port 4317):
{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4317",
"protocol": "grpc"
}
}
}Note: gRPC support is experimental.
{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "https://api.example.com/otlp",
"headers": {
"Authorization": "Bearer your-token-here"
}
}
}
}{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "https://{env-id}.live.dynatrace.com/api/v2/otlp",
"headers": {
"Authorization": "Api-Token dt0c01.xxx..."
}
}
}
}{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "https://otlp-gateway-prod-us-central-0.grafana.net/otlp",
"headers": {
"Authorization": "Basic base64(instanceId:apiKey)"
}
}
}
}Control trace sampling rate to reduce volume:
{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4318",
"sampleRate": 0.1
}
}
}1.0— Sample all traces (default)0.5— Sample 50% of traces0.1— Sample 10% of traces0.0— Disable trace sampling
Enable only specific signals:
{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4318",
"traces": true,
"metrics": false,
"logs": false
}
}
}{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4318",
"traces": false,
"metrics": true,
"logs": false
}
}
}{
"diagnostics": {
"enabled": true,
"otel": {
"enabled": true,
"endpoint": "http://localhost:4318",
"traces": false,
"metrics": false,
"logs": true
}
}
}OpenClaw also respects standard OTel environment variables as fallbacks:
| Variable | Description |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT |
Default OTLP endpoint |
OTEL_EXPORTER_OTLP_PROTOCOL |
Default protocol |
OTEL_SERVICE_NAME |
Default service name |
Config file values take precedence over environment variables.
After modifying configuration:
openclaw gateway restartOr trigger a hot reload (if supported):
kill -SIGUSR1 $(pgrep -f openclaw-gateway)Check the current config:
cat ~/.openclaw/openclaw.json | jq '.diagnostics'Validate JSON syntax:
cat ~/.openclaw/openclaw.json | jq .Test connectivity:
curl -v http://localhost:4318/v1/traces