Integrate OpenClaw Applications

更新时间:
复制 MD 格式

OpenClaw works with the opentelemetry-instrumentation-openclaw and diagnostics-otel plugins to report the complete trace and runtime metrics of an AI agent to Cloud Monitor 2.0 application monitoring. The opentelemetry-instrumentation-openclaw plugin handles trace reporting, following OpenTelemetry GenAI semantic conventions to generate a structured trace for each request. The diagnostics-otel plugin collects runtime metrics, such as token consumption rate, call QPS, and queue depth in real time. Once enabled, you can view monitoring data for your OpenClaw application in Cloud Monitor 2.0, including the complete trace, model call latency, token consumption details, and tool call details.

Limits

Limit

Description

OpenClaw version

v26.2.19 or later. Earlier versions do not include the diagnostics-otel plugin. Upgrade first.

Reporting protocol

Only HTTP/Protobuf is supported. HTTP/JSON and gRPC are not supported.

Data type

Only trace and metric data are supported. Log data is not supported.

Cloud Monitor service

You have activated Cloud Monitor 2.0 and created a workspace.

Step 1: Get the installation command

Before installing the plugin, get an installation command from the Cloud Monitor 2.0 console.

  1. Log on to the Cloud Monitor 2.0 console and select your target workspace.

  2. In the navigation pane on the left, click Integration Center.

  3. In the AI Application Observability section, click the OpenClaw card.

  4. In the parameter configuration area, enter an application name, select a connection method as needed, and then click Get next to LicenseKey.

    The console generates an installation command based on your configuration. You can click the copy icon in the upper-right corner to copy the command. The command contains endpoint information, such as the Endpoint and LicenseKey. If you plan to perform a manual installation, record the following information:

    Parameter

    Description

    Example

    Endpoint

    OTLP trace and metric reporting endpoint

    • https://proj-xtrace-xxx.cn-hangzhou-intranet.log.aliyuncs.com/apm/trace/opentelemetry/v1/traces

    • https://proj-xtrace-xxx.cn-hangzhou-intranet.log.aliyuncs.com/apm/trace/opentelemetry/v1/metrics

    x-arms-license-key

    LicenseKey for data write authentication

    d95vgxi0cn@xxxxx

    x-arms-project

    Simple Log Service project name

    proj-xtrace-xxx-cn-hangzhou

    x-cms-workspace

    Cloud Monitor 2.0 workspace ID

    default-cms-xxx-cn-hangzhou

    serviceName

    The application name.

    openclaw-xxx

Step 2: Install and integrate

Method 1: One-click installation (Recommended)

On the machine running OpenClaw, open a terminal, paste the installation command from the previous step, and run it:

curl -fsSL https://arms-apm-cn-hangzhou-pre.oss-cn-hangzhou.aliyuncs.com/opentelemetry-instrumentation-openclaw/install.sh | bash -s -- \
  --endpoint "https://<YOUR_ENDPOINT>" \
  --x-arms-license-key "<YOUR_LICENSE_KEY>" \
  --x-arms-project "<YOUR_PROJECT>" \
  --x-cms-workspace "<YOUR_WORKSPACE>" \
  --serviceName "<YOUR_SERVICE_NAME>"

The installation script automatically performs the following actions:

  1. Checks the environment for Node.js, npm, and the OpenClaw CLI.

  2. Downloads and extracts the opentelemetry-instrumentation-openclaw plugin to the OpenClaw extensions directory.

  3. Installs the runtime dependencies for the plugin.

  4. Automatically locates the diagnostics-otel extension and installs its dependencies if they are not already installed.

  5. Updates the openclaw.json file with configurations for both plugins. For OpenClaw v2026.4.25 and later, it also automatically adds hooks.allowConversationAccess: true.

  6. Restarts the gateway to apply the new configuration.

The expected output is similar to the following:

[INFO]  Checking prerequisites...
[OK]    Node.js v24.14.0
[OK]    npm 11.9.0
[OK]    OpenClaw CLI found
[INFO]  Downloading plugin...
[OK]    Downloaded
[INFO]  Extracting...
[OK]    Extracted
[INFO]  Installing npm dependencies...
[OK]    Dependencies installed
[INFO]  Locating diagnostics-otel extension...
[OK]    Found diagnostics-otel at: /home/.../extensions/diagnostics-otel
[OK]    diagnostics-otel dependencies already present
[INFO]  Updating config...
[OK]    Config updated
[INFO]  Restarting OpenClaw gateway...
[OK]    Gateway restarted
════════════════════════════════════════════════════
  ✅ opentelemetry-instrumentation-openclaw installed successfully!
