Skip to Content
KubeSense

OpenTelemetry Collector

Send traces, metrics and logs from an OpenTelemetry Collector to KubeSense, on Kubernetes or a VM, and fan out to KubeSense and another backend at the same time.

The OpenTelemetry Collector is the recommended way to send OpenTelemetry data to KubeSense when you run more than a few services. Applications export to a Collector near them, and the Collector batches, retries, adds metadata and forwards each signal to KubeSense.

A Collector also lets applications keep any OTLP protocol they already use. The Collector receives OTLP/gRPC (4317) and OTLP/HTTP (4318) from applications and forwards to KubeSense over OTLP/HTTP.

Applications (OpenTelemetry SDKs and agents)
      │  OTLP/gRPC :4317 or OTLP/HTTP :4318
      ▼
OpenTelemetry Collector ── resource attributes, Kubernetes metadata, batching, retries
      │  OTLP/HTTP
      ├─▶ traces   kubesense-kubecol:33443
      ├─▶ metrics  kubesense-metrics-scraper:30060/opentelemetry/v1/metrics
      └─▶ logs     kubesense-aggregator:30055

Before you start

Turn on the KubeSense receivers you need in your KubeSense server values, then upgrade the release:

kubecol:
  external_agent_traces:
    enabled: true          # traces on port 33443

metrics-scraper:
  service:
    enabled: true          # metrics on port 30060

aggregator:
  sources:
    otel:
      enabled: true        # OTLP logs on ports 30055 (HTTP) and 30056 (gRPC)
helm upgrade kubesense kubesense/kubesense -n kubesense -f values.yaml

If the Collector runs outside the KubeSense cluster (on a VM or in another Kubernetes cluster), expose ports 33443, 30060 and 30055 through an internal load balancer and allow inbound traffic from the Collector's network. See External Service Logs & Metrics.

Exporter configuration

Use one otlphttp exporter per signal, because each signal is received by a different KubeSense component:

exporters:
  otlphttp/kubesense_traces:
    traces_endpoint: http://kubesense-kubecol.kubesense.svc.cluster.local:33443/v1/traces
    tls:
      insecure: true
  otlphttp/kubesense_metrics:
    metrics_endpoint: http://kubesense-metrics-scraper.kubesense.svc.cluster.local:30060/opentelemetry/v1/metrics
    tls:
      insecure: true
  otlphttp/kubesense_logs:
    logs_endpoint: http://<AGGREGATOR_HOST>:30055/v1/logs
    tls:
      insecure: true

traces_endpoint, metrics_endpoint and logs_endpoint take the full URL including the path. From outside the KubeSense cluster, replace the service names with your load balancer addresses.

Kubernetes

This configuration is for the OpenTelemetry Collector Helm chart. It receives all three signals, adds Kubernetes metadata and the KubeSense resource attributes, and forwards traces and metrics to KubeSense. Replace <CLUSTER_NAME> with the cluster name shown in KubeSense.

mode: deployment

image:
  repository: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib

command:
  name: otelcol-contrib

presets:
  kubernetesAttributes:
    enabled: true      # adds the RBAC the k8sattributes processor needs

config:
  receivers:
    otlp:
      protocols:
        grpc:
          endpoint: 0.0.0.0:4317
        http:
          endpoint: 0.0.0.0:4318

  processors:
    memory_limiter:
      check_interval: 1s
      limit_percentage: 75
      spike_limit_percentage: 15
    k8sattributes:
      passthrough: false
      extract:
        metadata:
          - k8s.namespace.name
          - k8s.deployment.name
          - k8s.statefulset.name
          - k8s.daemonset.name
          - k8s.node.name
          - k8s.pod.name
      pod_association:
        - sources:
            - from: resource_attribute
              name: k8s.pod.ip
        - sources:
            - from: connection
    resource:
      attributes:
        - action: insert
          key: kubesense.cluster
          value: <CLUSTER_NAME>
        - action: insert
          key: kubesense.env_type
          value: k8s
    batch:
      send_batch_size: 10000
      timeout: 10s

  exporters:
    otlphttp/kubesense_traces:
      traces_endpoint: http://kubesense-kubecol.kubesense.svc.cluster.local:33443/v1/traces
      tls:
        insecure: true
    otlphttp/kubesense_metrics:
      metrics_endpoint: http://kubesense-metrics-scraper.kubesense.svc.cluster.local:30060/opentelemetry/v1/metrics
      tls:
        insecure: true

  service:
    pipelines:
      traces:
        receivers: [otlp]
        processors: [memory_limiter, k8sattributes, resource, batch]
        exporters: [otlphttp/kubesense_traces]
      metrics:
        receivers: [otlp]
        processors: [memory_limiter, k8sattributes, resource, batch]
        exporters: [otlphttp/kubesense_metrics]
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm install otel-collector open-telemetry/opentelemetry-collector \
  --namespace kubesense \
  -f collector-values.yaml

Applications then export to http://otel-collector-opentelemetry-collector.kubesense.svc.cluster.local:4318 (OTLP/HTTP) or otel-collector-opentelemetry-collector.kubesense.svc.cluster.local:4317 (OTLP/gRPC).

No logs pipeline on Kubernetes: On Kubernetes, the KubeSense log sensor already collects container stdout and stderr, so this configuration has no logs pipeline. Exporting the same logs over OTLP too would store each line twice. See Logs.

To instrument workloads automatically and point them at this Collector, see Kubernetes (OpenTelemetry Operator).

VMs and EC2 hosts

On a Linux or Windows host, run otelcol-contrib next to your applications. Applications export to localhost, and the Collector forwards to the KubeSense load balancer. This example also collects host metrics. Replace the placeholders with your load balancer addresses and cluster name.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 127.0.0.1:4317
      http:
        endpoint: 127.0.0.1:4318
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu: {}
      memory: {}
      disk: {}
      filesystem: {}
      network: {}
      load: {}

processors:
  resourcedetection:
    detectors: [env, system, ec2]
  resource:
    attributes:
      - action: insert
        key: kubesense.cluster
        value: <CLUSTER_NAME>
      - action: insert
        key: kubesense.env_type
        value: legacy
  batch: {}

exporters:
  otlphttp/kubesense_traces:
    traces_endpoint: http://<KUBECOL_HOST>:33443/v1/traces
    tls:
      insecure: true
  otlphttp/kubesense_metrics:
    metrics_endpoint: http://<METRICS_SCRAPER_HOST>:30060/opentelemetry/v1/metrics
    tls:
      insecure: true
  otlphttp/kubesense_logs:
    logs_endpoint: http://<AGGREGATOR_HOST>:30055/v1/logs
    tls:
      insecure: true

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [resourcedetection, resource, batch]
      exporters: [otlphttp/kubesense_traces]
    metrics:
      receivers: [otlp, hostmetrics]
      processors: [resourcedetection, resource, batch]
      exporters: [otlphttp/kubesense_metrics]
    logs:
      receivers: [otlp]
      processors: [resourcedetection, resource, batch]
      exporters: [otlphttp/kubesense_logs]

Remove the ec2 detector on hosts outside AWS. For a full host-metrics setup with process metrics and Windows, see Host Monitoring. For log files on the host, see OpenTelemetry (OTLP).

Send to KubeSense and another backend at the same time

A pipeline can list more than one exporter, and the Collector sends every item to each of them. Add the KubeSense exporters next to your current backend to run both side by side while you evaluate or migrate:

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, k8sattributes, resource, batch]
      exporters: [otlphttp/kubesense_traces, otlp/current_backend]
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, k8sattributes, resource, batch]
      exporters: [otlphttp/kubesense_metrics, otlp/current_backend]

When you're ready to switch, remove the old exporter. Applications don't change at any point.

Troubleshooting

SymptomLikely cause
Connection refused on 33443, 30060 or 30055The receiver isn't enabled (see Before you start), or the port isn't reachable from the Collector
400 Bad Request from the metrics endpointEither the path is wrong or the payload is JSON. Use metrics_endpoint with the full /opentelemetry/v1/metrics path (with endpoint: http://<host>:30060, the exporter posts to /v1/metrics and misses the /opentelemetry prefix), and keep the default protobuf encoding
Exporter errors mentioning gRPCA KubeSense endpoint is configured on an otlp (gRPC) exporter. Use otlphttp
Data appears under the wrong cluster, or not at allkubesense.cluster or kubesense.env_type is missing; check the resource processor is in every pipeline
Nothing arrives and no errorsCheck the Collector's own logs (kubectl logs or journalctl -u otelcol-contrib). Add the debug exporter to a pipeline to see what the Collector receives

On this page