Skip to content

feat(monitoring): measure the peak thread count of a runner pod #6392

Closed as not planned

Description

@devops-cli-service

Split from #6342.

The cAdvisor container_threads series gives the current thread count of each container. homelab#44 needs the peak thread count of one runner pod over 7 days to set the kubelet pod-max-pids . The measurement is deferred for two reasons. homelab copies k8s/monitoring/k8s-monitoring-values.yaml from devops-cli with make k8s-parity, and Argo CD syncs the change. The peak then needs a 7-day observation window. Neither event is part of this repository's change. Acceptance criteria: - After the sync, count(container_threads) shows at least one series for each runner container. - After 7 days, `max_over_time(sum by (namespace, pod) (container_threads{namespace=

Proposed design

Problem statement

The cAdvisor container_threads series is absent from the cAdvisor keep list in k8s/monitoring/k8s-monitoring-values.yaml. The runner pods therefore send no thread series to Prometheus, and homelab#44 cannot measure the peak thread count. This item adds the metric to the chart. The 7-day peak measurement waits on the homelab copy, the Argo CD sync and the observation window, so it is deferred.

Acceptance criteria

Requirement: The cAdvisor keep list includes container threads

The Kubernetes monitoring values MUST include container_threads in the cAdvisor includeMetrics list.

Scenario: Kubernetes monitoring values pass the k8s check

  • WHEN I run uv run devops ci --check --only k8s.
  • THEN The command exits 0 and reports no error for k8s/monitoring/k8s-monitoring-values.yaml.

Existing Tool Considered

No alternatives check has run. The need is covered by the cAdvisor metric container_threads, collected through the open Grafana Kubernetes Monitoring Helm chart and queried in Prometheus. The chart's clusterMetrics.cadvisor.metricsTuning.includeMetrics list in k8s/monitoring/k8s-monitoring-values.yaml lacks the metric, so the item adds one entry. The chart does not report a 7-day peak by itself; the deferred item uses a PromQL query for that.

Key questions

  • Which collection path adds the cAdvisor thread metric to the monitoring stack?: Add container_threads to clusterMetrics.cadvisor.metricsTuning.includeMetrics in k8s/monitoring/k8s-monitoring-values.yaml. The chart then keeps the cAdvisor series and sends it to Prometheus. (best practice) [sources: k8s/monitoring/k8s-monitoring-values.yaml]
    • Chosen: Add the metric to the chart cAdvisor include list. The chart already selects cAdvisor metrics; one entry is the smallest change.
    • Rejected: Add a separate Prometheus scrape job. It duplicates cAdvisor discovery and adds configuration to keep.
    • Rejected: Build a custom exporter. The cAdvisor metric already exists; an exporter adds code and maintenance.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    source/agent
    status/new
    value/medium
    effort/low
    scope/monitoring
    on Nov 19, 2026
  2. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor
  3. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  4. dan-petty commented on Nov 21, 2026

    @dan-petty
    Owner

    The peak query of the acceptance criteria counts each thread two times.

    cAdvisor gives a container_threads series for the pod cgroup (empty container and image labels), one for the pod sandbox, and one for each container. The pod cgroup series is the sum of the others. So sum by (namespace, pod) (container_threads{...}) gives two times the thread count of the pod. Evidence of 2026-11-21, from the kubelet cAdvisor endpoint of a node, for one pod with two containers: pod cgroup 22, sandbox 1, containers 8 and 13.

    Use the pod cgroup series. It counts what pod-max-pids limits:

    max by (namespace, pod) (max_over_time(container_threads{namespace="<runner namespace>", container="", image="", pod!=""}[7d]))

    The scrape interval is 60 s, so the result is the largest sample. A burst shorter than one interval can be higher.

    Found while building #6342 (PR #6711).

  5. dan-petty commented on Nov 22, 2026

    @dan-petty
    Owner

    Query note from the build of #6342 (PR #6711), for the peak of one runner pod after 7 days:

    • Use max by (namespace, pod) (max_over_time(container_threads{namespace="<runner namespace>", container="", image="", pod!=""}[7d])). The series with container="" and image="" is the pod cgroup, which already holds all its containers, so a sum by (pod) over every series counts each thread more than once.
    • The scrape interval is 60 s, so a thread burst shorter than one interval does not show. Give the result as the peak of the scraped samples.
    • After the sync of feat(monitoring): keep the cAdvisor container_threads series #6711, count(container_threads) should be about 329 series, about one for each container and pod cgroup on the cluster today.
  6. dan-petty commented on Nov 23, 2026

    @dan-petty
    Owner

    PR #6711 (349adda) added container_threads and container_threads_max to k8s/monitoring/k8s-monitoring-values.yaml. This resolved the manifest change.

    The live measurement occurs on the cluster over 7 days. Issue dan-petty/homelab#44 tracks that measurement. This repository requires no more code changes.

  7. removed
    status/new
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/monitoringsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions