NewDiskstatsCollector returns a new Collector exposing disk device stats.
()
| 54 | |
| 55 | // NewDiskstatsCollector returns a new Collector exposing disk device stats. |
| 56 | func NewDiskstatsCollector() (Collector, error) { |
| 57 | var diskLabelNames = []string{"device"} |
| 58 | |
| 59 | return &diskstatsCollector{ |
| 60 | ignoredDevicesPattern: regexp.MustCompile("^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$"), |
| 61 | // Docs from https://www.kernel.org/doc/Documentation/iostats.txt |
| 62 | descs: []typedFactorDesc{ |
| 63 | { |
| 64 | desc: prometheus.NewDesc( |
| 65 | prometheus.BuildFQName(namespace, diskSubsystem, "reads_completed_total"), |
| 66 | "The total number of reads completed successfully.", |
| 67 | diskLabelNames, |
| 68 | nil, |
| 69 | ), valueType: prometheus.CounterValue, |
| 70 | }, |
| 71 | { |
| 72 | desc: prometheus.NewDesc( |
| 73 | prometheus.BuildFQName(namespace, diskSubsystem, "reads_merged_total"), |
| 74 | "The total number of reads merged. See https://www.kernel.org/doc/Documentation/iostats.txt.", |
| 75 | diskLabelNames, |
| 76 | nil, |
| 77 | ), valueType: prometheus.CounterValue, |
| 78 | }, |
| 79 | { |
| 80 | desc: prometheus.NewDesc( |
| 81 | prometheus.BuildFQName(namespace, diskSubsystem, "read_bytes_total"), |
| 82 | "The total number of bytes read successfully.", |
| 83 | diskLabelNames, |
| 84 | nil, |
| 85 | ), valueType: prometheus.CounterValue, |
| 86 | factor: diskSectorSize, |
| 87 | }, |
| 88 | { |
| 89 | desc: prometheus.NewDesc( |
| 90 | prometheus.BuildFQName(namespace, diskSubsystem, "read_time_seconds_total"), |
| 91 | "The total number of milliseconds spent by all reads.", |
| 92 | diskLabelNames, |
| 93 | nil, |
| 94 | ), valueType: prometheus.CounterValue, |
| 95 | factor: .001, |
| 96 | }, |
| 97 | { |
| 98 | desc: prometheus.NewDesc( |
| 99 | prometheus.BuildFQName(namespace, diskSubsystem, "writes_completed_total"), |
| 100 | "The total number of writes completed successfully.", |
| 101 | diskLabelNames, |
| 102 | nil, |
| 103 | ), valueType: prometheus.CounterValue, |
| 104 | }, |
| 105 | { |
| 106 | desc: prometheus.NewDesc( |
| 107 | prometheus.BuildFQName(namespace, diskSubsystem, "writes_merged_total"), |
| 108 | "The number of writes merged. See https://www.kernel.org/doc/Documentation/iostats.txt.", |
| 109 | diskLabelNames, |
| 110 | nil, |
| 111 | ), valueType: prometheus.CounterValue, |
| 112 | }, |
| 113 | { |