Skip to content

Add per-process schedstat metrics collector #3674

@Luffy-nani

Description

@Luffy-nani

Feature Request

Currently, the schedstat collector only exports system-wide per-CPU metrics from /proc/schedstat.

However, /proc/[pid]/schedstat exposes per-process scheduler statistics:

  • Running time in nanoseconds
  • Waiting time in nanoseconds
  • Number of timeslices

The procfs library already has ProcSchedstat struct that parses this file, so no new parsing code is needed.

Proposal

Add an opt-in per-process schedstat collector (defaultDisabled, similar to the existing processes collector) that exports:

  • node_schedstat_process_running_seconds_total{pid, comm}
  • node_schedstat_process_waiting_seconds_total{pid, comm}
  • node_schedstat_process_timeslices_total{pid, comm}

Implementation

Would follow the same pattern as collector/processes_linux.go — iterate AllProcs(), call pid.Schedstat() per process, export metrics labeled with pid and comm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions