summaryrefslogtreecommitdiffstats
path: root/lass/3modules/kapacitor.nix
diff options
context:
space:
mode:
authorlassulus <lass@lassul.us>2017-01-09 17:09:52 +0100
committerlassulus <lass@lassul.us>2017-01-09 17:09:52 +0100
commitd8a52b784450909780f771d6550444ed66d6b667 (patch)
tree450227ef0a585699dc9b07eeb942a4e7d97db7c5 /lass/3modules/kapacitor.nix
parent43eaeee506939af8dc1d169754c5279b2372a134 (diff)
l 3: add kapacitor service
Diffstat (limited to 'lass/3modules/kapacitor.nix')
-rw-r--r--lass/3modules/kapacitor.nix101
1 files changed, 101 insertions, 0 deletions
diff --git a/lass/3modules/kapacitor.nix b/lass/3modules/kapacitor.nix
new file mode 100644
index 000000000..023801987
--- /dev/null
+++ b/lass/3modules/kapacitor.nix
@@ -0,0 +1,101 @@
+{ config, lib, pkgs, ... }:
+
+with builtins;
+with lib;
+
+let
+ cfg = config.lass.kapacitor;
+
+ out = {
+ options.lass.kapacitor = api;
+ config = mkIf cfg.enable imp;
+ };
+
+ api = {
+ enable = mkEnableOption "kapacitor";
+ dataDir = mkOption {
+ type = types.str;
+ default = "/var/lib/kapacitor";
+ };
+ user = mkOption {
+ type = types.str;
+ default = "kapacitor";
+ };
+ config = mkOption {
+ type = types.str;
+ #TODO: find a good default
+ default = ''
+ hostname = "localhost"
+ data_dir = "/home/lass/.kapacitor"
+
+ [http]
+ bind-address = ":9092"
+ auth-enabled = false
+ log-enabled = true
+ write-tracing = false
+ pprof-enabled = false
+ https-enabled = false
+ https-certificate = "/etc/ssl/kapacitor.pem"
+ shutdown-timeout = "10s"
+ shared-secret = ""
+
+ [replay]
+ dir = "${cfg.dataDir}/replay"
+
+ [storage]
+ boltdb = "${cfg.dataDir}/kapacitor.db"
+
+ [task]
+ dir = "${cfg.dataDir}/tasks"
+ snapshot-interval = "1m0s"
+
+ [[influxdb]]
+ enabled = true
+ name = "default"
+ default = false
+ urls = ["http://localhost:8086"]
+ username = ""
+ password = ""
+ ssl-ca = ""
+ ssl-cert = ""
+ ssl-key = ""
+ insecure-skip-verify = false
+ timeout = "0s"
+ disable-subscriptions = false
+ subscription-protocol = "http"
+ udp-bind = ""
+ udp-buffer = 1000
+ udp-read-buffer = 0
+ startup-timeout = "5m0s"
+ subscriptions-sync-interval = "1m0s"
+ [influxdb.subscriptions]
+ [influxdb.excluded-subscriptions]
+ _kapacitor = ["autogen"]
+
+ [logging]
+ file = "STDERR"
+ level = "INFO"
+ '';
+ description = "configuration kapacitor is started with";
+ };
+ };
+
+ configFile = pkgs.writeText "kapacitor.conf" cfg.config;
+
+ imp = {
+
+ systemd.services.kapacitor = {
+ description = "kapacitor";
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+
+ restartIfChanged = true;
+
+ serviceConfig = {
+ Restart = "always";
+ ExecStart = "${pkgs.kapacitor}/bin/kapacitord -config ${configFile}";
+ };
+ };
+ };
+
+in out