Use procfs/blockdevice for diskstats#2072
Closed
luizluca wants to merge 1 commit intoprometheus:masterfrom
Closed
Conversation
diskstats now use procfs/blockdevice instead of manually reading procfs. It prefers to use /sys but it will fallback to /proc if /sys fails. Although reading /sys/block/<dev>/stat is slower, /proc/diskstats have never garanteed atomicity between lines. A new option collector.diskstats.prefer-sysfs (true by default) can be used to skip /sys. Using /sys, diskstats will ignore partitions. If they are needed, /proc must be used or procfs/blockdevice must be extended. This solves issues with ambiguous names like xvda1 that that can both represent a partition in xvda or a standalone disk (Fixes prometheus#2041). If collector.diskstats.ignored-devices was changed to include partitions, collector.diskstats.prefer-sysfs must be set to false. if collector.diskstats.ignored-devices was untouched, both /proc and /sys should return the same results. With /sys as default, collector.diskstats.ignored-devices could be simplified to match only device names, not partitions. For now, partition filtering was kept and extended to match mmcblk0p[12]. The diskstats_linux_test.go was not implemented for /sys/block. Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use procfs/blockdevice for diskstats
diskstats now use procfs/blockdevice instead of manually reading
procfs. A new option collector.diskstats.prefer-sysfs (false by
default) can switch from /proc to /sys metrics. If /sys reading
fails, it will fallback to /proc.
Although reading /sys/block/<dev>/stat is slower, /proc/diskstats
have never garanteed atomicity between lines. Both /proc and /sys
data are equivalent except for partitions as procfs/blockdevice
/sys library does not include partition metrics. For now, if the
user expects to get partition metrics by changing default
ignored-devices, prefer-sysfs cannot be true.
Partition filtering was extended to match mmcblk0p[12].
The diskstats_linux_test.go was not implemented.
Signed-off-by: Luiz Angelo Daros de Luca luizluca@gmail.com