Integrations
Kubernetes

Kubernetes

Deploy the OpenTelemetry Collector on Kubernetes for cluster-wide observability.

Overview

The OpenTelemetry Collector is the recommended way to collect telemetry from your Kubernetes cluster. It provides a vendor-agnostic way to receive, process, and export telemetry data.

Automatic instrumentation: The OpenTelemetry Operator can automatically inject instrumentation into your workloads without code changes. This is the recommended approach for Node.js, Python, and Java applications.

Install with Helm

The easiest way to deploy the OpenTelemetry Collector is with Helm:

# Add the OpenTelemetry Helm repository
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update

Create the auth secret

Create a Kubernetes secret with your RocketLogs API token:

kubectl create secret generic rocketlogs-auth \
  --from-literal=token=YOUR_ROCKETLOGS_API_TOKEN \
  -n opentelemetry

Configure the Collector

Create a values file for the Helm chart:

# values.yaml
mode: daemonset

config:
  receivers:
    otlp:
      protocols:
        grpc:
          endpoint: 0.0.0.0:4317
        http:
          endpoint: 0.0.0.0:4318
    
    # Collect Kubernetes events
    k8s_events:
      namespaces: []  # empty = all namespaces
    
    # Collect container logs
    filelog:
      include:
        - /var/log/pods/*/*/*.log
      start_at: end
      include_file_path: true
      include_file_name: false
      operators:
        - type: router
          id: get-format
          routes:
            - output: parser-docker
              expr: 'body matches "^\\{"'
            - output: parser-crio
              expr: 'body matches "^[^ Z]+ "'
            - output: parser-containerd
              expr: 'body matches "^[^ Z]+Z"'

  processors:
    batch:
      timeout: 10s
      send_batch_size: 10000
    
    k8sattributes:
      extract:
        metadata:
          - k8s.pod.name
          - k8s.pod.uid
          - k8s.namespace.name
          - k8s.deployment.name
          - k8s.node.name
      pod_association:
        - sources:
            - from: resource_attribute
              name: k8s.pod.ip
        - sources:
            - from: resource_attribute
              name: k8s.pod.uid

  exporters:
    otlphttp:
      endpoint: https://ingress.us-east-2.rocketgraph.app
      headers:
        Authorization: Bearer ${ROCKETLOGS_TOKEN}

  service:
    pipelines:
      traces:
        receivers: [otlp]
        processors: [k8sattributes, batch]
        exporters: [otlphttp]
      metrics:
        receivers: [otlp]
        processors: [k8sattributes, batch]
        exporters: [otlphttp]
      logs:
        receivers: [otlp, filelog]
        processors: [k8sattributes, batch]
        exporters: [otlphttp]

extraEnvs:
  - name: ROCKETLOGS_TOKEN
    valueFrom:
      secretKeyRef:
        name: rocketlogs-auth
        key: token

Deploy the Collector

helm install opentelemetry-collector open-telemetry/opentelemetry-collector \
  -f values.yaml \
  -n opentelemetry \
  --create-namespace

Verify the installation

# Check the collector pods
kubectl get pods -n opentelemetry

# View collector logs
kubectl logs -l app.kubernetes.io/name=opentelemetry-collector -n opentelemetry

Configure your applications

Point your applications to the collector service:

# In your application's deployment
env:
  - name: OTEL_EXPORTER_OTLP_ENDPOINT
    value: "http://opentelemetry-collector.opentelemetry.svc.cluster.local:4317"
  - name: OTEL_SERVICE_NAME
    value: "my-service"