The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
OTLP forward: filter to Claude Code and Codex, redact, bound, keep headers out of config.json
Claude74fdc9eb6260
diff --git a/CLAUDE.md b/CLAUDE.mdindex 7f2ce7ee..7476b819 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -65,7 +65,7 @@ Supported runtime surfaces today:- Runtimes that ride shared hook/OTLP paths without a special contract worth expanding here include Antigravity CLI, Devin CLI, Devin Desktop, Factory Droid, Gemini CLI, Grok Build, Hermes Agent, Qwen Code, and VS Code. Installed hook/endpoint support is governed by `cli/beacon/cmd/endpoint_targets.go` plus the install/status switches in `cli/beacon/cmd/endpoint_hooks.go`; discovery rows live in `cli/beacon/internal/endpoint/harness`.- Browser chat telemetry through an optional MV3 extension (`browser-extension/`; Chrome, with a beta Firefox build) covering claude.ai and chatgpt.com. A main-world interceptor tees the streamed response, a per-site adapter parses it into a normalized turn, and the service worker POSTs OTLP GenAI logs to the local collector on `127.0.0.1:4318`; the extension never writes files and never contacts a remote endpoint. `harness.name` resolves to `claude_web` or `chatgpt_web` (already handled by `NormalizeHarnessName` in `pkg/asymptoteobserve/harness.go`, where the browser cases must stay above the generic `claude` rule) and `harness.collection_method` is `otlp`. The one build serves every Chromium browser; each event names the browser it came from in the typed `user_agent.name`/`user_agent.version` fields (OTel semconv, promoted by the exporter so Metadata-only forwarding keeps them), resolved in `browser-extension/src/shared/browser-identity.ts` from UA Client Hints brands, with a UA-string fallback that also names Firefox. Scope is deliberately narrow: only those origins' chat streams, never other tabs or general browsing. Retention defaults to `full`, so prompt and response text is retained by default; this is documented rather than defaulted down, because browser chat telemetry without content has no investigative value. Treat the adapters as experimental, since both sites' stream formats are private and undocumented. Per-browser differences live only in `browser-extension/tools/targets.mjs` (one entry per target, deriving its manifest from `src/manifest.json`; Chrome ships that file verbatim to `dist/`, Firefox gets `dist-firefox/`), and every extension API call goes through the `src/shared/browser.ts` shim (a unit test fails on direct `chrome.*` use). The Firefox Gecko ID `[email protected]` is pinned and must never change.- `beaconjson` OpenTelemetry Collector exporter that converts OTLP logs, traces, metrics, and resource attributes into Beacon endpoint JSONL.-- OTLP forward (`beacon endpoint install|repair --otlp-forward-endpoint`, `--otlp-forward-protocol grpc|http/protobuf`, repeatable `--otlp-forward-header`, `--no-otlp-forward`; `config.json` `destinations.otlp_forward`): for machines whose runtimes already exported OTLP to another backend before Beacon pointed them at its collector. The collector renders an `otlp/forward` or `otlphttp/forward` exporter (both in `collector-builder/builder.yaml`) on `logs/forward`, `traces/forward` and `metrics/forward` pipelines fed by the same receiver with only `memory_limiter` and `batch`, so the backend gets exactly what the runtimes sent and Beacon's processors never touch it. It is a customer-chosen destination like the HEC exporters, not a Beacon network channel, and hooks never use it. Install and repair carry it over (`buildConfig`) until `--no-otlp-forward` removes it; header values make the configs root-only and are shown by name only in status, doctor and `config show`. Guide: `docs/guides/kandji-otlp-forward-mdm.mdx`.+- OTLP forward (`beacon endpoint install|repair --otlp-forward-endpoint`, `--otlp-forward-protocol grpc|http/protobuf`, `--otlp-forward-harness`, repeatable `--otlp-forward-header`, `--no-otlp-forward`; `config.json` `destinations.otlp_forward`): for machines whose runtimes already exported OTLP to another backend before Beacon pointed them at its collector. The collector renders an `otlp/forward` or `otlphttp/forward` exporter (both in `collector-builder/builder.yaml`) on `logs/forward`, `traces/forward` and `metrics/forward` pipelines fed by the same receiver: `memory_limiter`, `beacon_forward_filter` (`forwardfilterprocessor`; keeps only resources whose harness, resolved like beaconjson resolves it, is listed, default Claude Code and Codex, so browser-extension chats and other runtimes never leave), `claude_api_body` on logs, `beacon_privacy`, `batch`. The exporter's queue and retries are bounded so a down backend sheds data instead of pushing `memory_limiter` into refusing Beacon's own pipelines. It is a customer-chosen destination like the HEC exporters, not a Beacon network channel, and carries no hook or session-store data. Install and repair carry it over (`buildConfig`) until `--no-otlp-forward` removes it. Header values never go in `config.json` (ordinary accounts read the system one to find the system log): they live in `OTLPForwardSecretsPath` (`otlp-forward-headers.json`, 0600) and the 0600 collector config, `config.json` keeps `header_names`, and status, doctor and `config show` show names only. Guide: `docs/guides/kandji-otlp-forward-mdm.mdx`.- Endpoint inventory (`inventory.heartbeat` / `inventory.snapshot` in `inventory_state.jsonl`) is written by a scheduled job, `com.beacon.endpoint.inventory` (`service.InventoryManager`, user LaunchAgent or system LaunchDaemon, `beacon-inventory.timer` on systemd), every six hours and once at load, on by default and reconciled by `lifecycle.ReconcileInventoryJob` on every install, repair and package upgrade (`beacon endpoint inventory install-daemon`). Agent hooks do not trigger inventory any more; the hook binary's `--cli` flag and `inventory-heartbeat` subcommand survive only as no-ops for hook commands written by older versions, and `beacon endpoint inventory heartbeat --trigger hook` is likewise retired. A system-mode run inventories the active console user's home and still writes the liveness heartbeat when nobody is logged in; the scheduled scan has no working directory, so project-scoped config is only in `beacon endpoint inventory`.- Beacon Cloud forwarding, the one Beacon-hosted network channel for endpoint telemetry: user-mode `beacon endpoint connect` authorizes device enrollment with the signed-in CLI account; system mode uses browser PKCE at `/cli/enroll`. Both store only the per-device key in `<BaseDir>/asymptote/vector-secrets.json` (0600, 0700 dir), render the selected privacy mode into `vector.toml` (re-rendered in place by install, repair and package upgrades, see above), validate it, and run Vector as `com.beacon.endpoint.asymptote-forwarder` / `beacon-asymptote-forwarder.service` through `service.ForwarderManager` (refused in supervised mode). `enrollment.json` and `config.json`'s `managed_ingest` block carry only non-secret identity and privacy mode; `beacon endpoint status` reports forwarder state and a live credential check (`GET /v1/ingest/health`, 3 s timeout); `disconnect` and `uninstall` remove the forwarder and credentials but never revoke server-side.- Asymptote Observe TypeScript SDK instrumentation for cloud applications, starting from OpenTelemetry/OpenLLMetry patterns and `observe()` wrappers.diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.goindex d3db592c..bc6fe724 100644--- a/cli/beacon/cmd/endpoint.go+++ b/cli/beacon/cmd/endpoint.go@@ -15,6 +15,7 @@ import ("github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/openclaw""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/vscode""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/writer"+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve")var endpointOpts struct {@@ -77,6 +78,7 @@ var endpointOpts struct {otlpForwardEndpoint stringotlpForwardProtocol stringotlpForwardHeaders []string+ otlpForwardHarnesses stringotlpForwardInsecure boolotlpForwardSkipVerify boolotlpForwardCAFile string@@ -795,8 +797,9 @@ func registerFalconFlags(cmd *cobra.Command) {}func registerOTLPForwardFlags(cmd *cobra.Command) {- cmd.Flags().StringVar(&endpointOpts.otlpForwardEndpoint, "otlp-forward-endpoint", "", "Also forward the OTLP the local collector receives, unchanged, to this OTLP endpoint (host:port or URL for grpc, base URL for http/protobuf)")+ cmd.Flags().StringVar(&endpointOpts.otlpForwardEndpoint, "otlp-forward-endpoint", "", "Also forward Claude Code and Codex OTLP the local collector receives, with secrets redacted, to this OTLP endpoint (host:port or URL for grpc, base URL for http/protobuf)")cmd.Flags().StringVar(&endpointOpts.otlpForwardProtocol, "otlp-forward-protocol", endpointconfig.OTLPForwardProtocolGRPC, "OTLP forward protocol: grpc or http/protobuf")+ cmd.Flags().StringVar(&endpointOpts.otlpForwardHarnesses, "otlp-forward-harness", "", "Runtimes whose OTLP the forward carries, comma-separated (default claude,codex); other sources, such as the browser extension, stay local")cmd.Flags().StringArrayVar(&endpointOpts.otlpForwardHeaders, "otlp-forward-header", nil, "Header sent with every OTLP forward export, as name=value (repeatable)")cmd.Flags().BoolVar(&endpointOpts.otlpForwardInsecure, "otlp-forward-insecure", false, "Send the OTLP forward without TLS (gRPC plaintext)")cmd.Flags().BoolVar(&endpointOpts.otlpForwardSkipVerify, "otlp-forward-insecure-skip-verify", false, "Skip TLS certificate verification for the OTLP forward")@@ -815,6 +818,7 @@ func otlpForwardOptions() (*endpointconfig.OTLPForward, error) {}if endpointOpts.otlpForwardEndpoint == "" &&len(endpointOpts.otlpForwardHeaders) == 0 &&+ endpointOpts.otlpForwardHarnesses == "" &&(endpointOpts.otlpForwardProtocol == "" || endpointOpts.otlpForwardProtocol == endpointconfig.OTLPForwardProtocolGRPC) &&!endpointOpts.otlpForwardInsecure &&!endpointOpts.otlpForwardSkipVerify &&@@ -836,7 +840,12 @@ func otlpForwardOptions() (*endpointconfig.OTLPForward, error) {if len(headers) == 0 {headers = nil}+ harnesses, err := otlpForwardHarnesses(endpointOpts.otlpForwardHarnesses)+ if err != nil {+ return nil, err+ }return &endpointconfig.OTLPForward{+ Harnesses: harnesses,Endpoint: endpointOpts.otlpForwardEndpoint,Protocol: endpointOpts.otlpForwardProtocol,Headers: headers,@@ -846,6 +855,32 @@ func otlpForwardOptions() (*endpointconfig.OTLPForward, error) {}, nil}+// otlpForwardHarnesses turns --otlp-forward-harness into canonical harness names; empty keeps the+// default (Claude Code and Codex). Codex CLI and the desktop app export under one name, so+// naming either forwards both.+func otlpForwardHarnesses(value string) ([]string, error) {+ var names []string+ seen := map[string]bool{}+ add := func(name string) {+ if !seen[name] {+ seen[name] = true+ names = append(names, name)+ }+ }+ for _, raw := range splitHarnessCSV(value) {+ name := asymptoteobserve.NormalizeHarnessName(strings.TrimSpace(raw))+ if name == "" {+ return nil, fmt.Errorf("--otlp-forward-harness: unknown runtime %q", raw)+ }+ add(name)+ if name == "codex_cli" || name == "codex_desktop" {+ add("codex_cli")+ add("codex_desktop")+ }+ }+ return names, nil+}+func splunkHECOptions() *endpointconfig.SplunkHEC {if endpointOpts.splunkHECEndpoint == "" &&endpointOpts.splunkHECToken == "" &&diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.goindex 5dc4dfb6..1963ca93 100644--- a/cli/beacon/cmd/endpoint_test.go+++ b/cli/beacon/cmd/endpoint_test.go@@ -476,6 +476,20 @@ func TestOTLPForwardOptions(t *testing.T) {}}+func TestOTLPForwardHarnesses(t *testing.T) {+ got, err := otlpForwardHarnesses("claude, codex")+ if err != nil || strings.Join(got, ",") != "claude_code,codex_cli,codex_desktop" {+ t.Fatalf("otlpForwardHarnesses(claude, codex) = %v, %v", got, err)+ }+ if got, err := otlpForwardHarnesses(""); err != nil || got != nil {+ t.Fatalf("empty = %v, %v; want nil so the default applies", got, err)+ }+ // A name Beacon does not know is kept as given, matched against the resource's own name.+ if got, err := otlpForwardHarnesses("my-agent"); err != nil || strings.Join(got, ",") != "my-agent" {+ t.Fatalf("otlpForwardHarnesses(my-agent) = %v, %v", got, err)+ }+}+func TestRepairCollectorServiceRollsBackWhenReadinessFails(t *testing.T) {oldOpts := endpointOptsoldLoadConfig := repairLoadEndpointConfigdiff --git a/cli/beacon/internal/endpoint/collector/collector.go b/cli/beacon/internal/endpoint/collector/collector.goindex 2407d265..d00897ba 100644--- a/cli/beacon/internal/endpoint/collector/collector.go+++ b/cli/beacon/internal/endpoint/collector/collector.go@@ -148,13 +148,22 @@ func ConfigYAML(cfg endpointconfig.Config) string {}exporters := "[" + strings.Join(exporterNames, ", ") + "]"forwardExporter, forwardName := otlpForwardYAML(cfg)- // The OTLP forward has pipelines of its own, fed by the same receiver, so what it sends is what- // the runtimes sent: none of Beacon's processors (claude_api_body, beacon_privacy) touch it. It- // stands in for the runtime's own export to that backend, which Beacon's settings replaced.- forwardPipelines := ""+ // The OTLP forward stands in for the export a runtime had to another backend before Beacon's+ // settings pointed it at this collector. It has pipelines of its own, fed by the same receiver,+ // that keep Beacon's own pipelines independent of that backend and give it only:+ // - the runtimes it is meant to carry (beacon_forward_filter), never the browser extension's+ // chats or another runtime's OTLP;+ // - Claude Code API body events under the same policy as everywhere else (claude_api_body);+ // - secrets redacted, as for the HEC exporters (beacon_privacy).+ forwardPipelines, forwardFilterYAML := "", ""if forwardName != "" {+ forwardFilterYAML = " " + ForwardFilterProcessor + ":\n harnesses: [" + strings.Join(cfg.Destinations.OTLPForward.Harnesses, ", ") + "]\n"for _, signal := range []string{"logs", "traces", "metrics"} {- forwardPipelines += fmt.Sprintf(" %s/forward:\n receivers: [otlp]\n processors: [memory_limiter, batch]\n exporters: [%s]\n", signal, forwardName)+ apiBody := ""+ if signal == "logs" {+ apiBody = "claude_api_body, "+ }+ forwardPipelines += fmt.Sprintf(" %s/forward:\n receivers: [otlp]\n processors: [memory_limiter, %s, %sbeacon_privacy, batch]\n exporters: [%s]\n", signal, ForwardFilterProcessor, apiBody, forwardName)}}// The direct HEC exporters send what they receive, so beacon_privacy redacts before the@@ -164,6 +173,9 @@ func ConfigYAML(cfg endpointconfig.Config) string {if len(exporterNames) > 1 {privacyYAML, privacyStep = " beacon_privacy: {}\n", "beacon_privacy, "}+ if forwardName != "" {+ privacyYAML = " beacon_privacy: {}\n" + forwardFilterYAML+ }runtimeMetricsYAML := ""if cfg.Collector.IncludeRuntimeMetrics {runtimeMetricsYAML = " include_runtime_metrics: true\n"@@ -242,6 +254,9 @@ service:%s`, cfg.Collector.GRPCPort, grpcLimitYAML, cfg.Collector.HTTPPort, modelContextYAML, privacyYAML, cfg.LogPath, runtimeMetricsYAML+codexSpansYAML+modelContextYAML+splunkExporter+falconExporter+forwardExporter, endpointconfig.HealthCheckPort(cfg.Collector), ingestYAML, extensions, privacyStep, exporters, privacyStep, exporters, privacyStep, exporters, forwardPipelines)}+// ForwardFilterProcessor keeps an OTLP forward to the runtimes it is meant to carry.+const ForwardFilterProcessor = "beacon_forward_filter"+// OTLPForwardExporters are the collector exporters an OTLP forward is rendered with, by protocol.var OTLPForwardExporters = map[string]string{endpointconfig.OTLPForwardProtocolGRPC: "otlp",@@ -274,6 +289,12 @@ func otlpForwardYAML(cfg endpointconfig.Config) (string, string) {fmt.Fprintf(&b, " %q: %q\n", key, forward.Headers[key])}}+ // Bounded well below memory_limiter's 128 MiB, so a backend that is down or slow sheds forward+ // data after a couple of minutes instead of holding enough in memory to make the limiter+ // refuse Beacon's own pipelines.+ fmt.Fprintf(&b, " timeout: 10s\n")+ fmt.Fprintf(&b, " sending_queue:\n enabled: true\n num_consumers: 2\n queue_size: 20\n")+ fmt.Fprintf(&b, " retry_on_failure:\n enabled: true\n max_elapsed_time: 120s\n")if forward.Insecure || forward.InsecureSkipVerify || forward.CAFile != "" {fmt.Fprintf(&b, " tls:\n")if forward.Insecure {diff --git a/cli/beacon/internal/endpoint/collector/collector_test.go b/cli/beacon/internal/endpoint/collector/collector_test.goindex 3baa4ac5..a696f21d 100644--- a/cli/beacon/internal/endpoint/collector/collector_test.go+++ b/cli/beacon/internal/endpoint/collector/collector_test.go@@ -427,7 +427,7 @@ func execLookPath(file string) (string, error) {return exec.LookPath(file)}-func TestConfigYAMLForwardsOTLPUnchangedWhenConfigured(t *testing.T) {+func TestConfigYAMLForwardsFilteredRedactedOTLPWhenConfigured(t *testing.T) {for _, tc := range []struct {protocol, endpoint, exporter string}{@@ -447,20 +447,22 @@ func TestConfigYAMLForwardsOTLPUnchangedWhenConfigured(t *testing.T) {yaml := ConfigYAML(cfg)for _, want := range []string{- " " + tc.exporter + ":\n endpoint: \"" + tc.endpoint + "\"\n headers:\n \"authorization\": \"Bearer secret\"\n \"x-b\": \"2\"\n tls:\n ca_file: \"/tmp/ca.pem\"\n",- " logs/forward:\n receivers: [otlp]\n processors: [memory_limiter, batch]\n exporters: [" + tc.exporter + "]\n",- " traces/forward:\n",- " metrics/forward:\n",- // Beacon's own pipelines are unchanged: the forward is not a fanout from them.- " processors: [memory_limiter, claude_api_body, batch]\n exporters: [beaconjson]\n",+ " " + tc.exporter + ":\n endpoint: \"" + tc.endpoint + "\"\n headers:\n \"authorization\": \"Bearer secret\"\n \"x-b\": \"2\"\n",+ // A down backend sheds forward data rather than filling memory_limiter.+ " sending_queue:\n enabled: true\n num_consumers: 2\n queue_size: 20\n",+ " retry_on_failure:\n enabled: true\n max_elapsed_time: 120s\n",+ " tls:\n ca_file: \"/tmp/ca.pem\"\n",+ " beacon_privacy: {}\n beacon_forward_filter:\n harnesses: [claude_code, codex_cli, codex_desktop]\n",+ " logs/forward:\n receivers: [otlp]\n processors: [memory_limiter, beacon_forward_filter, claude_api_body, beacon_privacy, batch]\n exporters: [" + tc.exporter + "]\n",+ " traces/forward:\n receivers: [otlp]\n processors: [memory_limiter, beacon_forward_filter, beacon_privacy, batch]\n",+ " metrics/forward:\n receivers: [otlp]\n processors: [memory_limiter, beacon_forward_filter, beacon_privacy, batch]\n",+ // Beacon's own pipelines are unchanged by a forward.+ " logs:\n receivers: [otlp]\n processors: [memory_limiter, claude_api_body, batch]\n exporters: [beaconjson]\n",} {if !strings.Contains(yaml, want) {t.Fatalf("ConfigYAML missing %q:\n%s", want, yaml)}}- if strings.Contains(yaml, "beacon_privacy") {- t.Fatalf("an OTLP forward alone should not add beacon_privacy:\n%s", yaml)- }})}}diff --git a/cli/beacon/internal/endpoint/collector/components.go b/cli/beacon/internal/endpoint/collector/components.goindex 14ca3d81..fc671520 100644--- a/cli/beacon/internal/endpoint/collector/components.go+++ b/cli/beacon/internal/endpoint/collector/components.go@@ -33,12 +33,12 @@ var listComponents = func(ctx context.Context, binary string) ([]byte, error) {// extensions names the extensions the config will use beyond health_check -- beacon_ingest, in the// restricted log access mode -- which are refused the same way.func CheckComponents(binary string, extensions ...string) error {- return CheckComponentsFor(binary, extensions, nil)+ return CheckComponentsFor(binary, extensions, nil, nil)}-// CheckComponentsFor is CheckComponents with the exporters the config will use beyond Beacon's-// own -- the OTLP forward's -- refused the same way.-func CheckComponentsFor(binary string, extensions, exporters []string) error {+// CheckComponentsFor is CheckComponents with the processors and exporters the config will use+// beyond Beacon's own -- the OTLP forward's -- refused the same way.+func CheckComponentsFor(binary string, extensions, processors, exporters []string) error {ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)defer cancel()out, err := listComponents(ctx, binary)@@ -63,7 +63,7 @@ func CheckComponentsFor(binary string, extensions, exporters []string) error {for _, processor := range listed.Processors {have[processor.Name] = true}- for _, name := range requiredProcessors {+ for _, name := range append(append([]string{}, requiredProcessors...), processors...) {if !have[name] {return fmt.Errorf("collector %s is older than this beacon CLI: it has no %q processor, which the collector config needs; "+"use the %s from the same Beacon release, or pass --collector with one", binary, name, BinaryName)diff --git a/cli/beacon/internal/endpoint/config/config.go b/cli/beacon/internal/endpoint/config/config.goindex dee857b8..d3c9d1e3 100644--- a/cli/beacon/internal/endpoint/config/config.go+++ b/cli/beacon/internal/endpoint/config/config.go@@ -6,6 +6,7 @@ import ("os""path/filepath""runtime"+ "sort""strings""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/atomicfile"@@ -198,13 +199,68 @@ type OTLPForward struct {Endpoint string `json:"endpoint,omitempty"`// Protocol is "grpc" (the default) or "http/protobuf".Protocol string `json:"protocol,omitempty"`+ // Harnesses are the canonical harness names whose OTLP is forwarded; empty means Claude Code+ // and Codex (DefaultOTLPForwardHarnesses). Every other source the collector receives, such as+ // the browser extension's chats, stays local.+ Harnesses []string `json:"harnesses,omitempty"`// Headers are sent with every export, typically an authorization header the backend issued.- Headers map[string]string `json:"headers,omitempty"`+ // Their values are credentials, so they are kept out of config.json (which ordinary accounts+ // read to find the system log) and stored in the root-only OTLPForwardSecretsPath; config.json+ // carries only HeaderNames.+ Headers map[string]string `json:"-"`+ HeaderNames []string `json:"header_names,omitempty"`Insecure bool `json:"insecure,omitempty"`InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`CAFile string `json:"ca_file,omitempty"`}+// DefaultOTLPForwardHarnesses are the runtimes a forward carries when none are named: the two+// whose OTLP export Beacon takes over.+var DefaultOTLPForwardHarnesses = []string{"claude_code", "codex_cli", "codex_desktop"}++// OTLPForwardSecretsPath holds the forward's header values, beside config.json and 0600.+func OTLPForwardSecretsPath(userMode bool) string {+ return filepath.Join(filepath.Dir(ConfigPath(userMode)), "otlp-forward-headers.json")+}++type otlpForwardSecrets struct {+ Headers map[string]string `json:"headers"`+}++// loadOTLPForwardSecrets fills in the forward's header values. An account that cannot read the+// secrets file (anyone but root, for a system install) gets the forward without them, which is+// all status and the runtime-log lookup need; only root renders the collector config.+func loadOTLPForwardSecrets(cfg *Config) {+ if cfg.Destinations == nil || cfg.Destinations.OTLPForward == nil || len(cfg.Destinations.OTLPForward.HeaderNames) == 0 {+ return+ }+ data, err := os.ReadFile(OTLPForwardSecretsPath(cfg.UserMode))+ if err != nil {+ return+ }+ var secrets otlpForwardSecrets+ if json.Unmarshal(data, &secrets) == nil && len(secrets.Headers) > 0 {+ cfg.Destinations.OTLPForward.Headers = secrets.Headers+ }+}++// saveOTLPForwardSecrets writes the forward's header values to their root-only file, or removes+// the file when the forward has none.+func saveOTLPForwardSecrets(cfg Config) error {+ path := OTLPForwardSecretsPath(cfg.UserMode)+ if cfg.Destinations == nil || cfg.Destinations.OTLPForward == nil || !cfg.Destinations.OTLPForward.Enabled || len(cfg.Destinations.OTLPForward.Headers) == 0 {+ if err := os.Remove(path); err != nil && !os.IsNotExist(err) {+ return err+ }+ return nil+ }+ data, err := json.MarshalIndent(otlpForwardSecrets{Headers: cfg.Destinations.OTLPForward.Headers}, "", " ")+ if err != nil {+ return err+ }+ return atomicfile.Write(path, data, 0600)+}+type SplunkHEC struct {Enabled bool `json:"enabled,omitempty"`Endpoint string `json:"endpoint,omitempty"`@@ -390,6 +446,7 @@ func Load(userMode bool) (Config, error) {if err := json.Unmarshal(data, &cfg); err != nil {return Config{}, err}+ loadOTLPForwardSecrets(&cfg)NormalizeDestinations(&cfg)if err := ValidateDestinations(cfg.Destinations); err != nil {return Config{}, err@@ -410,8 +467,13 @@ func Save(cfg Config) (string, error) {if err != nil {return "", err}+ // The forward's header values live in their own root-only file, so a forward alone leaves+ // config.json readable to the accounts that look up the system log through it.+ if err := saveOTLPForwardSecrets(cfg); err != nil {+ return "", err+ }perm := os.FileMode(0644)- if HasSecretDestinations(cfg) {+ if hasSecretConfigFields(cfg) {perm = 0600}if err := atomicfile.Write(path, data, perm); err != nil {@@ -450,6 +512,16 @@ func NormalizeDestinations(cfg *Config) {if forward.Enabled && forward.Protocol == "" {forward.Protocol = OTLPForwardProtocolGRPC}+ if forward.Enabled && len(forward.Harnesses) == 0 {+ forward.Harnesses = append([]string(nil), DefaultOTLPForwardHarnesses...)+ }+ if forward.Headers != nil {+ forward.HeaderNames = forward.HeaderNames[:0:0]+ for name := range forward.Headers {+ forward.HeaderNames = append(forward.HeaderNames, name)+ }+ sort.Strings(forward.HeaderNames)+ }}if falcon := cfg.Destinations.FalconHEC; falcon != nil {if falcon.Endpoint != "" || falcon.Token != "" {@@ -546,3 +618,12 @@ func HasSecretDestinations(cfg Config) bool {(cfg.Destinations.FalconHEC != nil && cfg.Destinations.FalconHEC.Token != "") ||(cfg.Destinations.OTLPForward != nil && len(cfg.Destinations.OTLPForward.Headers) > 0))}++// hasSecretConfigFields reports whether config.json itself holds a credential. The forward's+// header values are not in it (see OTLPForwardSecretsPath), so they do not count here; they do+// for the collector config, which renders them (HasSecretDestinations).+func hasSecretConfigFields(cfg Config) bool {+ return cfg.Destinations != nil &&+ ((cfg.Destinations.SplunkHEC != nil && cfg.Destinations.SplunkHEC.Token != "") ||+ (cfg.Destinations.FalconHEC != nil && cfg.Destinations.FalconHEC.Token != ""))+}diff --git a/cli/beacon/internal/endpoint/config/config_test.go b/cli/beacon/internal/endpoint/config/config_test.goindex b9818545..78e9070f 100644--- a/cli/beacon/internal/endpoint/config/config_test.go+++ b/cli/beacon/internal/endpoint/config/config_test.go@@ -253,7 +253,10 @@ func TestLoadRejectsCorruptJSON(t *testing.T) {}}-func TestSaveLoadOTLPForwardRoundTripAndPrivatePermissions(t *testing.T) {+// The forward's header values are credentials, but config.json must stay readable: ordinary+// accounts read the system config to find the system runtime log. So the values go to a 0600 file+// of their own and config.json carries only their names.+func TestSaveLoadOTLPForwardKeepsHeaderValuesOutOfConfigJSON(t *testing.T) {testenv.RequirePOSIXFileModes(t)home := t.TempDir()testenv.SetHome(t, home)@@ -270,11 +273,23 @@ func TestSaveLoadOTLPForwardRoundTripAndPrivatePermissions(t *testing.T) {}info, err := os.Stat(path)if err != nil {- t.Fatalf("stat config: %v", err)+ t.Fatal(err)}- if got, want := info.Mode().Perm(), os.FileMode(0600); got != want {- t.Fatalf("config permissions = %o, want %o", got, want)+ if got := info.Mode().Perm(); got != 0644 {+ t.Fatalf("config.json permissions = %o, want 644", got)+ }+ data, _ := os.ReadFile(path)+ if strings.Contains(string(data), "Bearer secret") || !strings.Contains(string(data), `"authorization"`) {+ t.Fatalf("config.json should name the header and not hold its value:\n%s", data)+ }+ secrets, err := os.Stat(OTLPForwardSecretsPath(true))+ if err != nil {+ t.Fatal(err)+ }+ if got := secrets.Mode().Perm(); got != 0600 {+ t.Fatalf("secrets permissions = %o, want 600", got)}+loaded, err := Load(true)if err != nil {t.Fatalf("Load returned error: %v", err)@@ -283,6 +298,30 @@ func TestSaveLoadOTLPForwardRoundTripAndPrivatePermissions(t *testing.T) {if !forward.Enabled || forward.Endpoint != "https://otel.tokenize.example" || forward.Protocol != OTLPForwardProtocolHTTP || forward.Headers["authorization"] != "Bearer secret" {t.Fatalf("OTLP forward did not round-trip: %#v", forward)}+ if strings.Join(forward.Harnesses, ",") != "claude_code,codex_cli,codex_desktop" {+ t.Fatalf("default harnesses = %v", forward.Harnesses)+ }++ // An account that cannot read the secrets still loads the forward, without the values.+ if err := os.Chmod(OTLPForwardSecretsPath(true), 0); err == nil && os.Geteuid() != 0 {+ loaded, err := Load(true)+ if err != nil {+ t.Fatalf("Load without the secrets returned error: %v", err)+ }+ if f := loaded.Destinations.OTLPForward; !f.Enabled || f.Headers != nil || strings.Join(f.HeaderNames, ",") != "authorization" {+ t.Fatalf("forward without secrets = %#v", f)+ }+ }++ // Removing the headers removes the secrets file.+ cfg.Destinations.OTLPForward.Headers = nil+ cfg.Destinations.OTLPForward.HeaderNames = nil+ if _, err := Save(cfg); err != nil {+ t.Fatal(err)+ }+ if _, err := os.Stat(OTLPForwardSecretsPath(true)); !os.IsNotExist(err) {+ t.Fatalf("secrets file left behind: %v", err)+ }}func TestValidateDestinationsRejectsBadOTLPForward(t *testing.T) {diff --git a/cli/beacon/internal/endpoint/lifecycle/destination_status_otlp_test.go b/cli/beacon/internal/endpoint/lifecycle/destination_status_otlp_test.goindex f4a84308..04f9c0eb 100644--- a/cli/beacon/internal/endpoint/lifecycle/destination_status_otlp_test.go+++ b/cli/beacon/internal/endpoint/lifecycle/destination_status_otlp_test.go@@ -2,6 +2,7 @@ package lifecycleimport ("encoding/json"+ "os""strings""testing"@@ -18,12 +19,13 @@ func TestDestinationStatusReportsOTLPForwardWithoutHeaderValues(t *testing.T) {Protocol: endpointconfig.OTLPForwardProtocolGRPC,Headers: map[string]string{"authorization": "Bearer secret"},}}}+ endpointconfig.NormalizeDestinations(&cfg)data, err := json.Marshal(destinationStatus(cfg))if err != nil {t.Fatal(err)}got := string(data)- if !strings.Contains(got, `"otlp_forward":{"configured":true,"endpoint":"otel.backend.example:4317","protocol":"grpc","headers":["authorization"]}`) {+ if !strings.Contains(got, `"otlp_forward":{"configured":true,"endpoint":"otel.backend.example:4317","protocol":"grpc","harnesses":["claude_code","codex_cli","codex_desktop"],"headers":["authorization"]}`) {t.Fatalf("destination status = %s", got)}if strings.Contains(got, "secret") {@@ -36,7 +38,10 @@ func TestDestinationStatusReportsOTLPForwardWithoutHeaderValues(t *testing.T) {// carried over, and only --no-otlp-forward (an empty forward) removes it.func TestBuildConfigKeepsOTLPForwardUntilRemoved(t *testing.T) {testenv.SetHome(t, t.TempDir())- writeInventoryConfig(t, true, `{"user_mode":true,"log_path":"/tmp/runtime.jsonl","destinations":{"otlp_forward":{"enabled":true,"endpoint":"otel.backend.example:4317","protocol":"grpc","headers":{"authorization":"Bearer secret"}}}}`)+ writeInventoryConfig(t, true, `{"user_mode":true,"log_path":"/tmp/runtime.jsonl","destinations":{"otlp_forward":{"enabled":true,"endpoint":"otel.backend.example:4317","protocol":"grpc","header_names":["authorization"]}}}`)+ if err := os.WriteFile(endpointconfig.OTLPForwardSecretsPath(true), []byte(`{"headers":{"authorization":"Bearer secret"}}`), 0600); err != nil {+ t.Fatal(err)+ }cfg := buildConfig(InstallOptions{UserMode: true})if cfg.Destinations == nil || cfg.Destinations.OTLPForward == nil || cfg.Destinations.OTLPForward.Endpoint != "otel.backend.example:4317" || cfg.Destinations.OTLPForward.Headers["authorization"] != "Bearer secret" {diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.goindex 0bfec92b..4dea1273 100644--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go@@ -5,7 +5,6 @@ import ("fmt""os""path/filepath"- "sort""strings""time"@@ -408,6 +407,7 @@ type OTLPForwardStatus struct {Configured bool `json:"configured"`Endpoint string `json:"endpoint,omitempty"`Protocol string `json:"protocol,omitempty"`+ Harnesses []string `json:"harnesses,omitempty"`Headers []string `json:"headers,omitempty"`}@@ -569,11 +569,12 @@ func Install(opts InstallOptions) (InstallResult, error) {if cfg.RestrictedLogAccess() {extensions = append(extensions, endpointcollector.IngestExtension)}- var exporters []string+ var processors, exporters []stringif cfg.Destinations != nil && cfg.Destinations.OTLPForward != nil && cfg.Destinations.OTLPForward.Enabled {+ processors = append(processors, endpointcollector.ForwardFilterProcessor)exporters = append(exporters, endpointcollector.OTLPForwardExporters[cfg.Destinations.OTLPForward.Protocol])}- if err := endpointcollector.CheckComponentsFor(collectorBinary, extensions, exporters); err != nil {+ if err := endpointcollector.CheckComponentsFor(collectorBinary, extensions, processors, exporters); err != nil {return InstallResult{}, err}@@ -644,10 +645,15 @@ func Install(opts InstallOptions) (InstallResult, error) {configPath := endpointconfig.ConfigPath(cfg.UserMode)tx.Track(configPath)manifest.Files = append(manifest.Files, configPath)+ forwardSecretsPath := endpointconfig.OTLPForwardSecretsPath(cfg.UserMode)+ tx.Track(forwardSecretsPath)if _, err := saveEndpointConfig(cfg); err != nil {tx.Rollback(manifest)return InstallResult{}, err}+ if _, err := os.Stat(forwardSecretsPath); err == nil {+ manifest.Files = append(manifest.Files, forwardSecretsPath)+ }// The scheduled inventory job is on by default and reconciled on every install, which is// how a package upgrade turns it on for an endpoint installed before it existed. The unit is@@ -849,8 +855,10 @@ func Uninstall(opts UninstallOptions) error {// a repaired endpoint that kept forwarding read as unconnected on disk. `uninstall// --keep-config` keeps harness settings only, so it still removes Beacon's own config.endpointConfigPath := endpointconfig.ConfigPath(cfg.UserMode)+ forwardSecretsPath := endpointconfig.OTLPForwardSecretsPath(cfg.UserMode)for _, path := range manifest.Files {- if opts.KeepManagedIngest && path == endpointConfigPath {+ // The forward's header values belong with config.json: repair keeps both.+ if opts.KeepManagedIngest && (path == endpointConfigPath || path == forwardSecretsPath) {continue}fail("remove "+path, os.Remove(path))@@ -928,6 +936,8 @@ func repairUninstallOptions(opts InstallOptions) UninstallOptions {func Repair(opts InstallOptions) (InstallResult, error) {configPath := endpointconfig.ConfigPath(opts.UserMode)configSnapshot := snapshotFile(configPath)+ forwardSecretsPath := endpointconfig.OTLPForwardSecretsPath(opts.UserMode)+ forwardSecretsSnapshot := snapshotFile(forwardSecretsPath)priorAutoUpdateMode := ""if !opts.UserMode {if mode, err := autoUpdateModeFromConfigFile(configPath); err == nil {@@ -938,6 +948,7 @@ func Repair(opts InstallOptions) (InstallResult, error) {result, err := Install(opts)if err != nil {restoreFile(configPath, configSnapshot)+ restoreFile(forwardSecretsPath, forwardSecretsSnapshot)return result, err}if !opts.UserMode {@@ -1251,12 +1262,7 @@ func destinationStatus(cfg endpointconfig.Config) DestinationStatus {}}if forward := cfg.Destinations.OTLPForward; forward != nil && forward.Enabled {- headers := make([]string, 0, len(forward.Headers))- for name := range forward.Headers {- headers = append(headers, name)- }- sort.Strings(headers)- status.OTLPForward = OTLPForwardStatus{Configured: true, Endpoint: forward.Endpoint, Protocol: forward.Protocol, Headers: headers}+ status.OTLPForward = OTLPForwardStatus{Configured: true, Endpoint: forward.Endpoint, Protocol: forward.Protocol, Harnesses: forward.Harnesses, Headers: forward.HeaderNames}}return status}diff --git a/collector-builder/builder.yaml b/collector-builder/builder.yamlindex 7c673421..891d6114 100644--- a/collector-builder/builder.yaml+++ b/collector-builder/builder.yaml@@ -15,6 +15,9 @@ processors:- gomod: github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconjsonexporter v0.0.0import: github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconjsonexporter/privacyprocessorpath: ./exporter/beaconjsonexporter+ - gomod: github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconjsonexporter v0.0.0+ import: github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor+ path: ./exporter/beaconjsonexporterexporters:- gomod: github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconjsonexporter v0.0.0diff --git a/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor/processor.go b/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor/processor.gonew file mode 100644index 00000000..0744c7dd--- /dev/null+++ b/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor/processor.go@@ -0,0 +1,95 @@+// Package forwardfilterprocessor keeps only the runtimes an OTLP forward is meant to carry.+//+// The OTLP forward replaces the export a runtime had to another backend before Beacon pointed it at+// the local collector. The collector's receiver is shared by every OTLP source Beacon sets up+// (Gemini CLI, VS Code, SDKs, the browser extension's claude.ai and ChatGPT chats), so without this+// filter the forward would hand that backend telemetry it never received before. A resource whose+// harness is not listed, or cannot be named, is dropped from the forward only.+package forwardfilterprocessor++import (+ "context"++ "go.opentelemetry.io/collector/component"+ "go.opentelemetry.io/collector/consumer"+ "go.opentelemetry.io/collector/pdata/pcommon"+ "go.opentelemetry.io/collector/pdata/plog"+ "go.opentelemetry.io/collector/pdata/pmetric"+ "go.opentelemetry.io/collector/pdata/ptrace"+ "go.opentelemetry.io/collector/processor"+ "go.opentelemetry.io/collector/processor/processorhelper"++ "github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconjsonexporter/internal/beaconevent"+)++var componentType = component.MustNewType("beacon_forward_filter")++// Config lists the canonical harness names (asymptoteobserve.NormalizeHarnessName) to forward.+type Config struct {+ Harnesses []string `mapstructure:"harnesses"`+}++func NewFactory() processor.Factory {+ return processor.NewFactory(componentType, func() component.Config { return &Config{} },+ processor.WithLogs(createLogs, component.StabilityLevelBeta),+ processor.WithTraces(createTraces, component.StabilityLevelBeta),+ processor.WithMetrics(createMetrics, component.StabilityLevelBeta))+}++type filter map[string]bool++func newFilter(cfg component.Config) filter {+ allowed := filter{}+ for _, name := range cfg.(*Config).Harnesses {+ if normalized := beaconevent.NormalizeHarnessName(name); normalized != "" {+ allowed[normalized] = true+ }+ }+ return allowed+}++// drops reports whether a resource's telemetry stays out of the forward. The harness is resolved+// from the resource attributes the way the beaconjson exporter resolves it, so an explicit+// beacon.harness.name (the browser extension's claude_web/chatgpt_web) wins over service.name.+func (f filter) drops(resource pcommon.Resource) bool {+ attrs := resource.Attributes().AsRaw()+ if beaconevent.FirstString(attrs, "beacon.harness.name", "harness.name", "service.name", "telemetry.sdk.name") == "" {+ return true+ }+ return !f[beaconevent.HarnessName(attrs)]+}++var mutates = processorhelper.WithCapabilities(consumer.Capabilities{MutatesData: true})++func createLogs(ctx context.Context, set processor.Settings, cfg component.Config, next consumer.Logs) (processor.Logs, error) {+ f := newFilter(cfg)+ return processorhelper.NewLogs(ctx, set, cfg, next, func(_ context.Context, logs plog.Logs) (plog.Logs, error) {+ logs.ResourceLogs().RemoveIf(func(r plog.ResourceLogs) bool { return f.drops(r.Resource()) })+ if logs.ResourceLogs().Len() == 0 {+ return logs, processorhelper.ErrSkipProcessingData+ }+ return logs, nil+ }, mutates)+}++func createTraces(ctx context.Context, set processor.Settings, cfg component.Config, next consumer.Traces) (processor.Traces, error) {+ f := newFilter(cfg)+ return processorhelper.NewTraces(ctx, set, cfg, next, func(_ context.Context, traces ptrace.Traces) (ptrace.Traces, error) {+ traces.ResourceSpans().RemoveIf(func(r ptrace.ResourceSpans) bool { return f.drops(r.Resource()) })+ if traces.ResourceSpans().Len() == 0 {+ return traces, processorhelper.ErrSkipProcessingData+ }+ return traces, nil+ }, mutates)+}++func createMetrics(ctx context.Context, set processor.Settings, cfg component.Config, next consumer.Metrics) (processor.Metrics, error) {+ f := newFilter(cfg)+ return processorhelper.NewMetrics(ctx, set, cfg, next, func(_ context.Context, metrics pmetric.Metrics) (pmetric.Metrics, error) {+ metrics.ResourceMetrics().RemoveIf(func(r pmetric.ResourceMetrics) bool { return f.drops(r.Resource()) })+ if metrics.ResourceMetrics().Len() == 0 {+ return metrics, processorhelper.ErrSkipProcessingData+ }+ return metrics, nil+ }, mutates)+}diff --git a/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor/processor_test.go b/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor/processor_test.gonew file mode 100644index 00000000..8423d082--- /dev/null+++ b/collector-builder/exporter/beaconjsonexporter/forwardfilterprocessor/processor_test.go@@ -0,0 +1,96 @@+package forwardfilterprocessor++import (+ "context"+ "testing"++ "go.opentelemetry.io/collector/consumer/consumertest"+ "go.opentelemetry.io/collector/pdata/plog"+ "go.opentelemetry.io/collector/pdata/pmetric"+ "go.opentelemetry.io/collector/pdata/ptrace"+ "go.opentelemetry.io/collector/processor/processortest"+)++// resources are one OTLP source each: what each sets on its resource, and whether a forward of+// Claude Code and Codex carries it.+var resources = []struct {+ attrs map[string]any+ forward bool+}{+ {map[string]any{"service.name": "claude-code"}, true},+ {map[string]any{"service.name": "codex_cli_rs"}, true},+ {map[string]any{"service.name": "codex-app-server"}, true},+ {map[string]any{"service.name": "agent-beacon-browser-collector", "beacon.harness.name": "claude_web"}, false},+ {map[string]any{"service.name": "agent-beacon-browser-collector", "beacon.harness.name": "chatgpt_web"}, false},+ {map[string]any{"service.name": "gemini-cli"}, false},+ {map[string]any{}, false},+}++func config() *Config {+ return &Config{Harnesses: []string{"claude_code", "codex_cli", "codex_desktop"}}+}++func TestLogsKeepOnlyListedHarnesses(t *testing.T) {+ sink := new(consumertest.LogsSink)+ proc, err := NewFactory().CreateLogs(context.Background(), processortest.NewNopSettings(componentType), config(), sink)+ if err != nil {+ t.Fatal(err)+ }+ logs := plog.NewLogs()+ want := 0+ for _, r := range resources {+ resource := logs.ResourceLogs().AppendEmpty()+ if err := resource.Resource().Attributes().FromRaw(r.attrs); err != nil {+ t.Fatal(err)+ }+ resource.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStr("x")+ if r.forward {+ want+++ }+ }+ if err := proc.ConsumeLogs(context.Background(), logs); err != nil {+ t.Fatal(err)+ }+ got := sink.AllLogs()+ if len(got) != 1 || got[0].ResourceLogs().Len() != want {+ t.Fatalf("forwarded %d batches, want one with %d resources", len(got), want)+ }+ for i := 0; i < got[0].ResourceLogs().Len(); i++ {+ if name, ok := got[0].ResourceLogs().At(i).Resource().Attributes().Get("beacon.harness.name"); ok {+ t.Fatalf("forwarded a browser resource: %s", name.Str())+ }+ }+}++func TestNothingListedForwardsNothing(t *testing.T) {+ sink := new(consumertest.TracesSink)+ proc, err := NewFactory().CreateTraces(context.Background(), processortest.NewNopSettings(componentType), &Config{Harnesses: []string{"codex_cli"}}, sink)+ if err != nil {+ t.Fatal(err)+ }+ traces := ptrace.NewTraces()+ _ = traces.ResourceSpans().AppendEmpty().Resource().Attributes().FromRaw(map[string]any{"service.name": "claude-code"})+ if err := proc.ConsumeTraces(context.Background(), traces); err != nil {+ t.Fatal(err)+ }+ if len(sink.AllTraces()) != 0 {+ t.Fatalf("forwarded Claude Code spans with only Codex listed")+ }+}++func TestMetricsKeepListedHarness(t *testing.T) {+ sink := new(consumertest.MetricsSink)+ proc, err := NewFactory().CreateMetrics(context.Background(), processortest.NewNopSettings(componentType), config(), sink)+ if err != nil {+ t.Fatal(err)+ }+ metrics := pmetric.NewMetrics()+ _ = metrics.ResourceMetrics().AppendEmpty().Resource().Attributes().FromRaw(map[string]any{"service.name": "claude-code"})+ _ = metrics.ResourceMetrics().AppendEmpty().Resource().Attributes().FromRaw(map[string]any{"service.name": "gemini-cli"})+ if err := proc.ConsumeMetrics(context.Background(), metrics); err != nil {+ t.Fatal(err)+ }+ if got := sink.AllMetrics(); len(got) != 1 || got[0].ResourceMetrics().Len() != 1 {+ t.Fatalf("want only the Claude Code resource forwarded, got %+v", got)+ }+}diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex e8ed9f77..03beffbb 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -11,7 +11,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.## Unreleased-- **Forward OTLP to a second backend** · Macs that already sent Claude Code or Codex OpenTelemetry to another backend lost that export when Beacon pointed the runtimes at its collector. `beacon endpoint install|repair --otlp-forward-endpoint <endpoint>` (with `--otlp-forward-protocol grpc|http/protobuf` and repeatable `--otlp-forward-header name=value`) now has the collector send everything it receives, unchanged, to that endpoint as well, through pipelines of its own so Beacon's processing does not touch it. Repair and package upgrades keep it; `--no-otlp-forward` removes it. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm).+- **Forward OTLP to a second backend** · Macs that already sent Claude Code or Codex OpenTelemetry to another backend lost that export when Beacon pointed the runtimes at its collector. `beacon endpoint install|repair --otlp-forward-endpoint <endpoint>` (with `--otlp-forward-protocol grpc|http/protobuf` and repeatable `--otlp-forward-header name=value`) now has the collector send that OTLP on to the endpoint as well, through pipelines of its own. The forward carries only Claude Code and Codex by default (`--otlp-forward-harness` changes the list), so browser-extension chats and other runtimes stay local. Secrets are redacted, raw API bodies are dropped, and the queue is bounded, so a down backend never holds up Beacon's own capture. Header values are kept in a root-only `otlp-forward-headers.json` beside `config.json`. Repair and package upgrades keep it; `--no-otlp-forward` removes it. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm).- **Inherited per-signal OTLP settings no longer divert Claude telemetry** · An `OTEL_EXPORTER_OTLP_{LOGS,METRICS,TRACES}_ENDPOINT`, protocol or headers setting in the environment or Claude's settings sent Claude's telemetry past Beacon's collector, in `beacon ci` and with `beacon endpoint`, which still reported telemetry as enabled. Beacon now overrides them, and `beacon endpoint status` flags one that points elsewhere.- **`beacon git` links symlinks a session creates** · When a session's directory ran through a symlink, such as `/tmp` on macOS, a link the session created was resolved to its target: `ln -s ../shared/config.json cfg.json` linked nothing, and `ln -s a.txt alias.txt` was credited as `a.txt`. The link itself is now recorded.- **Local MCP server follows JSON-RPC more closely** · `beacon mcp serve` changed large numeric request ids (above 2^53, or forms like `1e3`) when echoing them, left out `id` on parse errors, and rejected MCP `ping`; ids are now returned exactly, errors carry `"id": null`, and `ping` is answered.diff --git a/docs/cli/endpoint-install.mdx b/docs/cli/endpoint-install.mdxindex 810e3c53..f3f65335 100644--- a/docs/cli/endpoint-install.mdx+++ b/docs/cli/endpoint-install.mdx@@ -52,9 +52,10 @@ The `claude` harness writes both Claude Code's OpenTelemetry settings and its us| `--falcon-sourcetype <type>` | Optional Falcon LogScale parser or sourcetype || `--falcon-insecure-skip-verify` | Skip Falcon LogScale HEC TLS certificate verification || `--falcon-ca-file <path>` | Optional CA certificate path for Falcon LogScale HEC TLS verification |-| `--otlp-forward-endpoint <endpoint>` | Also forward the OTLP the local collector receives, unchanged, to a second OTLP endpoint: `host:port` or a URL for gRPC, the base URL for HTTP. For runtimes that already exported to another backend before Beacon took over their OTLP settings. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm). Omitted, install and repair keep the forward the endpoint already has |+| `--otlp-forward-endpoint <endpoint>` | Also forward the Claude Code and Codex OTLP the local collector receives, with secrets redacted and raw API bodies dropped, to a second OTLP endpoint: `host:port` or a URL for gRPC, the base URL for HTTP. For runtimes that already exported to another backend before Beacon took over their OTLP settings. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm). Omitted, install and repair keep the forward the endpoint already has || `--otlp-forward-protocol <protocol>` | `grpc` (default) or `http/protobuf` |-| `--otlp-forward-header <name=value>` | Header sent with every forwarded export, usually the backend's API key; repeatable. Makes the endpoint config root-only; status and doctor show header names only |+| `--otlp-forward-harness <list>` | Runtimes whose OTLP the forward carries, comma-separated. Default `claude,codex`; any other source, such as the browser extension, stays local |+| `--otlp-forward-header <name=value>` | Header sent with every forwarded export, usually the backend's API key; repeatable. Values are stored in a root-only `otlp-forward-headers.json` beside `config.json`, which keeps only the names; status and doctor show names only || `--otlp-forward-insecure` | Send the forward without TLS (plaintext gRPC) || `--otlp-forward-insecure-skip-verify` | Skip TLS certificate verification for the forward || `--otlp-forward-ca-file <path>` | Optional CA certificate path for the forward's TLS verification |diff --git a/docs/cli/endpoint-repair.mdx b/docs/cli/endpoint-repair.mdxindex 381de223..837c02b0 100644--- a/docs/cli/endpoint-repair.mdx+++ b/docs/cli/endpoint-repair.mdx@@ -50,9 +50,10 @@ On an endpoint connected to Beacon Cloud, repair leaves the forwarder service, t| `--falcon-sourcetype <type>` | Optional Falcon LogScale parser or sourcetype || `--falcon-insecure-skip-verify` | Skip Falcon LogScale HEC TLS certificate verification || `--falcon-ca-file <path>` | Optional CA certificate path for Falcon LogScale HEC TLS verification |-| `--otlp-forward-endpoint <endpoint>` | Also forward the OTLP the local collector receives, unchanged, to a second OTLP endpoint: `host:port` or a URL for gRPC, the base URL for HTTP. For runtimes that already exported to another backend before Beacon took over their OTLP settings. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm). Omitted, install and repair keep the forward the endpoint already has |+| `--otlp-forward-endpoint <endpoint>` | Also forward the Claude Code and Codex OTLP the local collector receives, with secrets redacted and raw API bodies dropped, to a second OTLP endpoint: `host:port` or a URL for gRPC, the base URL for HTTP. For runtimes that already exported to another backend before Beacon took over their OTLP settings. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm). Omitted, install and repair keep the forward the endpoint already has || `--otlp-forward-protocol <protocol>` | `grpc` (default) or `http/protobuf` |-| `--otlp-forward-header <name=value>` | Header sent with every forwarded export, usually the backend's API key; repeatable. Makes the endpoint config root-only; status and doctor show header names only |+| `--otlp-forward-harness <list>` | Runtimes whose OTLP the forward carries, comma-separated. Default `claude,codex`; any other source, such as the browser extension, stays local |+| `--otlp-forward-header <name=value>` | Header sent with every forwarded export, usually the backend's API key; repeatable. Values are stored in a root-only `otlp-forward-headers.json` beside `config.json`, which keeps only the names; status and doctor show names only || `--otlp-forward-insecure` | Send the forward without TLS (plaintext gRPC) || `--otlp-forward-insecure-skip-verify` | Skip TLS certificate verification for the forward || `--otlp-forward-ca-file <path>` | Optional CA certificate path for the forward's TLS verification |diff --git a/docs/guides/kandji-otlp-forward-mdm.mdx b/docs/guides/kandji-otlp-forward-mdm.mdxindex fe96108e..2b204adf 100644--- a/docs/guides/kandji-otlp-forward-mdm.mdx+++ b/docs/guides/kandji-otlp-forward-mdm.mdx@@ -7,7 +7,7 @@ description: "Deploy Beacon with Kandji on Macs that already export Claude CodeUse this runbook when your Macs already send Claude Code and Codex CLI OpenTelemetry (OTLP) to another backend, such as a token-usage or cost platform, and you are adding Beacon with Kandji.-Claude Code and Codex each export OTLP to one endpoint. Beacon needs that export to arrive at its local collector, so installing Beacon points both runtimes at `127.0.0.1:4317`, and the runtimes stop sending to the backend you already had. To keep that backend fed, Beacon's collector **forwards everything it receives, unchanged, to a second OTLP endpoint** alongside writing its own runtime log:+Claude Code and Codex each export OTLP to one endpoint. Beacon needs that export to arrive at its local collector, so installing Beacon points both runtimes at `127.0.0.1:4317`, and the runtimes stop sending to the backend you already had. To keep that backend fed, Beacon's collector **forwards the Claude Code and Codex OTLP it receives to a second OTLP endpoint**, with secrets redacted, alongside writing its own runtime log:```mermaidflowchart LR@@ -15,7 +15,7 @@ flowchart LRCodex[Codex CLI] -->|OTLP| CollectorClaudeHooks[Claude Code / Codex hooks] --> RuntimeLog["runtime.jsonl"]Collector -->|Beacon pipeline| RuntimeLog- Collector -->|"OTLP forward (unchanged)"| Backend["Your existing OTLP backend"]+ Collector -->|"OTLP forward (Claude Code + Codex, redacted)"| Backend["Your existing OTLP backend"]```Kandji provides the deployment layer:@@ -32,7 +32,15 @@ Kandji provides the deployment layer:## What the existing backend receives-The forward has its own collector pipelines, fed by the same receiver as Beacon's. None of Beacon's processing (event normalization, API-body handling, secret redaction) is applied to it: the backend receives the OTLP logs, metrics and traces exactly as Claude Code and Codex sent them to Beacon. If the backend is unreachable, the forward retries and queues in memory on its own; Beacon's local capture is not held up.+The forward has its own collector pipelines, fed by the same receiver as Beacon's. The backend receives the OTLP logs, metrics and traces Claude Code and Codex send, in OTLP form rather than Beacon's event schema, with three differences from the raw export:++- **Only Claude Code and Codex.** Other OTLP the collector receives stays local: Gemini CLI, VS Code, SDK apps, and Beacon's browser extension, which carries full claude.ai and ChatGPT chats. `--otlp-forward-harness` names a different list.+- **Secrets redacted.** Credentials found in prompts, commands and tool arguments are replaced with `[REDACTED]`, the same redaction Beacon applies before Splunk and Falcon. Token counts, cost, models and session ids are untouched.+- **No raw API bodies.** Claude Code API body events get the same handling as in Beacon's own log.++Hook events and session-file data (`beacon endpoint claude sync`, `codex sync`) never pass through the collector, so the forward does not carry them.++If the backend is down or slow, the forward retries for up to two minutes and holds at most a small queue, then drops what it cannot send. Beacon's local capture never waits on it.What the runtimes send is set by Beacon's runtime settings, which can differ from the settings you rolled out for the backend. Check these with the backend's owner before rollout:@@ -116,7 +124,7 @@ done|| "$BEACON" endpoint status --system --json```-`beacon endpoint repair` stores the forward in `/Library/Application Support/Beacon/Endpoint/config.json` and renders it into the collector config next to it. Both files become root-only (`0600`) when the forward has headers, because header values are usually credentials. Package upgrades and later repairs keep the forward; you do not pass the flags again. To remove it, run `beacon endpoint repair --system --no-otlp-forward`.+`beacon endpoint repair` stores the forward in `/Library/Application Support/Beacon/Endpoint/config.json` and renders it into the collector config next to it. Header values are usually credentials, so they go to a root-only file beside it, `otlp-forward-headers.json` (`0600`), and into the collector config, which is also `0600`. `config.json` keeps only the header names and stays readable, because the logged-in user's `beacon` commands read it to find the system log. Package upgrades and later repairs keep the forward; you do not pass the flags again. To remove it, run `beacon endpoint repair --system --no-otlp-forward`.Flags you may also need:diff --git a/docs/log-forwarding/index.mdx b/docs/log-forwarding/index.mdxindex 2e7c2847..5f29a8eb 100644--- a/docs/log-forwarding/index.mdx+++ b/docs/log-forwarding/index.mdx@@ -5,7 +5,7 @@ description: "Forward Beacon endpoint events from local JSONL into SIEMs, log ag## Forwarding overview-Beacon writes normalized [endpoint events](/concepts/core-concepts#endpoint-event) as JSONL. The active [runtime log](/concepts/core-concepts#runtime-jsonl-log) is the handoff point for local review, [customer-managed log pipelines](/concepts/core-concepts#customer-managed-forwarding), log aggregators, object storage exporters, and most SIEM content packs. Beacon can also enable optional collector exporters for [Splunk HTTP Event Collector (HEC)](/concepts/core-concepts#splunk-hec) and [CrowdStrike Falcon LogScale HEC](/concepts/core-concepts#falcon-logscale-hec) during endpoint install or repair, and an [OTLP forward](/guides/kandji-otlp-forward-mdm) that passes the runtimes' OTLP, unchanged, on to a second OTLP backend.+Beacon writes normalized [endpoint events](/concepts/core-concepts#endpoint-event) as JSONL. The active [runtime log](/concepts/core-concepts#runtime-jsonl-log) is the handoff point for local review, [customer-managed log pipelines](/concepts/core-concepts#customer-managed-forwarding), log aggregators, object storage exporters, and most SIEM content packs. Beacon can also enable optional collector exporters for [Splunk HTTP Event Collector (HEC)](/concepts/core-concepts#splunk-hec) and [CrowdStrike Falcon LogScale HEC](/concepts/core-concepts#falcon-logscale-hec) during endpoint install or repair, and an [OTLP forward](/guides/kandji-otlp-forward-mdm) that passes Claude Code and Codex OTLP, with secrets redacted, on to a second OTLP backend.Use the subpages below by destination category. Beacon Cloud is the one path that sends events to a Beacon-run service; it is opt-in per device and revocable from the Beacon dashboard. SIEM pages are for destinations that become investigation or detection systems. Log aggregation pages are for customer-owned pipelines and observability stores that tail local JSONL. Object storage pages are for archival or data lake export. Local pages cover the default runtime log and dashboard source.