Guides · Kubernetes

Kubernetes observability with OpenTelemetry

In Kubernetes, pods start and stop all the time, and a problem can be in the application, the pod, the node or the cluster. This guide lays out what to observe at each layer and how to collect it with OpenTelemetry, with no proprietary agents.

By the OneGlass team · December 3, 2026 · 8 min read

What to observe

A cluster has four layers, and each one answers a different question:

  • Applications: traces, metrics and logs from your services. Which request failed, and where?
  • Pods and containers: CPU, memory, restarts and logs for each container. Did it run out of memory? Is it restarting in a loop?
  • Nodes: CPU, memory, disk and network of each machine. Is the node saturated?
  • Cluster: the state of objects (Deployments, desired vs. available replicas, pending pods) and events. Could Kubernetes do what you asked?

Looking at a single layer leads to wrong diagnoses. A slow service can be code, a badly set CPU limit or a node out of resources, and you can only tell them apart with all four in view and linked to each other.

The architecture: two Collectors, not one

The standard approach uses the OpenTelemetry Collector deployed in two ways, because some data comes from each node and some comes from the cluster as a whole.

One Collector per node (DaemonSet)

It runs a copy on every node and collects what can only be seen from there:

  • Pod and container metrics, which it asks for from the node's own kubelet.
  • Container logs, which it reads from the node's files.
  • OTLP from the applications running on that node.
yaml
receivers:
  otlp:
    protocols:
      grpc: { endpoint: 0.0.0.0:4317 }
      http: { endpoint: 0.0.0.0:4318 }
  kubeletstats:                 # CPU, memory, network and disk of pods and containers
    collection_interval: 30s
    auth_type: serviceAccount
    endpoint: "https://${env:K8S_NODE_NAME}:10250"
    insecure_skip_verify: true  # the kubelet certificate is usually self-signed
  filelog:                      # logs from every container on the node
    include: [/var/log/pods/*/*/*.log]
    include_file_path: true
    operators:
      - type: container         # understands the containerd, CRI-O and Docker formats

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20
  k8sattributes:                # adds namespace, pod, workload and node to every item
    filter:
      node_from_env_var: K8S_NODE_NAME
    extract:
      metadata:
        - k8s.namespace.name
        - k8s.pod.name
        - k8s.pod.uid
        - k8s.deployment.name
        - k8s.statefulset.name
        - k8s.daemonset.name
        - k8s.node.name
    pod_association:
      - sources: [{ from: resource_attribute, name: k8s.pod.uid }]
      - sources: [{ from: connection }]
  batch: {}

exporters:
  otlphttp:
    endpoint: https://ingest.oneglass.io
    headers:
      Authorization: "Api-Token ${env:ONEGLASS_INGEST_KEY}"
      X-Tenant-ID: "${env:ONEGLASS_TENANT_ID}"

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

For this to work, the Collector pod needs three things in its manifest: the K8S_NODE_NAME variable taken from spec.nodeName, the node's /var/log/pods directory mounted read-only, and a service account with permission to read pods, namespaces and node stats.

One Collector for the cluster (single-replica Deployment)

It collects what exists once for the whole cluster: object state and events.

yaml
receivers:
  k8s_cluster:                  # desired and available replicas, pod phases, node status
    collection_interval: 30s
  k8sobjects:                   # Kubernetes events, as logs
    objects:
      - name: events
        mode: watch

It must be a single replica. If these receivers run in the DaemonSet, every node reports the whole cluster and the data arrives multiplied by the number of nodes.

The attributes that tie it all together

The k8sattributes processor is the piece that makes Kubernetes observability work. It adds the namespace, pod, workload and node to every trace, metric and log it came from. With that, you can go from a slow trace to the pod that served it, from there to its memory usage, and from there to the node.

Use the semantic convention names (k8s.namespace.name, k8s.pod.name, k8s.deployment.name, k8s.node.name) and add k8s.cluster.name by hand if you have more than one cluster: Kubernetes doesn't know what it's called.

Instrumenting the applications

Applications send OTLP to the Collector on their own node. The address comes from the node's IP, which the pod receives as an environment variable:

yaml
env:
  - name: NODE_IP
    valueFrom:
      fieldRef: { fieldPath: status.hostIP }
  - name: OTEL_EXPORTER_OTLP_ENDPOINT
    value: "http://$(NODE_IP):4318"
  - name: OTEL_SERVICE_NAME
    value: "checkout-api"

If you don't want to touch every image, the OpenTelemetry Operator injects auto-instrumentation with an annotation on the pod, for Java, .NET, Python, Node.js and Go.

What to look at first

  • Container restarts and their reason. OOMKilled means out of memory: the limit is too low or there's a leak.
  • Pending pods. Kubernetes can't find a place to put them: resources are short or a rule isn't being met.
  • Available vs. desired replicas for each Deployment.
  • Usage against requests and limits. A container pinned at its CPU limit gets throttled without any warning; one that requests far more than it uses wastes node capacity.
  • Cluster events, which explain almost everything above in plain words: an image that won't pull, a failing probe, a node out of disk.

Common mistakes

  • Running the cluster receivers in the DaemonSet. Duplicated data, once per node.
  • Forgetting permissions. Without RBAC, k8sattributes adds nothing and shows no visible error: the data arrives, but without namespace or pod.
  • Not setting limits on the Collector itself. It's just another pod; with no memory limit and no memory_limiter, it can affect the node it's supposed to observe.
  • Letting the Collector read its own logs unchecked. If it logs an error for every line it processes, it feeds itself. Exclude its files or lower its log level.
  • Not naming the cluster. With two clusters and no k8s.cluster.name, namespaces with the same name get mixed together.

With OneGlass

OneGlass is an observability platform built natively on OpenTelemetry, made in Argentina. For Kubernetes it provides a manifest bundle that installs everything in this guide: node and cluster telemetry, plus an OTLP gateway inside the cluster for your applications. The Kubernetes view is built from that standard data, from the cluster down to the container, and the Optimized view compares what each workload reserves with what it uses.