Files
Ananth Bhaskararaman e50595fdff nixos/prometheus-libvirt-exporter: fix systemd socket restrictions
Allow AF_UNIX, AF_INET, and AF_INET6 address families so the exporter
can connect to the libvirt socket and serve HTTP metrics.
2026-04-04 00:51:27 +05:30

35 lines
698 B
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.prometheus.exporters.libvirt;
in
{
port = 9177;
extraOpts = {
libvirtUri = lib.mkOption {
type = lib.types.str;
default = "qemu:///system";
description = "Libvirt URI from which to extract metrics";
};
};
serviceOpts = {
serviceConfig = {
ExecStart = ''
${lib.getExe pkgs.prometheus-libvirt-exporter} \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--libvirt.uri ${cfg.libvirtUri} ${lib.concatStringsSep " " cfg.extraFlags}
'';
RestrictAddressFamilies = [
"AF_UNIX"
"AF_INET"
"AF_INET6"
];
};
};
}