Skip to content

feat(monitoring): keep the cAdvisor container_threads series #6342

Closed

Description

@dan-petty

Problem or Motivation

Prometheus has no per-container thread series, so nobody can measure the peak thread count of one runner pod. dan-petty/homelab#44 needs that peak to set a per-pod PID limit on the kubelet (pod-max-pids). A guessed limit can kill a runner step. The pids cgroup counts each thread, so the measure is container_threads, not container_processes.

Evidence (https://github.com/dan-petty/homelab/issues/44#issuecomment-6993672688, 2026-11-18):

  • container_threads, container_processes and container_threads_max give no series in the last 30 days. The only process series are per node (node_processes_pids, node_processes_threads).
  • Cause: Alloy keeps only the 11 cAdvisor metrics of clusterMetrics.cadvisor.metricsTuning.includeMetrics in k8s/monitoring/k8s-monitoring-values.yaml:43.
  • The kubelet exposes the metrics: the cAdvisor endpoint of a node (/api/v1/nodes/<node>/proxy/metrics/cadvisor) lists container_threads, container_processes and container_threads_max.
  • homelab copies this file from devops-cli (make k8s-parity), so the change starts in devops-cli.

Proposed Solution & Architectural Design

  1. Add container_threads to the includeMetrics list. Consider container_threads_max too: it gives the limit that applies to each container.
  2. After the sync, record the number of new series (count(container_threads)), about one for each container.
  3. After 7 days, give the peak of one runner pod to homelab#44, for example max_over_time(sum by (namespace, pod) (container_threads{namespace="<runner namespace>"})[7d:5m]).

Target Subsystem

Monitoring (k8s/monitoring/).

Existing Tool Considered

The cAdvisor metrics of the kubelet, which Alloy scrapes already. No new tool.

Acceptance Criteria

  • After the sync, container_threads has series for the runner pods (a PromQL query proves it).
  • The comment of the item gives the series count, and after 7 days the peak thread count of one runner pod.

Source: https://github.com/dan-petty/homelab/issues/44#issuecomment-6993672688

Alternatives check of 2026-11-19: in-use.
The repository already uses this tool.
Tool: google/cadvisor (https://github.com/google/cadvisor), NOASSERTION, last activity 2026-11-18, maintained.
Reason: The searches found no other maintained tool with per-container thread counts; the kubelet's cAdvisor, which the issue names as already scraped by Alloy, exposes container_threads and container_threads_max, so only the includeMetrics filter blocks the series.

Covers:

  • Per-container thread count series container_threads
  • Per-container thread/PID limit via container_threads_max
  • Metrics served on the kubelet cAdvisor endpoint

Lacks:

  • Series are dropped unless Alloy includeMetrics lists them
  • No peak-over-time; needs PromQL max_over_time
  • No per-thread or per-process detail beyond counts

Proposed design

Problem statement

Prometheus has no per-container thread series. Alloy keeps only the 11 cAdvisor metrics that clusterMetrics.cadvisor.metricsTuning.includeMetrics lists in k8s/monitoring/k8s-monitoring-values.yaml:43. homelab#44 needs the peak thread count of one runner pod to set pod-max-pids. The pids cgroup counts each thread. The change adds container_threads and container_threads_max to that list. homelab copies the file from devops-cli with make k8s-parity, so the change starts here.

Acceptance criteria

Requirement: cAdvisor thread metrics are kept

The cAdvisor metricsTuning.includeMetrics list in k8s/monitoring/k8s-monitoring-values.yaml SHALL include container_threads and container_threads_max.

Scenario: k8s manifest check

  • WHEN uv run devops ci --check --only k8s runs on the branch
  • THEN the command reports success with no error

Existing Tool Considered

google/cadvisor (https://github.com/google/cadvisor), verdict in-use. The alternatives check of 2026-11-19 in the issue body gives the reason and lists what the tool covers and lacks. The proposal answers the lack that blocks the series: it adds container_threads and container_threads_max to the cAdvisor includeMetrics list, so Alloy keeps their series. No new tool is needed.

Key questions

  • Does an open, maintained tool cover the per-container thread count?: Yes. google/cadvisor is already in use. The alternatives check of 2026-11-19 in the issue body gives the verdict in-use. Alloy already scrapes the kubelet cAdvisor endpoint. [sources: k8s/monitoring/k8s-monitoring-values.yaml:43]
  • Which cAdvisor metrics does the change add to the includeMetrics list?: Add container_threads and container_threads_max to the cAdvisor includeMetrics list at k8s/monitoring/k8s-monitoring-values.yaml:43. (best practice) [sources: k8s/monitoring/k8s-monitoring-values.yaml:43]
    • Chosen: Both container_threads and container_threads_max. The pod-max-pids decision needs the observed peak and the current per-container limit. The alternatives check covers both. Each adds one series per container.
    • Rejected: Only container_threads. It gives the observed peak but not the current per-container limit that the pod-max-pids decision needs.
    • Rejected: Only container_threads_max. It gives the limit but not the observed thread count that the issue needs.
  • Which file and list hold the cAdvisor includeMetrics filter?: k8s/monitoring/k8s-monitoring-values.yaml:43 holds the cAdvisor includeMetrics list. Line 60 holds the KSM list. The change does not touch the KSM list. [sources: k8s/monitoring/k8s-monitoring-values.yaml:43, k8s/monitoring/k8s-monitoring-values.yaml:60]
  • How is the manifest change proven offline, and where does the 7-day peak go?: uv run devops ci --check --only k8s validates the k8s tree. The series count and the 7-day peak wait on the homelab sync and a 7-day window. They are deferred to a new issue. (best practice) [sources: k8s/monitoring/k8s-monitoring-values.yaml:43]
    • Chosen: k8s check plus a deferred measurement. The manifest change needs no cluster. The measurement waits on an outside sync and a date, so it cannot gate this pull request.
    • Rejected: Live PromQL check in this pull request. It waits on the homelab sync and a 7-day window, which are outside this repository.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#6392

Activity

  1. added
    type/feature
    source/agent
    status/new
    value/medium
    effort/low
    scope/monitoring
    on Nov 18, 2026
  2. dan-petty commented on Nov 18, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 18, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (4)

    Tools considered:

    Searches run:

    • Prometheus per-container thread count metric cAdvisor container_threads, results: 5
    • open source tool measure per-pod thread count Prometheus kubernetes pids, results: 5
    • cadvisor container_threads metric container_threads_max kubelet cadvisor metrics list, results: 5
    • github google/cadvisor docs storage prometheus metrics container_threads, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 21, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 22, 2026
  9. dan-petty commented on Nov 22, 2026

    @dan-petty
    OwnerAuthor

    After the merge of #6711 and the sync (2026-11-22 01:20 UTC): count(container_threads) gives 329 series, as expected, and the runner pods have series. The 7 days of data for #6392 start now, so its peak query can run on 2026-11-29 (the query in the comment on #6392).

  10. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-22 01:30 UTC

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