From 5c4c53ce75311b1813c783c68c294739dd7265ba Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Thu, 14 Feb 2019 14:54:17 +0100 Subject: [PATCH] metrics: fix names, split memory stats Fix the metrics naming/labeling scheme as suggested in the review. - drop the "flush" label for storage iops, no clear need yet - split the memory stats into available/resident. More memory metricss are probably useful, their addition will be tracked in https://github.com/kubevirt/kubevirt/issues/2023 Signed-off-by: Francesco Romani --- pkg/monitoring/vms/prometheus/prometheus.go | 71 ++++++++------------- 1 file changed, 25 insertions(+), 46 deletions(-) diff --git a/pkg/monitoring/vms/prometheus/prometheus.go b/pkg/monitoring/vms/prometheus/prometheus.go index 9be151384437..58ad05935ef9 100644 --- a/pkg/monitoring/vms/prometheus/prometheus.go +++ b/pkg/monitoring/vms/prometheus/prometheus.go @@ -43,58 +43,45 @@ var ( ) storageIopsDesc = prometheus.NewDesc( - "kubevirt_vm_storage_iops", + "kubevirt_vm_storage_iops_total", "I/O operation performed.", []string{"domain", "drive", "type"}, nil, ) // from now on: TODO: validate vcpuUsageDesc = prometheus.NewDesc( - "kubevirt_vm_vcpu_time", - "Vcpu elapsed time, seconds.", + "kubevirt_vm_vcpu_seconds", + "Vcpu elapsed time.", []string{"domain", "id", "state"}, nil, ) networkTrafficDesc = prometheus.NewDesc( - "kubevirt_vm_network_traffic_bytes", - "network traffic, bytes.", + "kubevirt_vm_network_traffic_bytes_total", + "network traffi.", []string{"domain", "interface", "type"}, nil, ) - memoryUsageDesc = prometheus.NewDesc( - "kubevirt_vm_memory_amount_bytes", - "memory amount, bytes.", - []string{"domain", "type"}, + memoryAvailableDesc = prometheus.NewDesc( + "kubevirt_vm_memory_available_bytes", + "amount of usable memory as seen by the domain.", + []string{"domain"}, + nil, + ) + memoryResidentDesc = prometheus.NewDesc( + "kubevirt_vm_memory_resident_bytes", + "resident set size of the process running the domain", + []string{"domain"}, nil, ) ) func updateMemory(vmStats *stats.DomainStats, ch chan<- prometheus.Metric) { - if vmStats.Memory.UnusedSet { - mv, err := prometheus.NewConstMetric( - memoryUsageDesc, prometheus.GaugeValue, - float64(vmStats.Memory.Unused), - vmStats.Name, "unused", - ) - if err == nil { - ch <- mv - } - } if vmStats.Memory.AvailableSet { mv, err := prometheus.NewConstMetric( - memoryUsageDesc, prometheus.GaugeValue, - float64(vmStats.Memory.Available), - vmStats.Name, "available", - ) - if err == nil { - ch <- mv - } - } - if vmStats.Memory.ActualBalloonSet { - mv, err := prometheus.NewConstMetric( - memoryUsageDesc, prometheus.GaugeValue, - float64(vmStats.Memory.ActualBalloon), - vmStats.Name, "balloon", + memoryAvailableDesc, prometheus.GaugeValue, + // the libvirt value is in KiB + float64(vmStats.Memory.Available)*1024, + vmStats.Name, ) if err == nil { ch <- mv @@ -102,9 +89,10 @@ func updateMemory(vmStats *stats.DomainStats, ch chan<- prometheus.Metric) { } if vmStats.Memory.RSSSet { mv, err := prometheus.NewConstMetric( - memoryUsageDesc, prometheus.GaugeValue, - float64(vmStats.Memory.RSS), - vmStats.Name, "resident", + memoryResidentDesc, prometheus.GaugeValue, + // the libvirt value is in KiB + float64(vmStats.Memory.RSS)*1024, + vmStats.Name, ) if err == nil { ch <- mv @@ -156,16 +144,6 @@ func updateBlock(vmStats *stats.DomainStats, ch chan<- prometheus.Metric) { ch <- mv } } - if block.FlReqsSet { - mv, err := prometheus.NewConstMetric( - storageIopsDesc, prometheus.CounterValue, - float64(block.FlReqs), - vmStats.Name, block.Name, "flush", - ) - if err == nil { - ch <- mv - } - } } } @@ -228,7 +206,8 @@ func (co *Collector) Describe(ch chan<- *prometheus.Desc) { ch <- storageIopsDesc ch <- vcpuUsageDesc ch <- networkTrafficDesc - ch <- memoryUsageDesc + ch <- memoryAvailableDesc + ch <- memoryResidentDesc } // Note that Collect could be called concurrently