ops/nixos: add ability to define additional things to be scraped, use this for coredns
This commit is contained in:
parent
588a47e97f
commit
26352c7065
3 changed files with 22 additions and 9 deletions
|
@ -23,16 +23,24 @@ let
|
||||||
systemDrvs = mapAttrs (_: sys: sys.config.system.build.toplevel) evaledSystems;
|
systemDrvs = mapAttrs (_: sys: sys.config.system.build.toplevel) evaledSystems;
|
||||||
systemTailscaleIPs = lib.mapAttrs' (n: v: lib.nameValuePair v [n]) (lib.filterAttrs (n: v: v != null) (mapAttrs (_: sys: sys.config.my.ip.tailscale) evaledSystems));
|
systemTailscaleIPs = lib.mapAttrs' (n: v: lib.nameValuePair v [n]) (lib.filterAttrs (n: v: v != null) (mapAttrs (_: sys: sys.config.my.ip.tailscale) evaledSystems));
|
||||||
|
|
||||||
systemExporters = builtins.listToAttrs (builtins.concatLists (lib.mapAttrsToList (sysName: sys: lib.mapAttrsToList (exporterName: exporter: let jobName = "${sysName}/exporters/${exporterName}"; in lib.nameValuePair jobName {
|
systemExporters = let
|
||||||
job_name = jobName;
|
exportersForSystem = sysName: sys: let
|
||||||
static_configs = [{
|
mkExporter = exporterName: exporterPort: let jobName = "${sysName}/exporters/${exporterName}"; in lib.nameValuePair jobName {
|
||||||
targets = ["${sysName}:${toString exporter.port}"];
|
job_name = jobName;
|
||||||
labels = {
|
static_configs = [{
|
||||||
system = sysName;
|
targets = ["${sysName}:${toString exporterPort}"];
|
||||||
exporter = exporterName;
|
labels = {
|
||||||
|
system = sysName;
|
||||||
|
exporter = exporterName;
|
||||||
|
};
|
||||||
|
}];
|
||||||
};
|
};
|
||||||
}];
|
stockExporters = lib.mapAttrsToList (exporterName: exporter: mkExporter exporterName exporter.port) (lib.filterAttrs (_: exporter: exporter.enable) sys.config.services.prometheus.exporters);
|
||||||
}) (lib.filterAttrs (_: exporter: exporter.enable) sys.config.services.prometheus.exporters)) evaledSystems));
|
customExporters = lib.mapAttrsToList mkExporter sys.config.my.prometheus.additionalExporterPorts;
|
||||||
|
in
|
||||||
|
stockExporters ++ customExporters;
|
||||||
|
in
|
||||||
|
builtins.listToAttrs (builtins.concatLists (lib.mapAttrsToList exportersForSystem evaledSystems));
|
||||||
in systemDrvs // {
|
in systemDrvs // {
|
||||||
systems = systemDrvs;
|
systems = systemDrvs;
|
||||||
systemExporters = systemExporters;
|
systemExporters = systemExporters;
|
||||||
|
|
|
@ -17,6 +17,10 @@ in
|
||||||
type = lib.types.nullOr lib.types.anything;
|
type = lib.types.nullOr lib.types.anything;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
options.my.prometheus.additionalExporterPorts = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.port;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
options.my.ip.tailscale = lib.mkOption {
|
options.my.ip.tailscale = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.string;
|
type = lib.types.nullOr lib.types.string;
|
||||||
|
|
|
@ -209,6 +209,7 @@ in {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
my.prometheus.additionalExporterPorts.coredns = 9153;
|
||||||
networking.resolvconf.extraConfig = ''
|
networking.resolvconf.extraConfig = ''
|
||||||
name_servers='127.0.0.53'
|
name_servers='127.0.0.53'
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue