Skip to content

LibVirt Telemetry

This document describes the telemetry signals originating directly from LibVirt and the hypervisor backend (QEMU/KVM or Cloud Hypervisor) on the Hypervisor nodes: Metrics, logs, and events.

Note: LibVirt exists in two operating models — see Hypervisor for details. The telemetry integration differs depending on the model.

Operating Model Differences

AspectGardenLinux-providedc5c3-managed (containerized)
LibVirt LogsSystemd Journal on the host (journalctl)Container stdout/stderr (standard log pipeline)
VM Logs (QEMU/CH)/var/log/libvirt/qemu/ or /var/log/libvirt/ch/ on the hostVolume mount or container stdout
Metrics Accesslibvirt-exporter connects to host daemonlibvirt-exporter in the same pod or as sidecar
Event SubscriptionHA Agent connects via TCP to hostHA Agent connects via TCP to container
Log CollectionFluent Bit reads host paths + journalFluent Bit collects container logs (standard path)

libvirt-exporter

The libvirt-exporter exports per-VM metrics as Prometheus metrics. It connects to the local libvirtd and queries domain statistics. These metrics are scraped by the cluster-local Prometheus instance and federated to the Management Cluster (see Metrics).

Metrics

MetricDescriptionLabels
libvirt_domain_info_vcpusNumber of assigned vCPUsdomain, uuid
libvirt_domain_info_memory_bytesAssigned memorydomain, uuid
libvirt_domain_vcpu_time_seconds_totalCPU time per vCPUdomain, uuid, vcpu
libvirt_domain_memory_usage_bytesActual memory usagedomain, uuid
libvirt_domain_block_read_bytes_totalDisk read bytesdomain, uuid, device
libvirt_domain_block_write_bytes_totalDisk write bytesdomain, uuid, device
libvirt_domain_block_read_requests_totalDisk read IOPSdomain, uuid, device
libvirt_domain_block_write_requests_totalDisk write IOPSdomain, uuid, device
libvirt_domain_net_receive_bytes_totalNetwork receive bytesdomain, uuid, interface
libvirt_domain_net_transmit_bytes_totalNetwork transmit bytesdomain, uuid, interface
libvirt_domain_net_receive_packets_totalNetwork receive packetsdomain, uuid, interface
libvirt_domain_net_transmit_packets_totalNetwork transmit packetsdomain, uuid, interface
libvirt_domain_net_receive_errors_totalNetwork receive errorsdomain, uuid, interface
libvirt_domain_net_transmit_drops_totalNetwork transmit dropsdomain, uuid, interface
libvirt_upReachability of the libvirtd daemon

DaemonSet

yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: libvirt-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: libvirt-exporter
  template:
    metadata:
      labels:
        app: libvirt-exporter
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9177"
    spec:
      nodeSelector:
        node-role.kubernetes.io/hypervisor: ""
      containers:
        - name: libvirt-exporter
          image: ghcr.io/c5c3/libvirt-exporter:latest  # Pin to a specific version in production
          args:
            - --libvirt.uri=qemu+tcp://$(NODE_IP):16509/system
          env:
            - name: NODE_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
          ports:
            - containerPort: 9177
              name: metrics
          resources:
            requests:
              memory: 64Mi
              cpu: 25m
            limits:
              memory: 128Mi
              cpu: 100m
yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: libvirt-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: libvirt-exporter
  endpoints:
    - port: metrics
      interval: 30s

LibVirt Logging

GardenLinux-provided

When LibVirt is provided by the host OS, logs end up in the following locations:

Log SourcePathDescription
libvirtdSystemd Journal (libvirtd.service)Daemon events, connection lifecycle
VMM (per VM)/var/log/libvirt/qemu/<domain>.log or /var/log/libvirt/ch/<domain>.logEmulator startup, errors, chardev

Fluent Bit must be configured for this model to read both the systemd journal and host paths:

text
[INPUT]
    Name            systemd
    Tag             host.libvirtd
    Systemd_Filter  _SYSTEMD_UNIT=libvirtd.service

[INPUT]
    Name            tail
    Tag             host.qemu.*
    Path            /var/log/libvirt/qemu/*.log
    Parser          syslog

c5c3-managed (containerized)

When LibVirt runs as a container, logging follows the standard container model:

  • libvirtd logs to container stdout/stderr
  • QEMU logs are redirected to container stdout or provided via a volume
  • Fluent Bit collects logs via the standard container log pipeline (/var/log/containers/)

No additional Fluent Bit configuration required.

LibVirt Events

The HA Agent subscribes to LibVirt domain events via the libvirt Event API. These events are a telemetry source for failure detection.

Monitored Event Types:

Event TypeDescriptionAction
Lifecycle (Stopped)VM unexpectedly stoppedCreate Eviction CRD
Lifecycle (Crashed)VM crashedCreate Eviction CRD
WatchdogWatchdog timer triggeredCreate Eviction CRD
I/O ErrorDisk I/O error in VMLog event, possibly Eviction
RebootVM reboot requestedStatus update in Hypervisor CRD

See High Availability for the complete failure detection and evacuation architecture.

Event Flow

text
libvirtd ──▶ HA Agent ──▶ Kubernetes API ──▶ Hypervisor Operator
             (Event       (Eviction CRD)     (Evacuation Logic)
              Listener)

The HA Agent connects via TCP to the LibVirt daemon (qemu+tcp://<host>:16509/system) and registers event callbacks. On relevant events, it creates Eviction CRDs that are processed by the Hypervisor Operator.