Skip to content

Beats Receivers: OTel collector not receiving service.telemetry configuration from persisted config #12737

@rubenruizdegauna

Description

@rubenruizdegauna

Summary

When running Elastic Agent in Kubernetes agentless mode with an initial configuration containing service.telemetry settings, the OTel collector does not receive this configuration. The persisted configuration (from elastic-agent.yml) is successfully merged but is not passed to the OTel manager due to a timing issue in the coordinator.

Expected Behavior

The OTel collector should receive the complete merged configuration including:

  • service.telemetry.resource attributes from the persisted config
  • service.telemetry.logs OTLP exporter configuration
  • service.telemetry.metrics OTLP exporter configuration with delta temporality
  • service.telemetry.traces OTLP exporter configuration

This allows the collector to instrument itself and export telemetry to a specified OTLP endpoint.

Actual Behavior

The OTel collector receives nil for the collector configuration, losing all service.telemetry settings from the persisted config. This prevents the collector from exporting its own telemetry.

Root Cause

In coordinator.go, the c.otelCfg field is set after refreshComponentModel() is called, which means when updateManagersWithConfig() reads c.otelCfg to pass to the OTel manager, it's still nil.

Problematic flow:

processConfig()
├── processConfigAgent()
│   ├── applyPersistedConfig()  // cfg.OTel now has service.telemetry ✅
│   └── refreshComponentModel()
│       └── updateManagersWithConfig()
│           └── otelMgr.Update(c.otelCfg)  // c.otelCfg is still nil ❌
└── c.otelCfg = cfg.OTel  // Set too late!

Steps to Reproduce

  1. Deploy Elastic Agent in Kubernetes using agentless mode
  2. Add initial configuration with service.telemetry section in elastic-agent.yml:
service:
  telemetry:
    resource:
      policy_id: my-policy
    logs:
      level: info
      processors:
        - batch:
            exporter:
              otlp:
                protocol: http/protobuf
                endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}
    metrics:
      level: detailed
      readers:
        - periodic:
            exporter:
              otlp:
                protocol: http/protobuf
                endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}
                temporality_preference: delta
  1. Run diagnostics and check otel.yml and otel-merged.yml

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions