Skip to content

feat(monitoring): keep the cAdvisor container_threads series - #6711

Merged
dan-petty merged 4 commits into
mainfrom
feat/6342-keep-container-threads
Nov 22, 2026
Merged

dan-petty merged 4 commits into
mainfrom
feat/6342-keep-container-threads

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Prometheus keeps the cAdvisor series container_threads and container_threads_max, the thread count and thread limit of each cgroup. dan-petty/homelab#44 needs the peak thread count of a runner pod to set pod-max-pids.

  • includeMetrics of clusterMetrics.cadvisor lists the two metrics. In the helm template output of chart 4.6.1, only the cadvisor keep regex changes.
  • The chart drops no thread series with an empty container label, so the series of each pod cgroup stays. It counts each thread of the pod, as the pids cgroup does.
  • The Process IDs rule of the Kubernetes guideline names that series.

Series cost: on 2026-11-21 the 4 nodes whose cAdvisor target was up served 329 series of each metric (113 containers, 98 sandboxes, 98 pod cgroups, 20 host cgroups). The change adds about 658 series, about 1 % of the 64,476 head series.

Closes #6342

Change: openspec/changes/archive/2026-11-21-6342-keep-container-threads/

@dan-petty dan-petty added type/feature Type feature: a new function scope/monitoring Grafana, Prometheus, Loki, alerts and dashboards labels Nov 21, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Follow-up steps and review points for #6342.

After the merge (not done yet: it needs the merge)

  • The live k8s-monitoring Application reads k8s/monitoring/k8s-monitoring-values.yaml from main of this repository, with automated sync. Its last synced revision is 671f241. So Argo CD applies the change after the merge, and Alloy loads the new keep rule.
  • Proof of acceptance criterion 1: devops prometheus query 'count(container_threads)' gives about 329, and count(container_threads{namespace="<runner namespace>", container!=""}) gives a series while a runner pod runs. Give the count in a comment on feat(monitoring): keep the cAdvisor container_threads series #6342.
  • Follow-up in dan-petty/homelab: copy the file with make k8s-parity. This PR does not change homelab.
  • feat(monitoring): measure the peak thread count of a runner pod #6392 reads the 7-day peak. The query in the issue (sum by (namespace, pod) (container_threads{...})) counts each thread two times. Use the pod cgroup series: max by (namespace, pod) (max_over_time(container_threads{namespace="<runner namespace>", container="", image="", pod!=""}[7d])). I put this on feat(monitoring): measure the peak thread count of a runner pod #6392.

Review points

  • The scrape interval is 60 s. The peak is the largest sample, so a burst shorter than one interval can be higher. Add a margin to the limit.
  • container_threads_max today: each pod cgroup gives 0 (no limit). Each container cgroup gives 15 % of the kernel threads-max of its node (37,914 to 76,768 on the 4 nodes), which agrees with the systemd DefaultTasksMax.
  • The change keeps the 20 host cgroup series of each metric (root, kubepods, system.slice). A drop rule of the project would save little. The design of the change records this.
  • One node, cordoned since 2026-11-06, is unreachable since 2026-11-19, so its cAdvisor target is down. Its series come back when the node returns. I recorded this on fix(k8s): test the hawk hardware and record the cause of its crashes #5143.
  • Proof before the merge: helm template k8s-monitoring k8s-monitoring --repo https://grafana.github.io/helm-charts --version 4.6.1 -n monitoring -f k8s/monitoring/k8s-monitoring-values.yaml | grep -c 'container_threads|container_threads_max' gives 0 on the base and 1 on the branch. No test reads the value (owner rule of 2026-11-16).

@dan-petty
dan-petty marked this pull request as ready for review November 22, 2026 00:36
@dan-petty
dan-petty merged commit 349adda into main Nov 22, 2026
28 checks passed
@dan-petty
dan-petty deleted the feat/6342-keep-container-threads branch November 22, 2026 00:48
dan-petty-release Bot added a commit that referenced this pull request Nov 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.191.0](v0.190.0...v0.191.0)
(2026-11-22)


### Features

* **infra:** add node drain, uncordon, restart and reboot
([#6706](#6706))
([8af846c](8af846c)),
closes [#5128](#5128)
* **monitoring:** keep the cAdvisor container_threads series
([#6711](#6711))
([349adda](349adda))


### Bug Fixes

* **ci:** check release image job times in devops ci job-time
([#6635](#6635))
([1b1a25e](1b1a25e))
* **k8s:** narrow the in-namespace egress of the object store
([#6712](#6712))
([f14cb8b](f14cb8b)),
closes [#6707](#6707)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/monitoring Grafana, Prometheus, Loki, alerts and dashboards type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(monitoring): keep the cAdvisor container_threads series

1 participant