跳到主内容

OpenClaw

OpenClaw is an open-source, self-hosted AI assistant: a gateway that connects chat apps to AI agents. Its diagnostics-otel plugin exports the agent's traces, metrics, and logs over OpenTelemetry (OTLP/HTTP). Casdoor can receive that data, store each payload as an Entry, and show OpenClaw sessions as a graph, so you can see what your agents did next to who they act for.

工作原理​

OpenClaw sends OTLP payloads to Casdoor's ingest endpoints:

信号端点
轨迹POST /api/v1/traces
指标POST /api/v1/metrics
日志POST /api/v1/logs

三个接口都要求 Content-Type: application/x-protobuf。 Casdoor 把每个载荷保存为一条 Entry,并标记发送方的 IP 和 User-Agent。

在 Casdoor 中设置​

1. 创建日志提供商​

  1. 进入 Providers → Add。
  2. 把 Category 设为 Log,Type 设为 Agent (OpenClaw)。
  3. In the Host field, enter the IP address of the machine running OpenClaw. Leave it empty to accept data from any IP.
  4. (Optional) Agent ID and Path tell Casdoor where to find the agent's session transcripts; see Raw session transcripts.
  5. (Optional) In the Storage provider field, pick which Storage provider should hold the raw session transcripts. Leave it empty to let Casdoor choose automatically.
  6. Save. Casdoor is now ready to receive data.

Host 字段是这个提供商的 IP 白名单。来自其他地址的请求会被拒绝并返回 403 Forbidden,防止未授权的代理向你的组织写入条目。

2. 配置 OpenClaw​

Install and enable OpenClaw's diagnostics-otel plugin, then point its OTLP exporter at Casdoor. OpenClaw appends /v1/traces, /v1/metrics, and /v1/logs to the endpoint, so the endpoint is Casdoor's URL followed by /api:

openclaw plugins install clawhub:@openclaw/diagnostics-otel
{
plugins: {
allow: ["diagnostics-otel"],
entries: {
"diagnostics-otel": { enabled: true },
},
},
diagnostics: {
enabled: true,
otel: {
enabled: true,
endpoint: "https://your-casdoor.com/api",
protocol: "http/protobuf",
traces: true,
metrics: true,
logs: true,
},
},
}

See OpenTelemetry export in the OpenClaw documentation for sampling, flush intervals, and what content is captured.

Viewing collected data​

Once data is flowing, navigate to Entries in the Casdoor sidebar. Each incoming OTLP payload produces one Entry.

  • Trace entries render as a span tree in the built-in EntryMessageViewer, showing timing, attributes, and status for each span.
  • Metrics and log entries store the raw OTLP JSON in the Message field, which you can inspect directly or export for use in other tools.

Entries are scoped to an organization, so data from different teams or environments can be separated by placing them under different organizations with their own Log providers.

Raw session transcripts​

Beyond the parsed trace view, Casdoor can keep the raw JSONL transcript of each OpenClaw session—the exact line-delimited log the agent produced. This is useful when you need the unmodified record for debugging, auditing, or replay.

Where transcripts are read from​

Casdoor reads the transcripts from OpenClaw's state directory on the machine where Casdoor runs, so this feature needs OpenClaw on the same host (or its state directory mounted there). By default the directory is ~/.openclaw/agents/<Agent ID>/sessions, where Agent ID defaults to main; OPENCLAW_STATE_DIR and OPENCLAW_PROFILE are honored as in OpenClaw. Set Path on the provider to use another directory.

记录存放在哪里​

OpenClaw 提供商同步会话时,Casdoor 会把该会话的 .jsonl 文件上传到某个 存储提供商,并记录为一个资源。目标存储按以下顺序选择:

  1. 如果在日志提供商上设置了 Storage provider 字段,就用这个提供商(必须是同一组织中已启用的 Storage 提供商)。
  2. 否则,Casdoor 使用组织中第一个已启用的存储提供商。
  3. 如果一个都没有,Casdoor 会自动创建一个名为 openclaw-transcript-storage 的默认本地存储提供商。

重新同步会话会覆盖已存储的记录,而不是创建重复文件。

查看记录​

在图形查看器中打开一个 OpenClaw 会话。有原始记录时,查看器工具栏会出现 Raw JSONL 按钮,点击即可打开该会话的记录页面。

查看器只以流的方式加载文件的预览,而不是整个文件,最多 2 MB。记录更大时,响应会标记为截断,提示存储的文件中还有更多内容。预览在后台由以下接口提供:

GET /api/get-openclaw-session-transcript?id=<owner>/<session-name>

它返回文件名、总大小、已加载的字节数、truncated 标记,以及记录的 content。

关联 Casdoor 智能体​

如果你在 Casdoor 的 Agents 中注册了 AI 智能体,就可以把遥测条目和产生它们的智能体关联起来。 Agent 记录保存了智能体的接口地址和 bearer 令牌,让身份和可观测性数据可以在同一个地方关联。

下一步​

  • Entries:了解条目类型和追踪查看器
  • 日志提供商:Agent (OpenClaw) 提供商的完整参考
  • Agents:在 Casdoor 中注册 AI 智能体的接口