1
0

activate NixOS monitoring in prometheus

This commit is contained in:
clerie 2023-01-02 21:43:43 +01:00
parent 64122a7149
commit 1dfba9663a
3 changed files with 27 additions and 1 deletions

View File

@ -12,5 +12,6 @@
enable = true; enable = true;
id = "208"; id = "208";
pubkey = "s2GT9iYQmuiwkZ04KzSqqlIEbUJ6CT6i4htCjWYt2xs="; pubkey = "s2GT9iYQmuiwkZ04KzSqqlIEbUJ6CT6i4htCjWYt2xs=";
nixos = false;
}; };
} }

View File

@ -23,6 +23,13 @@ let
"${host.config.networking.hostName}.mon.clerie.de:9100") "${host.config.networking.hostName}.mon.clerie.de:9100")
monitoringHosts; monitoringHosts;
nixosMonitoringTargets = mapAttrsToList (name: host:
"${host.config.networking.hostName}.mon.clerie.de:9152")
(filterAttrs (name: host:
# assume this is a NixOS system if not specified
attrByPath ["clerie" "monitoring" "nixos"] true host.config)
monitoringHosts);
birdMonitoringTargets = mapAttrsToList (name: host: birdMonitoringTargets = mapAttrsToList (name: host:
"${host.config.networking.hostName}.mon.clerie.de:9324") "${host.config.networking.hostName}.mon.clerie.de:9324")
(filterAttrs (name: host: (filterAttrs (name: host:
@ -149,6 +156,15 @@ in {
} }
]; ];
} }
{
job_name = "nixos-exporter";
scrape_interval = "1m";
static_configs = [
{
targets = nixosMonitoringTargets;
}
];
}
{ {
job_name = "bird-exporter"; job_name = "bird-exporter";
scrape_interval = "20s"; scrape_interval = "20s";

View File

@ -23,6 +23,11 @@ in
}; };
bird = mkEnableOption "Monitor bird"; bird = mkEnableOption "Monitor bird";
blackbox = mkEnableOption "Monitor blackbox"; blackbox = mkEnableOption "Monitor blackbox";
nixos = mkOption {
type = types.bool;
default = true;
description = "Monitor NixOS";
};
}; };
}; };
@ -95,9 +100,13 @@ in
User = "nixos-exporter"; User = "nixos-exporter";
Group = "nixos-exporter"; Group = "nixos-exporter";
ExecStart = '' ExecStart = ''
${pkgs.nixos-exporter}/bin/nixos-exporter ${pkgs.nixos-exporter}/bin/nixos-exporter --listen [::]:9152
''; '';
}; };
}; };
networking.firewall.extraCommands = ''
ip46tables -A nixos-fw -i wg-monitoring -p tcp -m tcp --dport 9152 -m comment --comment nixos-exporter -j nixos-fw-accept
'';
}; };
} }