From 0112e59b1f40097fb1fe4dcc239ed082cc1ac0e7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 28 Jan 2017 18:36:53 +0100 Subject: l 3 kapacitor: add alert definition --- lass/3modules/kapacitor.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lass/3modules') 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 -- cgit v1.2.3 From 6edbfeb6f5f048e5646b72b7bca241df3bdd9002 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 30 Jan 2017 22:53:28 +0100 Subject: l 3 kapacitor: better defaults --- lass/3modules/kapacitor.nix | 117 +------------------------------------------- 1 file changed, 2 insertions(+), 115 deletions(-) (limited to 'lass/3modules') diff --git a/lass/3modules/kapacitor.nix b/lass/3modules/kapacitor.nix index a2ee71732..a1e82b830 100644 --- a/lass/3modules/kapacitor.nix +++ b/lass/3modules/kapacitor.nix @@ -27,7 +27,7 @@ let }; check_db = mkOption { type = types.str; - default = "kapacitor_example"; + default = "all_data"; }; config = mkOption { type = types.str; @@ -82,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" @@ -198,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"; }; -- cgit v1.2.3 From f0a345d79b0ab80d2e38baddba7f19e40241c79a Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 30 Jan 2017 22:56:12 +0100 Subject: l 3 telegraf: split config into inputs/outputs --- lass/3modules/telegraf.nix | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'lass/3modules') diff --git a/lass/3modules/telegraf.nix b/lass/3modules/telegraf.nix index 64b323460..a54e71a9d 100644 --- a/lass/3modules/telegraf.nix +++ b/lass/3modules/telegraf.nix @@ -21,6 +21,26 @@ let type = types.str; default = "telegraf"; }; + outputs = mkOption { + type = types.str; + default = '' + [outputs.influxdb] + urls = ["http://localhost:8086"] + database = "all_data" + user_agent = "telegraf" + ''; + }; + inputs = mkOption { + type = with types; listOf str; + default = [ + '' + [cpu] + percpu = false + totalcpu = true + drop = ["cpu_time"] + '' + ]; + }; config = mkOption { type = types.str; #TODO: find a good default @@ -30,17 +50,10 @@ let [outputs] - # Configuration to send data to InfluxDB. - [outputs.influxdb] - urls = ["http://localhost:8086"] - database = "kapacitor_example" - user_agent = "telegraf" + ${cfg.outputs} + + ${concatStringsSep "\n" cfg.inputs} - # Collect metrics about cpu usage - [cpu] - percpu = false - totalcpu = true - drop = ["cpu_time"] ''; description = "configuration telegraf is started with"; }; -- cgit v1.2.3 From 920cb3456045f7ec431de68a2613e478a7e30751 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 3 Feb 2017 00:23:23 +0100 Subject: l 3 telegraf: set default db to `telegraf_db` --- lass/3modules/telegraf.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lass/3modules') diff --git a/lass/3modules/telegraf.nix b/lass/3modules/telegraf.nix index a54e71a9d..6ef775090 100644 --- a/lass/3modules/telegraf.nix +++ b/lass/3modules/telegraf.nix @@ -26,7 +26,7 @@ let default = '' [outputs.influxdb] urls = ["http://localhost:8086"] - database = "all_data" + database = "telegraf_db" user_agent = "telegraf" ''; }; -- cgit v1.2.3 From 7d9bd2024826928c028d63b6448f126966e6552c Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 3 Feb 2017 00:23:59 +0100 Subject: l 3 telegraf: add interval option --- lass/3modules/telegraf.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lass/3modules') diff --git a/lass/3modules/telegraf.nix b/lass/3modules/telegraf.nix index 6ef775090..0b3be2d69 100644 --- a/lass/3modules/telegraf.nix +++ b/lass/3modules/telegraf.nix @@ -41,12 +41,16 @@ let '' ]; }; + interval = mkOption { + type = types.str; + default = "10s"; + }; config = mkOption { type = types.str; #TODO: find a good default default = '' [agent] - interval = "1s" + interval = "${cfg.interval}" [outputs] -- cgit v1.2.3