| 82 | } |
| 83 | |
| 84 | func bcachePeriodStatsToMetric(ps *bcache.PeriodStats, labelValue string) []bcacheMetric { |
| 85 | label := []string{"backing_device"} |
| 86 | |
| 87 | metrics := []bcacheMetric{ |
| 88 | { |
| 89 | name: "bypassed_bytes_total", |
| 90 | desc: "Amount of IO (both reads and writes) that has bypassed the cache.", |
| 91 | value: float64(ps.Bypassed), |
| 92 | metricType: prometheus.CounterValue, |
| 93 | extraLabel: label, |
| 94 | extraLabelValue: labelValue, |
| 95 | }, |
| 96 | { |
| 97 | name: "cache_hits_total", |
| 98 | desc: "Hits counted per individual IO as bcache sees them.", |
| 99 | value: float64(ps.CacheHits), |
| 100 | metricType: prometheus.CounterValue, |
| 101 | extraLabel: label, |
| 102 | extraLabelValue: labelValue, |
| 103 | }, |
| 104 | { |
| 105 | name: "cache_misses_total", |
| 106 | desc: "Misses counted per individual IO as bcache sees them.", |
| 107 | value: float64(ps.CacheMisses), |
| 108 | metricType: prometheus.CounterValue, |
| 109 | extraLabel: label, |
| 110 | extraLabelValue: labelValue, |
| 111 | }, |
| 112 | { |
| 113 | name: "cache_bypass_hits_total", |
| 114 | desc: "Hits for IO intended to skip the cache.", |
| 115 | value: float64(ps.CacheBypassHits), |
| 116 | metricType: prometheus.CounterValue, |
| 117 | extraLabel: label, |
| 118 | extraLabelValue: labelValue, |
| 119 | }, |
| 120 | { |
| 121 | name: "cache_bypass_misses_total", |
| 122 | desc: "Misses for IO intended to skip the cache.", |
| 123 | value: float64(ps.CacheBypassMisses), |
| 124 | metricType: prometheus.CounterValue, |
| 125 | extraLabel: label, |
| 126 | extraLabelValue: labelValue, |
| 127 | }, |
| 128 | { |
| 129 | name: "cache_miss_collisions_total", |
| 130 | desc: "Instances where data insertion from cache miss raced with write (data already present).", |
| 131 | value: float64(ps.CacheMissCollisions), |
| 132 | metricType: prometheus.CounterValue, |
| 133 | extraLabel: label, |
| 134 | extraLabelValue: labelValue, |
| 135 | }, |
| 136 | } |
| 137 | if ps.CacheReadaheads != 0 { |
| 138 | bcacheReadaheadMetrics := []bcacheMetric{ |
| 139 | { |
| 140 | name: "cache_readaheads_total", |
| 141 | desc: "Count of times readahead occurred.", |