════════════════════════════════════════════════════

Installation parameters

Parameter

Required

Description

--endpoint

Yes

The OTLP data reporting endpoint, obtained from the Cloud Monitor 2.0 Integration Center.

--x-arms-license-key

Yes

The LicenseKey for data write authentication.

--x-arms-project

Yes

The Simple Log Service project name.

--x-cms-workspace

Yes

The Cloud Monitor 2.0 workspace identifier.

--serviceName

Yes

The reported service name, which appears as the application name in the Cloud Monitor 2.0 application list.

--plugin-url

No

A custom tarball download URL.

--install-dir

No

A custom installation directory.

--disable-metrics

No

Disables metric reporting by skipping the diagnostics-otel configuration. This enables trace reporting only.

Method 2: Manual installation

To perform a manual installation, follow these steps.

1. Download and extract plugin

curl -fsSL -o opentelemetry-instrumentation-openclaw.tar.gz https://arms-apm-cn-hangzhou-pre.oss-cn-hangzhou.aliyuncs.com/opentelemetry-instrumentation-openclaw/opentelemetry-instrumentation-openclaw.tar.gz
tar -xzf opentelemetry-instrumentation-openclaw.tar.gz
cd opentelemetry-instrumentation-openclaw
npm install --omit=dev

2. Enable diagnostics-otel plugin

openclaw plugins enable diagnostics-otel

3. Edit configuration file

Edit the ~/.openclaw/openclaw.json file and add the following configuration. Replace the placeholders with the endpoint information from Step 1.

{
  "plugins": {
    "allow": ["opentelemetry-instrumentation-openclaw", "diagnostics-otel"],
    "load": {
      "paths": ["<PATH_TO_OPENTELEMETRY_INSTRUMENTATION_OPENCLAW>"]
    },
    "entries": {
      "opentelemetry-instrumentation-openclaw": {
        "enabled": true,
        "hooks": {
          "allowConversationAccess": true
        },
        "config": {
          "endpoint": "<ENDPOINT>",
          "headers": {
            "x-arms-license-key": "<YOUR_LICENSE_KEY>",
            "x-arms-project": "<YOUR_ARMS_PROJECT>",
            "x-cms-workspace": "<YOUR_WORKSPACE_ID>"
          },
          "serviceName": "<YOUR_SERVICE_NAME>"
        }
      },
      "diagnostics-otel": {
        "enabled": true
      }
    }
  },
  "diagnostics": {
    "enabled": true,
    "otel": {
      "enabled": true,
      "endpoint": "<ENDPOINT>",
      "protocol": "http/protobuf",
      "headers": {
        "x-arms-license-key": "<YOUR_LICENSE_KEY>",
        "x-arms-project": "<YOUR_ARMS_PROJECT>",
        "x-cms-workspace": "<YOUR_WORKSPACE_ID>"
      },
      "serviceName": "<YOUR_SERVICE_NAME>",
      "traces": false,
      "metrics": true,
      "logs": false
    }
  }
}
Version compatibility: The hooks.allowConversationAccess setting is supported only in OpenClaw v2026.4.25 and later. For earlier versions, remove the hooks section to avoid an "Unrecognized key" error when the gateway starts.

4. Restart the gateway

openclaw gateway restart

Method 3: Container integration

First, select an OpenClaw base image. If you have already built a custom image from the official base image, you can use your custom image. Then, install the OpenClaw observability plugins on top of the base image and rebuild your own OpenClaw image, as shown below:

FROM ghcr.io/openclaw/openclaw:latest
RUN curl -fsSL https://arms-apm-cn-hangzhou-pre.oss-cn-hangzhou.aliyuncs.com/opentelemetry-instrumentation-openclaw/install.sh | bash -s -- \
  --endpoint "https://<YOUR_ENDPOINT>" \
  --x-arms-license-key "<YOUR_LICENSE_KEY>" \
  --x-arms-project "<YOUR_PROJECT>" \
  --x-cms-workspace "<YOUR_WORKSPACE>" \
  --serviceName "<YOUR_SERVICE_NAME>"

This is the same installation script used for the one-click installation.

Then, build a custom OpenClaw image from this Dockerfile and use it in your container environment.

If you need to dynamically configure the reporting endpoint, application name, and other settings for your OpenClaw instance, build your OpenClaw image as follows:

FROM ghcr.io/openclaw/openclaw:latest
RUN curl -fsSL https://arms-apm-cn-hangzhou-pre.oss-cn-hangzhou.aliyuncs.com/opentelemetry-instrumentation-openclaw/install-ack.sh | bash -s

Then, when you run the image, set the following environment variables to specify the reporting endpoint, application name, and other information:

Environment variable

Description

ARMS_OTLP_ENDPOINT

Your endpoint URL

ARMS_LICENSE_KEY

Your LicenseKey

ARMS_PROJECT

Your project

ARMS_CMS_WORKSPACE

Your workspace

ARMS_SERVICE_NAME

Your service name

Configuration parameters

opentelemetry-instrumentation-openclaw

Parameter

Type

Required

Description

endpoint

String

Yes

The OTLP data reporting endpoint, which you can obtain from the Cloud Monitor 2.0 Integration Center.

headers.x-arms-license-key

String

Yes

The LicenseKey for identity authentication.

headers.x-arms-project

String

Yes

The Simple Log Service project for storing trace data.

headers.x-cms-workspace

String

Yes

The target Cloud Monitor 2.0 workspace for data reporting.

serviceName

String

Yes

The reported service name, which appears as the application name in the Cloud Monitor 2.0 application list.

debug

Boolean

No

Enables the debug log. The default value is false.

batchSize

Number

No

The maximum number of spans to hold in the buffer before sending them in a batch. The default value is 10.

flushIntervalMs

Number

No

Maximum buffer wait time (milliseconds). The default is 5000.

enableTracePropagation

Boolean

No

Enables W3C Trace Context propagation to correlate upstream and downstream requests. The default value is false.

propagationTargetUrls

String[]

No

Injects the traceparent header into matching downstream URLs (URL substring matching).

resourceAttributes

Object

No

Specifies custom Resource attributes to inject into the OTel Resource, such as {"deployment.environment": "production"}.

globalSpanAttributes

Object

No

Global Span attributes, which are injected into all spans (such as {"biz.team": "payment"}).

Note: hooks.allowConversationAccess: true must be configured in the hooks field of the plugin entries (at the same level as config). Otherwise, conversation-related hooks will be blocked by the OpenClaw security policy. Only OpenClaw versions >= 2026.4.25 support this field. Do not configure it for earlier versions.

Environment variable fallback

If a configuration field is not set, the plugin reads the value from the corresponding environment variable instead. This method is ideal for container and Kubernetes environments.

Environment variable

Corresponding configuration

Description

ARMS_OTLP_ENDPOINT

endpoint

OTLP reporting endpoint

ARMS_LICENSE_KEY

headers.x-arms-license-key

ARMS LicenseKey

ARMS_PROJECT

headers.x-arms-project

ARMS project name

ARMS_CMS_WORKSPACE

headers.x-cms-workspace

Workspace identifier

ARMS_SERVICE_NAME / OTEL_SERVICE_NAME

serviceName

Service name

ARMS_TRACE_DEBUG

debug

Debug log (true / 1)

OTEL_RESOURCE_ATTRIBUTES

resourceAttributes

Custom Resource properties (key1=value1,key2=value2)

OTEL_SPAN_ATTRIBUTES

globalSpanAttributes

Global Span Attributes (key1=value1,key2=value2)

Priority: Configuration file > Environment variables > Default values.

Important: The OpenClaw gateway runs in daemon mode by default and does not inherit environment variables from the invoking shell. For local development, use the configuration file method. Environment variables are suitable for container environments such as Docker and Kubernetes.

diagnostics-otel

Parameter

Type

Required

Description

enabled

Boolean

Yes

Specifies whether to enable the diagnostics feature. Set to true to enable it.

otel.enabled

Boolean

Yes

Specifies whether to enable OpenTelemetry data export. Set to true to enable.

otel.endpoint

String

Yes

OTLP data reporting endpoint. The plugin automatically appends the /v1/traces or /v1/metrics path.

otel.protocol

String

Yes

Reporting protocol. Currently, only http/protobuf is supported.

otel.headers

Object

Yes

The authentication headers included in reporting requests.

otel.serviceName

String

Yes

The reported service name should be consistent with the serviceName configured in opentelemetry-instrumentation-openclaw.

otel.traces

Boolean

Yes

Specifies whether to report trace data. We recommend that you set this to false because tracing is handled by opentelemetry-instrumentation-openclaw.

otel.metrics

Boolean

Yes

Specifies whether to report metric data. Set this parameter to true to view metrics such as token usage, number of calls, and latency.

otel.logs

Boolean

Yes

Specifies whether to report log data. This feature is not currently supported by Cloud Monitor 2.0. We recommend that you set this parameter to false.

otel.sampleRate

Number

No

The trace sampling rate ranges from 0.0 to 1.0 and applies only to the root span. A value of 1 indicates full sampling.

otel.flushIntervalMs

Number

No

The batch data refresh interval, in milliseconds. The minimum value is 1000, and the default value is 60000.

