metrics: prometheus: more storage metrics
Add metrics to report:
per-drive per-VM I/O traffic aka bytes read/write total
per-drive per-VM I/O operational times aka total time spent doing I/O
ops, needed to compute the average latency time (e.g. read latency).
@@ -48,7 +48,18 @@ var (
[]string{"domain", "drive", "type"},
nil,
)
- // from now on: TODO: validate
+ storageTrafficDesc = prometheus.NewDesc(
+ "kubevirt_vm_storage_traffic_bytes_total",
+ "storage traffic.",
+ []string{"domain", "drive", "type"},
+ nil,
+ )
+ storageTimesDesc = prometheus.NewDesc(
+ "kubevirt_vm_storage_times_ms_total",
+ "storage operation time.",
+ []string{"domain", "drive", "type"},
+ nil,
+ )
vcpuUsageDesc = prometheus.NewDesc(
"kubevirt_vm_vcpu_seconds",
"Vcpu elapsed time.",
@@ -57,7 +68,7 @@ var (
)
networkTrafficDesc = prometheus.NewDesc(
"kubevirt_vm_network_traffic_bytes_total",
- "network traffi.",
+ "network traffic.",
[]string{"domain", "interface", "type"},
nil,
)
@@ -144,8 +155,49 @@ func updateBlock(vmStats *stats.DomainStats, ch chan<- prometheus.Metric) {
ch <- mv
}
}
+
+ if block.RdBytesSet {
+ mv, err := prometheus.NewConstMetric(
+ storageTrafficDesc, prometheus.CounterValue,
+ float64(block.RdBytes),
+ vmStats.Name, block.Name, "read",
+ )
+ if err == nil {
+ ch <- mv
+ }
+ }
+ if block.WrBytesSet {
+ mv, err := prometheus.NewConstMetric(
+ storageTrafficDesc, prometheus.CounterValue,
+ float64(block.WrBytes),
+ vmStats.Name, block.Name, "write",
+ )
+ if err == nil {
+ ch <- mv
+ }
}
+ if block.RdTimesSet {
+ mv, err := prometheus.NewConstMetric(
+ storageTimesDesc, prometheus.CounterValue,
+ float64(block.RdTimes),
+ vmStats.Name, block.Name, "read",
+ )
+ if err == nil {
+ ch <- mv
+ }
+ }
+ if block.WrTimesSet {
+ mv, err := prometheus.NewConstMetric(
+ storageTimesDesc, prometheus.CounterValue,
+ float64(block.WrTimes),
+ vmStats.Name, block.Name, "write",
+ )
+ if err == nil {
+ ch <- mv
+ }
+ }
+ }
}
func updateNetwork(vmStats *stats.DomainStats, ch chan<- prometheus.Metric) {
@@ -204,6 +256,8 @@ func (co *Collector) Describe(ch chan<- *prometheus.Desc) {
// TODO: Use DescribeByCollect?
ch <- versionDesc
ch <- storageIopsDesc
+ ch <- storageTrafficDesc
+ ch <- storageTimesDesc
ch <- vcpuUsageDesc
ch <- networkTrafficDesc
ch <- memoryAvailableDesc
