feat(monitoring): prometheus ingest labels

This commit is contained in:
arcnmx 2024-05-30 17:14:50 -07:00
parent bb371d19d3
commit a20ed52cfc
2 changed files with 18 additions and 2 deletions

View file

@ -7,10 +7,13 @@ let
};
};
serviceModule = {
system,
config,
gensokyo-zone,
lib,
...
}: let
inherit (gensokyo-zone.lib) mapOptionDefaults;
inherit (lib.options) mkOption;
inherit (lib.modules) mkOptionDefault;
inherit (lib.attrsets) attrNames filterAttrs;
@ -24,7 +27,6 @@ let
};
labels = mkOption {
type = attrsOf str;
default = {};
};
};
};
@ -35,7 +37,15 @@ let
};
};
config.prometheus = {
exporter.ports = mkOptionDefault (attrNames exporterPorts);
exporter = {
ports = mkOptionDefault (attrNames exporterPorts);
labels = mapOptionDefaults {
gensokyo_exports_service = config.name;
gensokyo_exports_id = config.id;
gensokyo_system = system.name;
gensokyo_host = system.access.fqdn;
};
};
};
};
in

View file

@ -58,8 +58,11 @@
};
};
serviceModule = {
system,
config,
name,
machine,
gensokyo-zone,
...
}: {
options = with lib.types; {
@ -76,6 +79,7 @@
type = attrsOf (submoduleWith {
modules = [portModule];
specialArgs = {
inherit gensokyo-zone machine system;
service = config;
};
});
@ -155,7 +159,9 @@ in {
type = attrsOf (submoduleWith {
modules = [serviceModule];
specialArgs = {
inherit gensokyo-zone;
machine = name;
system = config;
systemConfig = config;
};
});