prometheus / prometheus/node_exporter

Add per-process schedstat metrics collector

Open
#3,674 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
13.8k
Forks
2.7k
Avg merge
1d 23h
Merged PRs (30d)
8

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with collector/processes_linux.go and the procfs ProcSchedstat struct, then trace how AllProcs() and per-process Schedstat() are used. Implement the opt-in, default-disabled collector and verify that it exports running time, waiting time, and timeslices with pid and comm labels in the specified metric names.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.