node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Exclude filesystem metrics by device name

Open laurivosandi opened this issue 4 months ago • 10 comments

Currently there seems to be no easy way to exclude /dev/loop0 from being scraped

laurivosandi avatar Sep 04 '25 08:09 laurivosandi

Can any one of these solve your problem?

  • --collector.diskstats.device-exclude
  • --collector.filesystem.fs-types-exclude
  • --collector.filesystem.mount-points-exclude

eugercek avatar Sep 17 '25 18:09 eugercek

First one excludes disk stats but it still shows up under filesystems:

node_filesystem_purgeable_bytes{device="/dev/loop21",device_error="",fstype="ext4",mountpoint="/mnt/test"} 0

Filesystem exclusion doesn't help as it's ext4 and I have mountpoints all across the filesystem

laurivosandi avatar Sep 18 '25 03:09 laurivosandi

Try this in your metric_relabel_configs:

 - source_labels: [device]
   regex: '/dev/loop[0-9]+'
   action: drop

It will still scrape but will be dropped before it hits the db.

This config will drop any metric that satisfies that condition - recommend testing to ensure it has the desired effect and doesn't drop things you want to keep.

https://relabeler.promlabs.com/ is handy for this kind of thing.

breca avatar Oct 24 '25 01:10 breca

Good call, the filesystem collector does not have device name filtering. This should be easy to implement.

SuperQ avatar Oct 24 '25 05:10 SuperQ

@breca I would like to keep Prom config as clean as possible

I would advise either adding --collector.filesystem.device-exclude or generalizing device-exclude so it works for both diskstats and filesystems both

laurivosandi avatar Oct 24 '25 05:10 laurivosandi

PRs welcome!

SuperQ avatar Oct 24 '25 06:10 SuperQ

If this is the desired approach, I'm wondering if device-exclude might be better as a completely generic option?

breca avatar Oct 24 '25 08:10 breca

I think we want to stick with per-collector flags.

SuperQ avatar Oct 24 '25 08:10 SuperQ

Just to reflect on https://github.com/prometheus/node_exporter/pull/3384 , I think file system uuid based filtering would provide a consistent solution even if things like loop devices are re-created under a different index/name . Traditional Linux device naming like /dev/sda, /dev/sdb, /dev/sdc, etc. is not guaranteed to be predictable either. File system labels are not mandatory either but uuid will be there in a persistent fashion. I can't really see a situation where the combinations of mountpoint, fs type and fs uuid would not be sufficient to exclude a mounted device .

Rozzii avatar Nov 12 '25 10:11 Rozzii

I'd also feel we should rather support uuid (and maybe labels - certainly useful to have human readable identifiers for old school sysops where you don't generate the filters from some config mgmt system etc) than device names.. Not oppose to have all three but we should be clear that this is the final set of identifiers we want to support because otherwise this opens a can of worms..

discordianfish avatar Nov 12 '25 16:11 discordianfish