Skip to content

Commit

Permalink
metrics: fix names, split memory stats
Browse files Browse the repository at this point in the history
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 kubevirt#2023

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Feb 14, 2019
1 parent 3491274 commit 5c4c53c
Showing 1 changed file with 25 additions and 46 deletions.
71 changes: 25 additions & 46 deletions pkg/monitoring/vms/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,68 +43,56 @@ 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
}
}
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
Expand Down Expand Up @@ -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
}
}
}

}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5c4c53c

Please sign in to comment.