summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lass/3modules/kapacitor.nix31
1 files changed, 31 insertions, 0 deletions
diff --git a/lass/3modules/kapacitor.nix b/lass/3modules/kapacitor.nix
index 8524c8198..a2ee71732 100644
--- a/lass/3modules/kapacitor.nix
+++ b/lass/3modules/kapacitor.nix
@@ -21,6 +21,14 @@ let
type = types.str;
default = "kapacitor";
};
+ alarms = mkOption {
+ type = with types; attrsOf str;
+ default = {};
+ };
+ check_db = mkOption {
+ type = types.str;
+ default = "kapacitor_example";
+ };
config = mkOption {
type = types.str;
#TODO: find a good default
@@ -216,6 +224,29 @@ let
ExecStart = "${pkgs.kapacitor}/bin/kapacitord -config ${configFile}";
};
};
+
+ systemd.services.kapacitor-alarms = {
+ description = "kapacitor-alarms";
+ after = [ "kapacitor.service" ];
+ wantedBy = [ "multi-user.target" ];
+
+ restartIfChanged = true;
+
+ serviceConfig = {
+ Type = "oneshot";
+ ExecStart = pkgs.writeDash "add_alarms" ''
+ ${pkgs.kapacitor}/bin/kapacitor delete tasks \*
+ ${concatStrings (mapAttrsToList (name: alarm: ''
+ ${pkgs.kapacitor}/bin/kapacitor define ${name} \
+ -type batch \
+ -tick ${pkgs.writeText "${name}.tick" alarm} \
+ -dbrp ${cfg.check_db}.default
+ ${pkgs.kapacitor}/bin/kapacitor enable ${name}
+ '') cfg.alarms)}
+ '';
+ };
+ };
+
};
in out