Upgraded snowfall lib
This commit is contained in:
parent
7e87dbc55b
commit
a1709f033f
58 changed files with 22 additions and 19 deletions
59
modules/nixos/services/prometheus/default.nix
Normal file
59
modules/nixos/services/prometheus/default.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
options,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.aa.services.prometheus;
|
||||
exporters = config.services.prometheus.exporters;
|
||||
in {
|
||||
options.aa.services.prometheus = with types; {
|
||||
enable = mkEnableOption "prometheus";
|
||||
enableServer = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Whether or not to enable the prometheus server";
|
||||
};
|
||||
enableNodeExporter = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Whether or not to enable the node exporter";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.prometheus = {
|
||||
enable = cfg.enableServer;
|
||||
exporters = {
|
||||
node = {
|
||||
enable = cfg.enableNodeExporter;
|
||||
enabledCollectors = ["systemd"];
|
||||
port = 9002;
|
||||
openFirewall = true;
|
||||
};
|
||||
};
|
||||
scrapeConfigs = mkIf cfg.enableServer [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{
|
||||
# TODO: How to automatically generate this whenever an exporter
|
||||
# is configured
|
||||
targets = [
|
||||
"node:${toString exporters.node.port}"
|
||||
"gospel:${toString exporters.node.port}"
|
||||
"pi4:${toString exporters.node.port}"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
networking.firewall = mkIf cfg.enableServer {
|
||||
allowedTCPPorts = [config.services.prometheus.port];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue