Repository navigation
Description
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_threadstoclusterMetrics.cadvisor.metricsTuning.includeMetricsink8s/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
devops-cli-service commentedon Nov 19, 2026
Both use the container_threads metric for runner pods. #6342 ensures the series exists; the candidate reads the 7-day peak to set pod-max-pids.devops-cli-service commentedon Nov 19, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
dan-petty commentedon Nov 21, 2026
The peak query of the acceptance criteria counts each thread two times.
cAdvisor gives a
container_threadsseries for the pod cgroup (emptycontainerandimagelabels), one for the pod sandbox, and one for each container. The pod cgroup series is the sum of the others. Sosum 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-pidslimits: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).
dan-petty commentedon Nov 22, 2026
Query note from the build of #6342 (PR #6711), for the peak of one runner pod after 7 days:
max by (namespace, pod) (max_over_time(container_threads{namespace="<runner namespace>", container="", image="", pod!=""}[7d])). The series withcontainer=""andimage=""is the pod cgroup, which already holds all its containers, so asum by (pod)over every series counts each thread more than once.count(container_threads)should be about 329 series, about one for each container and pod cgroup on the cluster today.dan-petty commentedon Nov 23, 2026
PR #6711 (349adda) added
container_threadsandcontainer_threads_maxtok8s/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.