The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
beaconjsonexporter
Production Collector exporter for Beacon Endpoint Agent.
This exporter is built into the custom beacon-otelcol distribution. It is
responsible for converting OTLP logs, traces, metrics, and resource attributes
into Wazuh-compatible Beacon endpoint JSONL events.
Required behavior:
- Bind only through Collector receivers configured on localhost.
- Write one complete JSON object per line.
- Use the canonical
vendor=beacon,product=endpoint-agent,schema_version=1.0event contract. - Identify Claude Code and Claude Cowork OTLP resources and map prompts, tool/MCP calls, file access, approval decisions, API usage, token counts, costs, and errors into Beacon endpoint events.
- For Claude Code and Claude Cowork logs, decode JSON-string
tool_inputandtool_parametersattributes into canonicalcommand.*andfile.*fields. Only actual tool results may become tool, command, or file actions; API, assistant, plugin, hook, skill, and other lifecycle logs use session actions, while MCP connection lifecycle usesmcp.connection. - Preserve explicitly supplied Beacon action/category attributes and retain the
original OTLP attributes under
raw.attributes. - Include configured content fields by default, with
metadataandredactedmodes available for stricter deployments. - Redact common secrets and cap event size before writing.
- Emit health failure events when write failures occur.
Token and cost usage:
- Metrics named
gen_ai.client.token.usageor ending in.token.usageor.cost.usage(for exampleclaude_code.token.usageandclaude_code.cost.usage) expand to one event per datapoint so the value, token type, model, and session attributes survive into JSONL. - Token datapoints normalize into the canonical
gen_ai.usagestruct using thetype/gen_ai.token.typeattribute (input,output,cacheRead,cacheCreation,reasoning); cost datapoints map togen_ai.usage.cost_usd. Unknown token types keep the raw value inraw.metric_valueonly. - Gemini CLI's counts overlap differently: its input includes the cache and its
output excludes thinking tokens. The
gemini_cli.api_responselog record and thegemini_cli.token.usageseries (input,output,thought,cache,tool) both map to input = prompt - cached + tool-use prompt, cache read = cached, output = candidates + thoughts, and reasoning = thoughts. Thegen_ai.client.inference.operation.detailsrecord that restates the same response carries no usage, so a response is counted once. - Datapoint events use the datapoint timestamp and record
raw.metric_temporality,raw.metric_monotonic,raw.metric_value, and (for histograms)raw.metric_countso downstream aggregation can dedupe cumulative series. - All other metrics, and usage metrics without datapoints, keep the single
metric.observedevent. - Codex's current live token source is the completed
session_task.turntrace, not its anonymous histogram. The exporter keeps that one span by default, promotesthread.id/turn.id/model, and maps cache reads and cache writes to disjoint canonical usage fields. Legacy Codex metric events remain readable. - Span and log attributes under the OTel GenAI semconv input names
(
gen_ai.usage.input_tokens, and the oldergen_ai.usage.prompt_tokens/llm.usage.prompt_tokens) count cached prompt tokens as part of input, so the exporter subtracts the cache read and cache creation (cache_write) counts reported beside them to store uncached input. An input smaller than those cache counts is already uncached and is stored as reported. Claude Code's bareinput_tokensis Anthropic's uncached count and is never reduced;rawkeeps every value as the runtime sent it.
Noise controls:
- Generic process/runtime metrics are dropped by default unless
include_runtime_metrics: trueis set. - Codex spans are dropped by default except for a completed turn span carrying
codex.turn.token_usage.*. Setinclude_codex_spans: trueonly when troubleshooting all Codex OTLP internals. - Codex metrics and transport/startup/debug logs remain suppressed by default so one prompt does not flood the endpoint runtime log.
- Copilot CLI metrics are suppressed by default, including
github.copilot.*, legacycopilot_chat.*, andgen_ai.client.*metrics. Activity comes from OTLP spans. Setinclude_runtime_metrics: truefor troubleshooting. - OpenClaw metrics are suppressed by default, including
openclaw.*andgen_ai.client.*token metrics. Activity comes from OTLP logs and traces. Setinclude_runtime_metrics: truefor troubleshooting.
The production implementation should live here and be included by
collector-builder/builder.yaml.
beacon_ingest extension
beaconingestextension (component type beacon_ingest) is the collector side of the restricted
log access mode for system-mode endpoints. With it, the collector is the only writer of
/var/log/beacon-agent/runtime.jsonl, which can then be 0640 root:beacon-log instead of
world-writable:
- It listens on a Unix socket (
/var/run/beacon-agent/ingest.sockby default) that hooks send their events to (pkg/asymptoteobserve/localingest). - Each event's
useris replaced with the sender's kernel-verified uid and account name, so a user can describe their own sessions but cannot write an event under someone else's account. - Events are appended through
internal/runtimelog, the same lock, rotation and file-mode handling the exporter uses, so both writers can share one log. - Shutdown removes the socket; hooks then spool their events privately until the collector is back.
extensions:
beacon_ingest:
log_path: /var/log/beacon-agent/runtime.jsonl
rotate_bytes: 10485760
rotate_archives: 5
service:
extensions: [health_check, beacon_ingest]
beacon endpoint install --system --log-access restricted renders this; nothing else enables it.