node_exporter
node_exporter copied to clipboard
Request for Btrfs device stats collection
I don't see stats from the btrfs device stats command in my metrics. I see a closed ticket #1100 already exists for this, but can't immediately find anything about this in the code either. So I'm wondering if it was ever implemented?
Host operating system:
Linux klaatu 5.8.0-63-generic #71-Ubuntu SMP Tue Jul 13 15:59:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
node_exporter version:
node_exporter, version 1.2.2 (branch: HEAD, revision: 26645363b486e12be40af7ce4fc91e731a33104e)
build user: root@b9cb4aa2eb17
build date: 20210806-13:44:18
go version: go1.16.7
platform: linux/amd64
node_exporter command line flags
/usr/local/bin/node_exporter --collector.systemd --collector.textfile --collector.textfile.directory=/var/lib/node_exporter --web.listen-address=0.0.0.0:9102 --web.telemetry-path=/metrics
Are you running node_exporter in Docker?
Not Docker, deployed with Ansible.
It was: https://github.com/prometheus/node_exporter/blob/master/collector/btrfs_linux.go
@discordianfish Has it not just been released then, or are the metrics renamed somewhere? The output of the command is something like
[/dev/sda].write_io_errs 0
[/dev/sda].read_io_errs 0
[/dev/sda].flush_io_errs 0
[/dev/sda].corruption_errs 0
[/dev/sda].generation_errs 0
[/dev/sdb].write_io_errs 0
[/dev/sdb].read_io_errs 0
[/dev/sdb].flush_io_errs 0
[/dev/sdb].corruption_errs 0
[/dev/sdb].generation_errs 0
[/dev/sdc].write_io_errs 0
[/dev/sdc].read_io_errs 0
[/dev/sdc].flush_io_errs 0
[/dev/sdc].corruption_errs 0
[/dev/sdc].generation_errs 0
[/dev/sdd].write_io_errs 186
[/dev/sdd].read_io_errs 91
[/dev/sdd].flush_io_errs 0
[/dev/sdd].corruption_errs 4
[/dev/sdd].generation_errs 0
For anyone else interested in this, there's a textile collector script that does this at https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/blob/master/btrfs_stats.py
The existing collector in node_exporter (as mentioned) does not export device stats/errors, due to the requirement of using ioctls ~~and requring root~~. The script in the -community repo was a quick hack, which kind of works but has several problems. A much better collector for the device stats is here. Note that as of linux-5.14 btrfs will export the device stats to sysfs (commit) so the existing Go-based collector in node_exporter can and should be extended (probably via node_exporter/procfs).
I'm happy to report that this was added in #2193 and was released in 1.4.0 / 2022-09-24 😄 Please let me know if you find any issues!
Great, I think we can close this then and re-open if something is missing!