ncabatoff / process-exporter

Prometheus exporter that mines /proc to report on selected processes
MIT License
1.67k stars 265 forks source link

Specifying threads flag in front of config flag causes the config to be ignored #278

Closed hartfordfive closed 1 year ago

hartfordfive commented 1 year ago

For some reason, it appears that specifying the -threads false flag prior to the -config.path flag causes the config to be ignored. For example:

[web@web1~]# /opt/third/process_exporter/0.7.10/bin/process-exporter -threads false -config.path /etc/process-exporter/config.yml -web.listen-addres
s "0.0.0.0:9257"
2023/08/02 23:18:27 Reading metrics from /proc for procnames: []

whereas having it at the end of the config doesn't cause an issue.

[web@web1~]# /opt/third/process_exporter/0.7.10/bin/process-exporter -config.path /etc/process-exporter/config.yml -web.listen-address "0.0.0.0:9257" -threads false
2023/08/02 23:22:16 Reading metrics from /proc based on "/etc/process-exporter/config.yml"
hartfordfive commented 1 year ago

I've actually figured out the problem. As the flag is a boolean type, it's necessary to concatenate the flag name and the value with the = sign. So going from this:

-threads false

to this:

-threads=false

solves the problem.

This is also confirmed in the documentation for the flag package, which states:

You must use the -flag=false form to turn off a boolean flag.