summaryrefslogtreecommitdiffstats
path: root/lass/3modules/kapacitor.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2017-02-04 14:31:47 +0100
committermakefu <github@syntax-fehler.de>2017-02-04 14:31:47 +0100
commitd6c9edd9dc860d560d4ea7a727962aaf93d09322 (patch)
treeaefb49a9372b959cd722bdfcf51001783cda8bb1 /lass/3modules/kapacitor.nix
parentd2df5375e705e55764b4cacd4ea32dffcb4c6041 (diff)
parent8daef993dcb6149a02c72a4895d6e808a6c6a8d4 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lass/3modules/kapacitor.nix')
-rw-r--r--lass/3modules/kapacitor.nix146
1 files changed, 32 insertions, 114 deletions
diff --git a/lass/3modules/kapacitor.nix b/lass/3modules/kapacitor.nix
index 8524c8198..a1e82b830 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 = "all_data";
+ };
config = mkOption {
type = types.str;
#TODO: find a good default
@@ -74,115 +82,7 @@ let
[logging]
file = "STDERR"
- level = "INFO"
-
- [collectd]
- enabled = false
- bind-address = ":25826"
- database = "collectd"
- retention-policy = ""
- batch-size = 5000
- batch-pending = 10
- batch-timeout = "10s"
- read-buffer = 0
- typesdb = "/usr/share/collectd/types.db"
-
- [opentsdb]
- enabled = false
- bind-address = ":4242"
- database = "opentsdb"
- retention-policy = ""
- consistency-level = "one"
- tls-enabled = false
- certificate = "/etc/ssl/influxdb.pem"
- batch-size = 1000
- batch-pending = 5
- batch-timeout = "1s"
- log-point-errors = true
-
- [smtp]
- enabled = false
- host = "localhost"
- port = 25
- username = ""
- password = ""
- no-verify = false
- global = false
- state-changes-only = false
- from = ""
- idle-timeout = "30s"
-
- [opsgenie]
- enabled = false
- api-key = ""
- url = "https://api.opsgenie.com/v1/json/alert"
- recovery_url = "https://api.opsgenie.com/v1/json/alert/note"
- global = false
-
- [victorops]
- enabled = false
- api-key = ""
- routing-key = ""
- url = "https://alert.victorops.com/integrations/generic/20131114/alert"
- global = false
-
- [pagerduty]
- enabled = false
- url = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
- service-key = ""
- global = false
-
- [sensu]
- enabled = false
- addr = ""
- source = "Kapacitor"
-
- [slack]
- enabled = false
- url = ""
- channel = ""
- global = false
- state-changes-only = false
-
- [telegram]
- enabled = false
- url = "https://api.telegram.org/bot"
- token = ""
- chat-id = ""
- parse-mode = ""
- disable-web-page-preview = false
- disable-notification = false
- global = false
- state-changes-only = false
-
- [hipchat]
- enabled = false
- url = ""
- token = ""
- room = ""
- global = false
- state-changes-only = false
-
- [alerta]
- enabled = false
- url = ""
- token = ""
- environment = ""
- origin = ""
-
- [reporting]
- enabled = true
- url = "https://usage.influxdata.com"
-
- [stats]
- enabled = true
- stats-interval = "10s"
- database = "_kapacitor"
- retention-policy = "autogen"
- timing-sample-rate = 0.1
- timing-movavg-size = 1000
-
- [udf]
+ level = "DEBUG"
[deadman]
interval = "10s"
@@ -190,11 +90,6 @@ let
id = "{{ .Group }}:NODE_NAME for task '{{ .TaskName }}'"
message = "{{ .ID }} is {{ if eq .Level \"OK\" }}alive{{ else }}dead{{ end }}: {{ index .Fields \"emitted\" | printf \"%0.3f\" }} points/INTERVAL."
global = false
-
- [talk]
- enabled = false
- url = ""
- author_name = ""
'';
description = "configuration kapacitor is started with";
};
@@ -216,6 +111,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