node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Request for Btrfs device stats collection

Open kennethjor opened this issue 4 years ago • 4 comments

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.

kennethjor avatar Oct 21 '21 04:10 kennethjor

It was: https://github.com/prometheus/node_exporter/blob/master/collector/btrfs_linux.go

discordianfish avatar Oct 21 '21 09:10 discordianfish

@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

kennethjor avatar Oct 21 '21 11:10 kennethjor

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

kennethjor avatar Oct 25 '21 06:10 kennethjor

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).

hhoffstaette avatar Nov 03 '21 12:11 hhoffstaette

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!

leth avatar Oct 07 '22 19:10 leth

Great, I think we can close this then and re-open if something is missing!

discordianfish avatar Oct 11 '22 12:10 discordianfish