From a20ed52cfc07fc23ac9cf8ddb420d58729c43cda Mon Sep 17 00:00:00 2001 From: arcnmx Date: Thu, 30 May 2024 17:14:50 -0700 Subject: [PATCH] feat(monitoring): prometheus ingest labels --- modules/system/exports/monitoring.nix | 14 ++++++++++++-- modules/system/exports/services.nix | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/system/exports/monitoring.nix b/modules/system/exports/monitoring.nix index 895f8b77..f0ae36ba 100644 --- a/modules/system/exports/monitoring.nix +++ b/modules/system/exports/monitoring.nix @@ -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 diff --git a/modules/system/exports/services.nix b/modules/system/exports/services.nix index fe036de7..02530dd5 100644 --- a/modules/system/exports/services.nix +++ b/modules/system/exports/services.nix @@ -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; }; });