Skip to content

KVM (libvirt) module revamp #18513

@jsoriano

Description

@jsoriano

Module for kvm in metricbeat has some issues that should be addressed:

  • It only collects memory metrics and domain statuses (since Add domain state to kvm module #17673).
  • Memory metrics are collected one per event, with a field for the name of the metric and another one for the value.
  • There are no integration tests.
  • There is test code in the metricset.
  • It is called kvm, but it actually uses libvirt for monitoring, that can support other hypervisors as Xen or VMware, should we rename the module and offer support for other backends?

I think that this module should be completely revamped, possibly with new metricsets, or as a new libvirt module, some things to do:

Some potential datasets could be:

  • hypervisor
  • domain
  • storagepool
  • storagevolume
  • network
  • snapshot

As reference of available monitoring data, these are the monitoring commands exposed by virsh for example:

 Domain Monitoring (help keyword 'monitor')
    domblkerror                    Show errors on block devices
    domblkinfo                     domain block device size information
    domblklist                     list all domain blocks
    domblkstat                     get device block stats for a domain
    domcontrol                     domain control interface state
    domif-getlink                  get link state of a virtual interface
    domifaddr                      Get network interfaces' addresses for a running domain
    domiflist                      list all domain virtual interfaces
    domifstat                      get network interface stats for a domain
    dominfo                        domain information
    dommemstat                     get memory statistics for a domain
    domstate                       domain state
    domstats                       get statistics about one or multiple domains
    domtime                        domain time
    list                           list domains

virsh domstats has a good summary of metrics, other subcommands may be needed to get metadata.

$ virsh domstats buster-amd64 
Domain: 'buster-amd64'
  state.state=1
  state.reason=1
  cpu.time=69239116999
  cpu.user=1300000000
  cpu.system=7000000000
  balloon.current=1024000
  balloon.maximum=1024000
  balloon.swap_in=0
  balloon.swap_out=0
  balloon.major_fault=0
  balloon.minor_fault=3755
  balloon.unused=859920
  balloon.available=984940
  balloon.usable=792752
  balloon.last-update=1589446510
  balloon.rss=285460
  vcpu.current=1
  vcpu.maximum=1
  vcpu.0.state=1
  vcpu.0.time=10470000000
  vcpu.0.wait=0
  vcpu.0.halted=yes
  net.count=1
  net.0.name=vnet0
  net.0.rx.bytes=110
  net.0.rx.pkts=1
  net.0.rx.errs=0
  net.0.rx.drop=984
  net.0.tx.bytes=0
  net.0.tx.pkts=0
  net.0.tx.errs=0
  net.0.tx.drop=0
  block.count=1
  block.0.name=vda
  block.0.path=/var/lib/libvirt/images/buster-amd64.qcow2
  block.0.rd.reqs=1
  block.0.rd.bytes=512
  block.0.rd.times=60796
  block.0.wr.reqs=0
  block.0.wr.bytes=0
  block.0.wr.times=0
  block.0.fl.reqs=0
  block.0.fl.times=0
  block.0.allocation=0
  block.0.capacity=10737418240
  block.0.physical=1847296

For metadata, the non-metrics data of the domain info may be a good reference:

$ virsh dominfo buster-amd64 
Id:             1
Name:           buster-amd64
UUID:           ea006fe2-f026-43c6-814d-1dbcd0afda22
OS Type:        hvm
State:          running
CPU(s):         1
CPU time:       73,5s
Max memory:     1024000 KiB
Used memory:    1024000 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0
Security label: libvirt-ea006fe2-f026-43c6-814d-1dbcd0afda22 (enforcing)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions