ansible-node-exporter icon indicating copy to clipboard operation
ansible-node-exporter copied to clipboard

Quoting the collector parameter ignored-mount-points produces unwanted results

Open pja237 opened this issue 5 years ago • 1 comments

What happened?

Setting the filesystem collector parameter ignored-mount-points puts the value in quotes to the service file, which is fed verbatimly into regexp parser and makes the expression "useless".

Is there some way to work around this obstacle? (detailed description below)

Did you expect to see some different?

As per these two node exporter issues quoting the regexp in service file is a wrong thing to do:

https://github.com/prometheus/node_exporter/issues/911#issuecomment-429712534 https://github.com/prometheus/node_exporter/issues/1000#issuecomment-583202422

How to reproduce it (as minimally and precisely as possible):

Use the example from the defaults/main.yml file:

node_exporter_enabled_collectors:
- filesystem:
    ignored-mount-points: "^/(sys|proc|dev)($|/)"

Produces the .service file with execstart line:

ExecStart=/usr/local/bin/node_exporter \
--collector.textfile \
    --collector.textfile.directory=/opt/prometheus_data \
--collector.filesystem \
    --collector.filesystem.ignored-mount-points='^/(sys|proc|dev)($|/)' \
    --web.listen-address=0.0.0.0:9100

Result:

# curl -s localhost:9100/metrics|grep 'mountpoint="/sys'
node_filesystem_avail_bytes{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 9.0760503296e+10
node_filesystem_device_error{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 0
node_filesystem_files{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 2.2158326e+07
node_filesystem_files_free{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 2.215831e+07
node_filesystem_free_bytes{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 9.0760503296e+10
node_filesystem_readonly{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 1
node_filesystem_size_bytes{device="tmpfs",fstype="tmpfs",mountpoint="/sys/fs/cgroup"} 9.0760503296e+10

If the quotes are manually removed from the switch line:

--collector.filesystem.ignored-mount-points=^/(sys|proc|dev)($|/) \

then the result is as expected (mountpoint is ignored):

# systemctl daemon-reload
# systemctl restart node_exporter.service
# curl -s localhost:9100/metrics|grep 'mountpoint="/sys'
#
  • Role version:

    version: 0.21.5

  • Ansible version information:

ansible --version
ansible 2.8.2
  config file = /root/src/clip-hpc/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/src/clip-hpc-venv/lib/python3.6/site-packages/ansible
  executable location = /root/src/clip-hpc-venv/bin/ansible
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

pja237 avatar Aug 12 '20 14:08 pja237

Seems like a fix would be to always quote with double quotes and not single ones. Unquoted regex can also lead to unexpected issues as mentioned in https://github.com/cloudalchemy/ansible-node-exporter/pull/144

paulfantom avatar Dec 10 '20 10:12 paulfantom

This role has been deprecated in favor of a the prometheus-community/ansible collection.

SuperQ avatar Mar 06 '23 14:03 SuperQ