Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Datadog Engineering 12 min read Case study mediumAdept

Our journey taking Kubernetes state metrics to the next level

Datadog's Containers team made kube-state-metrics usable as a library: an upstream PR made the KSM Builder extensible so the MetricStore could be swapped out, with neutral-to-slightly-better benchmark results. Embedding KSM's informers directly in the Datadog Agent as a long-running Go core check, run on Cluster Check Runners or the Cluster Agent, removed the costly crawl of the /metrics endpoint. Large clusters had been producing millions of metrics every 15 seconds, and this change cut collection time 15x and halved memory and CPU footprint. It also required extending the Agent collector's interface to support long-lived check threads.

Assumes: Kubernetes informersPrometheus/OpenMetrics formatGo

Related posts

  • How we scaled metrics aggregation by moving durable state into storage

    Datadog Engineering mediumAdept

    Datadog's metrics aggregation service, which merges DDSketch distributions to reduce tag dimensions, went through three generations as volume grew roughly 10× each time. Static leader-follower partitions with local RocksDB doubled compute and needed manual partition splits. Dynamic Kafka assignment with incremental SSTable snapshots to blob storage and time-windowed lazy restore improved recovery and enabled autoscaling, but state recovery then became the bottleneck. The third generation makes streaming aggregation and deduplication best-effort. Both storage tiers reconcile partial aggregates, duplicates and late data during reads and compaction, so workers can restart at the live edge without restoring hours of state and can be provisioned for current traffic.

  • Scaling down to speed up: How we improved efficiency of live process metrics by 100x

    Datadog Engineering mediumAdept

    Datadog cut real-time process and container metric traffic by about 100x by enabling 2-second live collection only on hosts whose processes a user is actually viewing (at most 50 per user), instead of on every host in the tenant. Sorting switched to the existing 10-second data, which removed the need to hold all live metrics in a single server's memory. Host subscriptions are published over Kafka at 1-second intervals to the intake service, which keeps a TTL-based in-memory cache of viewed hosts. Peak volume fell from 500,000 to 5,000 messages per second, the live data service shrank by about 98% (over 600 cores and 1 TiB of memory freed), and Agent CPU usage dropped about 2%.

  • Kubernetes v1.36: PSI Metrics for Kubernetes Graduates to GA

    Kubernetes Blog mediumAdept

    Pressure Stall Information (PSI) metrics in the kubelet are generally available in Kubernetes v1.36, exposing CPU, memory and I/O stall time at node, pod and container level with no feature gate needed. SIG Node measured overhead on 4-core nodes running 80+ pods: kubelet collection was indistinguishable from baseline, and kernel PSI tracking cost roughly 0.04–0.125 cores (about 1–3% of the node), with one brief spike to 0.225 cores. Since beta, the kubelet checks cgroup configuration for OS-level PSI support and no longer emits misleading zero values on nodes booted with psi=0. Using the metrics requires Linux 4.20+, cgroup v2 and CONFIG_PSI; they are scraped from /metrics/cadvisor or read via the Summary API.

  • Open sourcing kubenetmon: how we monitor data transfer in ClickHouse Cloud

    ClickHouse mediumAdept

    kubenetmon, now open source, is ClickHouse Cloud's in-house tool for monitoring data transfer across many Kubernetes clusters on AWS, GCP and Azure. It scrapes Linux conntrack with netfilter accounting enabled and atomically resets the counters on each scrape, so every record is per-interval bytes and packets. Connections are then attributed to pods, workloads and availability zones for forensics, attribution and cost metering. Cilium Hubble, cloud provider flow logs, OpenCost-style cost tools, in-app ClickHouse tracking and third-party eBPF agents were rejected over missing volumetric context, cost, provider inconsistency, Prometheus cardinality, and risk from mixing eBPF stacks.

  • Node.js and the tale of worker threads

    Zalando Engineering mediumAdept

    A Node.js service using cluster mode called os.cpus().length inside a Kubernetes container, which returns the host's core count, not the pod's CPU allocation. On a 48-core node it forked 48 processes inside a 2GB pod. Each needed about 120MB, so the processes were killed under memory pressure and immediately re-forked by the exit handler, flooding a translation service with startup requests (1,000 to 20,000 rpm) and causing cancelled connections and read timeouts. The initial diagnosis of a retry feedback loop caused by process.exit() on fetch failure turned out to be wrong. The fix was to drop cluster mode and let Kubernetes handle scaling, and the incident motivated adding event-loop lag and other signals through an internal Node.js observability SDK.

The quest for software engineering knowledge.

Look:
Layout: