enable node exporter on all machines
enable prometheus scraper and web interface on warwick
This commit is contained in:
parent
90165687ef
commit
52ee071087
3 changed files with 52 additions and 0 deletions
|
@ -3,5 +3,7 @@
|
|||
kind = "physical";
|
||||
arch = "aarch64-linux";
|
||||
isRaspberryPi = true;
|
||||
|
||||
nixosModule.lab.services.prometheus.server.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
./networking
|
||||
./data-sharing.nix
|
||||
./globals.nix
|
||||
./prometheus.nix
|
||||
];
|
||||
}
|
||||
|
|
49
nix/modules/prometheus.nix
Normal file
49
nix/modules/prometheus.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ lib, config, machines, ... }:
|
||||
let
|
||||
cfg = config.lab.services.prometheus;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lab.services.prometheus = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
|
||||
server.enable = lib.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts = [ config.services.prometheus.exporters.node.port ]
|
||||
++ lib.lists.optionals cfg.server.enable [ config.services.prometheus.port ];
|
||||
|
||||
services.prometheus = {
|
||||
enable = cfg.server.enable;
|
||||
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
scrapeConfigs = lib.mkIf cfg.server.enable (
|
||||
lib.attrsets.mapAttrsToList
|
||||
(name: machine:
|
||||
let
|
||||
domain = if machine.isPhysical then "hyp" else "dmz";
|
||||
in
|
||||
{
|
||||
job_name = name;
|
||||
static_configs = [{
|
||||
targets = [ "${name}.${domain}:${toString config.services.prometheus.exporters.node.port}" ];
|
||||
}];
|
||||
})
|
||||
machines
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue