-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: collect mdraid metrics from sysfs instead of parsing /proc/mdstat #1085
Comments
I think we've talked about this in the past. I'm very much in favor of using We also would like to implement the parsing as a separate library, rather than put the code directly in the node_exporter like it is now. We have the Prometheus procfs library which is our catch-all for |
@SuperQ I forked prometheus/procfs recently, and had an initial poke around. My WIP is in https://github.com/dswarbrick/procfs/blob/mdraid-sysfs/sysfs/mdraid.go. The code is in its early stages - I intend to split up the function(s) a bit more. |
@dswarbrick I just noticed that the sync / check phase is not really covered by the node_exporter currently (which makes it hard to i.e. supress disk utilization alerts when a check is running) and I was about to start implementing this. Now I ran into this issue and your move to use sysfs as data source. Are you still pursuing this and would open a PR at some point? |
@frittentheke Sadly I let this slip off my radar for a long time. There was also some discussion over the "right" way to implement reading of a large number of sysfs files. I've seen some overly naive approaches fall flat on their face, especially when exact sysfs entries present can vary. I am not currently working on this, but still interested in the topic, and happy to collaborate with you. |
@dswarbrick I opened PR prometheus/procfs#321 and a corresponding one for the node exporter with #1810 |
@dswarbrick May you post a link to the discussion you had about the right way to read a large number of files in sysfs ? |
@jooola I don't have the exact link off the top of my head, but it mostly revolved around a couple of fragile approaches. One involved basically reading every file in a particular sysfs directory, and using the relevant values read from the files. This was suboptimal because a few files here and there are not world-readable, which of course resulted in errors. There are also some files that will return dangerously large amounts of data (think There are some collectors which read a predefined list of files, e.g. On a side note, possibly of interest to procfs / node_exporter in general, there was a new However, it seems like there is now more interest in using io_uring to read a large number of files with as few syscalls as possible. |
I also stumbled on those emails, really interesting. I also read about the idea to cache the file handler and re seek any necessary content for parsing. It uses more memory, but is way faster than opening/closing the desired file. But it might be dangerous, I don't know enough on this topic to say more. |
It would be so much easier if the kernel just had a proper metrics interface. |
@dswarbrick Do you mind if I pick up your current code and try to work on it ? What is missing ? Should it have feature equality with the current /proc/mdstat parser ? |
@jooola The kernel md admin guide describes how many of the md-related sysfs (and I have no objection to you picking up my code and continuing with it. Sadly I just haven't had the time to dedicate to this, with everything else on my radar most of the time. If it's going to be a drop-in replacement for the current
AFAIK this is unused by the procfs package. |
Since this appears to have stagnated, I've resumed what I started several years ago. I hope to have a PR for procfs in a couple of days. |
any update? |
@dtap001 what is missing here exactly? The PR prometheus/procfs#509 was merged which gets the stats off of sysfs now. @dswarbrick you wanted to also fetch metrics via sysfs, sync rate and progress, right? |
Sorry I haven't had the bandwidth to work on this for a long time, but it looks like somebody else has picked up the torch in #3031 |
Proposal
I just discovered the that
node_md_blocks_synced
metric, which is currently parsed from/proc/mdstat
is not very useful in trying to determine resync / check progress percentage of an array. To be honest, I'm not really sure what it can be used for, because the way in which it is parsed has little bearing to the other metrics that are parsed from/proc/mdstat
.Take the following example of an array rebuilding:
Parsing this, node_exporter provides me with two nearly useful metrics:
node_md_blocks = 3281959800
node_md_blocks_synced = 124074752
One might be forgiven for thinking that one can simply divide node_md_blocks_synced by node_md_blocks and multiply by 100 to get a resync completion percentage. The problem is however that node_md_blocks is the whole array size expressed in 1 KB blocks (this is a ~3.1 TB array), whereas node_md_blocks_synced is the number of synced 1 KB blocks of the drive which is being rebuilt., i.e. one seventh of the of entire array (raid5, 8 members).
Dividing node_md_blocks_synced by node_md_blocks is going to yield a number that is seven times too small, and the only way you could possibly know that you need to multiply that number by seven would be if you knew a) the raid level, and b) the number of raid members.
The mdraid information contained in sysfs is a lot more detailed, and a lot easier to parse. The information that one would need to accurately calculate current rebuild progress can be read from
/sys/block/md*/md/sync_completed
, e.g.:These numbers are in sectors, and the md admin guide literally says that you can divide these numbers to get a "fraction of the process that is complete."
Use case. Why is this important?
The mdraid information in sysfs is substantially more detailed and more machine-readable than
/proc/mdstat
. I don't know whether there are any guarantees about the stability of the format of/proc/mdstat
, and I've never seen any indication that it is intended to be machine-readable; on the contrary, it is formatted to be human-friendly.The only information from
/proc/mdstat
which I don't think can be found in sysfs is the very first line, e.g.Personalities : [raid0] [raid1] [raid6] [raid5] [raid4]
, but node_exporter does not expose that information anyway. Everything else can be found in/sys/block/md*/md/*
.I am prepared to provide a PR which would completely refactor the mdadm collector (with a healthy dose of unit tests), if the Prometheus developers are interested. Ultimately I suspect this should find its way into the prometheus/procfs package, alongside the other sysfs parsers.
The text was updated successfully, but these errors were encountered: