node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Number of PIDs is wrong

Open xixiliguo opened this issue 3 years ago • 2 comments

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

xixiliguo avatar May 09 '22 12:05 xixiliguo

The metric is correct as-is, in this case node_processes_pids is already "Number of Processes". The documentation in the help string is just a bit misleading/confusing.

SuperQ avatar May 09 '22 12:05 SuperQ

Can I create PR to change it to below ?

# HELP node_processes_max_processes Number of max process limit
# HELP node_processes_pids Number of Processes

one more thing, real max threads limit should equal min(threads-max, pid_max)

# HELP node_processes_max_threads Limit of threads in the system
# TYPE node_processes_max_threads gauge
node_processes_max_threads 61187

xixiliguo avatar May 09 '22 15:05 xixiliguo