Monitoring: shared topology module (hubs, roles, ports) (flakes-2gf7)
Shared NixOS module that defines the monitoring topology once, in the style of mixins/nixos/lan/site.nix, so hubs/agents derive their config from data instead of per-host copy-paste.
Spec
- Location:
mixins/nixos/services/monitoring/(opt-in mixin, imported by pc and edgerimports.nix). - Options (sketch):
monitoring.hubs— attrset of hub name → address, default{ pc = "pc.yjpark.zerotier"; edger = "edger.yjpark.zerotier"; }(zerotier names resolve/route from every site).monitoring.role.hub— bool; enables VM + VL on this host (see hub bean).monitoring.role.agent— bool, default true when the mixin is imported.- Ports as constants/options: VM 8428, VL 9428, node_exporter 9100, vlagent listen 9429 (localhost).
- Derived: list of VM remote-write URLs (
http://<hub>:8428/api/v1/write) and VL remote-write URLs (http://<hub>:9428/internal/insert) for all hubs — confirm the exact vlagent→VL ingestion path from VictoriaLogs docs/source. - Common labels:
host = config.networking.hostName,site = config.site.id.
Todo
- Create mixin with options + derived URL lists
- Import in
nixos/hosts/pc/imports.nixandnixos/hosts/edger/imports.nix -
mise run build-hostbuilds on both (verified via toplevel drv eval for pc and edger)
Summary of Changes
- Added
mixins/nixos/services/monitoring/default.nix(options only, no services yet):monitoring.hubs(default pc/edger →<host>.yjpark.zerotier),monitoring.role.{hub,agent},monitoring.ports.*, and read-only derivedlabels(host, plussitewhen the lan mixin is imported),vmWriteUrls(/api/v1/write) andvlWriteUrls(/internal/insert, verified in VictoriaLogs v1.49 vlinsert). role.hubdefaults tohubs ? hostName, so pc and edger are hubs automatically — flakes-4c4d does not need to set it per host.- Imported the mixin in pc and edger
imports.nix. - Verified: both toplevels evaluate; derived values checked via
nix eval. Drv diff vs HEAD is only the flake source path in home-manager files (no functional change).