prometheus / prometheus/node_exporter

Number of PIDs is wrong

Open
#2,371 2 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

Host operating system: output of uname -a

Linux localhost.localdomain 5.14.0-22.el9.x86_64 #1 SMP Fri Nov 26 23:47:21 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

node_exporter version: output of node_exporter --version

node_exporter, version 1.3.1 (branch: HEAD, revision: a2321e7b940ddcff26873612bccdf7cd4c42b6b6)
build user: root@243aafa5525c
build date: 20211205-11:09:49
go version: go1.17.3
platform: linux/amd64

node_exporter command line flags

./node_exporter --collector.processes

Are you running node_exporter in Docker?

No

What did you do that produced an error?

curl http://localhost:9100/metrics

What did you expect to see?
# HELP node_processes_pids Number of PIDs
# TYPE node_processes_pids gauge
node_processes_pids 241
# HELP node_processes_threads Allocated threads in system
# TYPE node_processes_threads gauge
node_processes_threads 241
What did you see instead?
# HELP node_processes_pids Number of PIDs
# TYPE node_processes_pids gauge
node_processes_pids 121
# HELP node_processes_threads Allocated threads in system
# TYPE node_processes_threads gauge
node_processes_threads 241

https://github.com/prometheus/node_exporter/blob/da8b0f694ceadd3013096f6e8671cdd70a98da24/collector/processes_linux.go#L112

Value of Number of PIDs get from number of process. It is wrong at linux system, because each thread allocate one pid. not each process.
We can fix it and provide one more "Number of Process"
Number of PIDs = threads
Number of Process = pids

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 in collector/processes_linux.go around line 112 and reproduce the reported metrics with --collector.processes and a request to /metrics. Check the Linux distinction between process IDs and thread IDs, then ensure the exported metrics use the intended meanings. Done means the PID and process counts are correct and the existing thread count remains accurate.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.