|
| 1 | +# diskstats |
| 2 | + |
| 3 | +Exposes disk I/O statistics from `/proc/diskstats` and block device metadata from sysfs and udev. |
| 4 | + |
| 5 | +Status: enabled by default |
| 6 | + |
| 7 | +## Platforms |
| 8 | + |
| 9 | +- Linux |
| 10 | +- Darwin |
| 11 | +- OpenBSD |
| 12 | +- AIX |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +``` |
| 17 | +--collector.diskstats.device-include Regexp of devices to include (mutually exclusive with device-exclude) |
| 18 | +--collector.diskstats.device-exclude Regexp of devices to exclude (default: ^(z?ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\d+n\d+p)\d+$) |
| 19 | +``` |
| 20 | + |
| 21 | +## Data Sources |
| 22 | + |
| 23 | +| Source | Description | |
| 24 | +|--------|-------------| |
| 25 | +| `/proc/diskstats` | Disk I/O statistics | |
| 26 | +| `/sys/block/<device>/` | Block device attributes | |
| 27 | +| `/sys/block/<device>/queue/` | Block device queue stats | |
| 28 | +| `/run/udev/data/b<major>:<minor>` | Udev device properties | |
| 29 | + |
| 30 | +Kernel documentation: https://www.kernel.org/doc/Documentation/iostats.txt |
| 31 | + |
| 32 | +## Metrics |
| 33 | + |
| 34 | +### I/O Statistics |
| 35 | + |
| 36 | +| Metric | Type | Labels | Description | |
| 37 | +|--------|------|--------|-------------| |
| 38 | +| `node_disk_reads_completed_total` | counter | `device` | Total number of reads completed successfully | |
| 39 | +| `node_disk_reads_merged_total` | counter | `device` | Total number of reads merged | |
| 40 | +| `node_disk_read_bytes_total` | counter | `device` | Total number of bytes read successfully | |
| 41 | +| `node_disk_read_time_seconds_total` | counter | `device` | Total seconds spent by all reads | |
| 42 | +| `node_disk_writes_completed_total` | counter | `device` | Total number of writes completed successfully | |
| 43 | +| `node_disk_writes_merged_total` | counter | `device` | Total number of writes merged | |
| 44 | +| `node_disk_written_bytes_total` | counter | `device` | Total number of bytes written successfully | |
| 45 | +| `node_disk_write_time_seconds_total` | counter | `device` | Total seconds spent by all writes | |
| 46 | +| `node_disk_io_now` | gauge | `device` | Number of I/Os currently in progress | |
| 47 | +| `node_disk_io_time_seconds_total` | counter | `device` | Total seconds spent doing I/Os | |
| 48 | +| `node_disk_io_time_weighted_seconds_total` | counter | `device` | Weighted seconds spent doing I/Os | |
| 49 | + |
| 50 | +### Discard Statistics (Linux 4.18+) |
| 51 | + |
| 52 | +| Metric | Type | Labels | Description | |
| 53 | +|--------|------|--------|-------------| |
| 54 | +| `node_disk_discards_completed_total` | counter | `device` | Total number of discards completed successfully | |
| 55 | +| `node_disk_discards_merged_total` | counter | `device` | Total number of discards merged | |
| 56 | +| `node_disk_discarded_sectors_total` | counter | `device` | Total number of sectors discarded successfully | |
| 57 | +| `node_disk_discard_time_seconds_total` | counter | `device` | Total seconds spent by all discards | |
| 58 | + |
| 59 | +### Flush Statistics (Linux 5.5+) |
| 60 | + |
| 61 | +| Metric | Type | Labels | Description | |
| 62 | +|--------|------|--------|-------------| |
| 63 | +| `node_disk_flush_requests_total` | counter | `device` | Total number of flush requests completed successfully | |
| 64 | +| `node_disk_flush_requests_time_seconds_total` | counter | `device` | Total seconds spent by all flush requests | |
| 65 | + |
| 66 | +### Device Info |
| 67 | + |
| 68 | +| Metric | Type | Labels | Description | |
| 69 | +|--------|------|--------|-------------| |
| 70 | +| `node_disk_info` | gauge | `device`, `major`, `minor`, `path`, `wwn`, `model`, `serial`, `revision`, `rotational` | Block device info, always 1 | |
| 71 | +| `node_disk_filesystem_info` | gauge | `device`, `type`, `usage`, `uuid`, `version` | Filesystem info from udev, always 1 | |
| 72 | +| `node_disk_device_mapper_info` | gauge | `device`, `name`, `uuid`, `vg_name`, `lv_name`, `lv_layer` | Device mapper info, always 1 | |
| 73 | + |
| 74 | +### ATA Device Attributes |
| 75 | + |
| 76 | +| Metric | Type | Labels | Description | |
| 77 | +|--------|------|--------|-------------| |
| 78 | +| `node_disk_ata_write_cache` | gauge | `device` | ATA disk has a write cache (1 if true) | |
| 79 | +| `node_disk_ata_write_cache_enabled` | gauge | `device` | ATA disk write cache is enabled (1 if true) | |
| 80 | +| `node_disk_ata_rotation_rate_rpm` | gauge | `device` | ATA disk rotation rate in RPM (0 for SSDs) | |
| 81 | + |
| 82 | +## Notes |
| 83 | + |
| 84 | +- Sector sizes in `/proc/diskstats` are always 512 bytes regardless of actual device sector size |
| 85 | +- Time values in the kernel are in milliseconds; the collector converts to seconds |
| 86 | +- Udev info metrics require readable `/run/udev/data/` directory |
| 87 | +- Discard and flush metrics availability depends on kernel version |
| 88 | +- The default exclude pattern filters out partition devices and RAM/loop devices |
0 commit comments