Exclude filesystem metrics by device name
Currently there seems to be no easy way to exclude /dev/loop0 from being scraped
Can any one of these solve your problem?
-
--collector.diskstats.device-exclude -
--collector.filesystem.fs-types-exclude -
--collector.filesystem.mount-points-exclude
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
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.
Good call, the filesystem collector does not have device name filtering. This should be easy to implement.
@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
PRs welcome!
If this is the desired approach, I'm wondering if device-exclude might be better as a completely generic option?
I think we want to stick with per-collector flags.
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 .
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..