Step 3: Verify installation

Run the following command to check if the plugins are active:

openclaw plugins list

The expected output looks like this:

┌───────────────────┬─────────────────┬──────────┬──────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┐
│ Name              │ ID              │ Format   │ Status   │ Source                                                                                                                                                                     │ Version    │
├───────────────────┼─────────────────┼──────────┼──────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ OpenClaw OTel     │ opentelemetry-  │ openclaw │ enabled  │ ~/.openclaw/extensions/opentelemetry-instrumentation-openclaw/dist/index.js                                                                                                │ 0.1.3-beta │
│ Plugin            │ instrumentation │          │          │ Report OpenClaw AI agent execution traces to any OTLP-compatible backend via OpenTelemetry                                                                                 │            │
│ @openclaw/        │ diagnostics-    │ openclaw │ enabled  │ ~/.openclaw/npm/node_modules/@openclaw/diagnostics-otel/dist/index.js                                                                                                      │ 2026.5.6   │
│ diagnostics-otel  │ otel            │          │          │                                                                                                                                                                            │            │
└───────────────────┴─────────────────┴──────────┴──────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────┘

Step 4: View monitoring data

After the installation is complete, send a few messages to OpenClaw to trigger agent execution. You can then view the monitoring data reported by OpenClaw in the Cloud Monitor 2.0 console.

  1. Log on to the Cloud Monitor 2.0 console and select your target workspace.

  2. In the left-side navigation pane, choose Application Observability > AI Application Observability.

  3. In the application list, find the service name you configured (for example, openclaw-gateway).

  4. Click the application name or select Trace Analysis to view the trace, token consumption, LLM inputs and outputs, and latency distribution.

Uninstall

To uninstall the plugin, run the following command:

curl -fsSL https://arms-apm-cn-hangzhou-pre.oss-cn-hangzhou.aliyuncs.com/opentelemetry-instrumentation-openclaw/uninstall.sh | bash

The uninstall script automatically cleans up the opentelemetry-instrumentation-openclaw installation directory and all related configurations in openclaw.json. The configuration for diagnostics-otel is also disabled.

Parameter

Description

-y / --yes

Skips the confirmation prompt.

--install-dir

Specifies the plugin installation directory. If not provided, the directory is automatically detected.

--keep-metrics

Uninstall only opentelemetry-instrumentation-openclaw (Trace), and retain the configuration for diagnostics-otel (Metrics).

FAQ

No data appears in the console after configuration?

Check the following items in order:

  1. Confirm that your OpenClaw version is v26.2.19 or later. Run openclaw --version to verify.

  2. Confirm that the gateway has restarted (it restarts automatically after a one-click installation, but requires you to run openclaw gateway restart for a manual installation). If the restart fails, you can run openclaw doctor and then restart the gateway after the issues are fixed.

  3. Confirm that the Endpoint URL is correct and reachable over the network. Test connectivity with curl.

  4. Confirm that all three header values (x-arms-license-key, x-arms-project, and x-cms-workspace) are correctly entered.

  5. If the OpenClaw version is 2026.4.25 or later, set hooks.allowConversationAccess to true in the plugin configuration to prevent the security policy from blocking conversation-related hooks. If the version is earlier than 2026.4.25, ensure that the configuration does not contain the hooks field to avoid an "Unrecognized key" error.

  6. Note that the default flushIntervalMs is 60 seconds. For short-lived tasks, wait a few minutes before data appears.

Does integration affect performance?

The impact is minimal. opentelemetry-instrumentation-openclaw uses the batch export mechanism of OpenTelemetry. Span data is buffered in memory and reported in batches at regular intervals, which does not block the normal processing flow of the agent.

Can I install trace reporting only?

Yes. You can add the --disable-metrics parameter during installation to skip the configuration of diagnostics-otel and enable only Trace reporting.

Will traces from different plugins conflict?

No. The installation script sets diagnostics.otel.traces to false by default. The opentelemetry-instrumentation-openclaw component is specifically responsible for reporting traces. No conflicts will occur even if both report simultaneously.

Will the installation overwrite existing configurations?

No. The installation script uses a merge-update strategy—it only updates necessary fields such as endpoint and headers, and leaves your existing configurations for traces, logs, and sampleRate unchanged.

Why is the token consumption always 0?

OpenClaw v2026.3.8 contains a bug that causes incorrect token consumption collection. This bug was fixed in v2026.4.5 and later versions.

Can I use gRPC to report data?

The diagnostics-otel plugin in OpenClaw supports only http/protobuf. If you set grpc, the setting is silently ignored. No error occurs, but the setting has no effect.