M roles/prometheus.nix => roles/prometheus.nix +33 -3
@@ 14,11 14,41 @@ in {
default = false;
description = "Wheter to open firewall ports for enabled exporters";
};
- node.enable = lib.mkEnableOption "node exporter";
- systemd.enable = lib.mkEnableOption "systemd exporter";
+ node = lib.mkOption {
+ type = lib.types.submodule {
+ options = {
+ enable = lib.mkEnableOption "node exporter";
+ port = lib.mkOption {
+ type = lib.types.port;
+ };
+ extraFlags = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
+ default = [];
+ };
+ };
+ };
+ };
+ systemd = lib.mkOption {
+ type = lib.types.submodule {
+ options = {
+ enable = lib.mkEnableOption "systemd exporter";
+ };
+ };
+ };
};
};
- default = {};
+ };
+ };
+
+ config = {
+ services.prometheus.exporters = {
+ node = lib.mkIf cfg.exporters.node.enable {
+ port = cfg.exporters.node.port;
+ extraFlags = cfg.exporters.node.extraFlags;
+ };
+ systemd = lib.mkIf cfg.exporters.systemd.enable {
+ port = cfg.exporters.systemd.port;
+ };
};
};
}