add bind_exporter

This commit is contained in:
Charlotte 🦝 Delenk 2022-01-15 14:44:34 +01:00
parent fbcf829d8c
commit a1a4ba1db2
Signed by: darkkirb
GPG key ID: 015E3768A70AFBC5
3 changed files with 28 additions and 1 deletions

View file

@ -1,4 +1,10 @@
{ ... }: { { config, ... }:
let
internalIP = import ../../utils/getInternalIP.nix config;
createListenEntry = ip: "inet ${ip} port 8653 allow { ${ip} };";
listenEntries = builtins.map createListenEntry internalIP.listenIPsBare;
in
{
services.bind = { services.bind = {
enable = true; enable = true;
zones = { zones = {
@ -31,7 +37,18 @@
file = "rpz.int.chir.rs.zone"; file = "rpz.int.chir.rs.zone";
}; };
}; };
extraConfig = ''
statistics-channels {
${toString listenEntries}
}
'';
}; };
networking.firewall.allowedTCPPorts = [ 53 ]; networking.firewall.allowedTCPPorts = [ 53 ];
networking.firewall.allowedUDPPorts = [ 53 ]; networking.firewall.allowedUDPPorts = [ 53 ];
services.prometheus.exporters.bind = {
enable = true;
bindGroups = [ "server" "view" "tasks" ];
bindURI = "http://${internalIP.listenIP}:8653/";
listenAddress = internalIP.listenIP;
};
} }

View file

@ -11,6 +11,14 @@
]; ];
}]; }];
} }
{
job_name = "bind_exporter";
static_configs = [{
targets = [
"${config.services.prometheus.exporters.bind.listenAddress}:${toString config.services.prometheus.exporters.bind.port}"
];
}];
}
]; ];
}; };
} }

View file

@ -1,9 +1,11 @@
config: config:
let let
removeCIDR = cidr: builtins.elemAt (builtins.split "/" cidr) 0; removeCIDR = cidr: builtins.elemAt (builtins.split "/" cidr) 0;
filterIPsBare = cidrs: builtins.map removeCIDR cidrs;
filterIPs = cidrs: builtins.map (f: "[${removeCIDR f}]") cidrs; filterIPs = cidrs: builtins.map (f: "[${removeCIDR f}]") cidrs;
in in
rec { rec {
listenIPs = filterIPs config.networking.wireguard.interfaces."wg0".ips; listenIPs = filterIPs config.networking.wireguard.interfaces."wg0".ips;
listenIPsBare = filterIPsBare config.networking.wireguard.interfaces."wg0".ips;
listenIP = builtins.elemAt listenIPs 0; listenIP = builtins.elemAt listenIPs 0;
} }