Add netdata configuration
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Oct 2020 09:42:28 +0000 (11:42 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Oct 2020 09:42:28 +0000 (11:42 +0200)
modules/private/environment.nix
modules/private/monitoring/status.nix
modules/private/system/eldiron.nix
modules/private/system/monitoring-1.nix
nixops/secrets

index 0f6f3e2d50854f3f260c36afaca52a8b19d16db8..a8799d26e492ef821edd7aae8d194b1bcf94b82f 100644 (file)
@@ -561,6 +561,8 @@ in
           nrdp_tokens = mkOption { type = listOf str; description = "Tokens allowed to push status update"; };
           slack_url = mkOption { type = str; description = "Slack webhook url to push status update"; };
           slack_channel = mkOption { type = str; description = "Slack channel to push status update"; };
+          netdata_aggregator = mkOption { type = str; description = "Url where netdata information should be sent"; };
+          netdata_keys = mkOption { type = attrsOf str; description = "netdata host keys"; };
           contacts = mkOption { type = attrsOf unspecified; description = "Contact dicts to fill naemon objects"; };
           email_check = mkOption {
             description = "Emails services to check";
index 4f5f4bbd96136a7d50ce02e591b5f6d255136cd9..4ca0327e80e88d7a6650fb1ba2a7a5d3c34e4a7a 100644 (file)
       recommendedOptimisation = true;
       recommendedGzipSettings = true;
       recommendedProxySettings = true;
+      upstreams."netdata".servers = { "127.0.0.1:19999" = {}; };
+      upstreams."netdata".extraConfig = ''
+        keepalive 64;
+        '';
       virtualHosts."status.immae.eu" = {
         acmeRoot = config.myServices.certificates.webroot;
         useACMEHost = name;
         forceSSL = true;
         locations."/".proxyPass = "http://unix:/run/naemon-status/socket.sock:/";
+
+        locations."= /netdata".return = "301 /netdata/";
+        locations."~ /netdata/(?<ndpath>.*)".extraConfig = ''
+          proxy_redirect off;
+          proxy_set_header Host $host;
+
+          proxy_set_header X-Forwarded-Host $host;
+          proxy_set_header X-Forwarded-Server $host;
+          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+          proxy_http_version 1.1;
+          proxy_pass_request_headers on;
+          proxy_set_header Connection "keep-alive";
+          proxy_store off;
+          proxy_pass http://netdata/$ndpath$is_args$args;
+
+          gzip on;
+          gzip_proxied any;
+          gzip_types *;
+          '';
       };
     };
     security.acme.certs."${name}" = {
index 15ddd40f56cdd550ac2689353a3a96f322120129..f11afb675e2d5f5fd27e70d9aa5332be038821f0 100644 (file)
   services.duplyBackup.enable = false;
   services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
 
+  services.netdata.enable = true;
+  services.netdata.config.global."memory mode" = "none";
+  services.netdata.config.health."enabled" = "no";
+  services.netdata.config.web.mode = "none";
+  environment.etc."netdata/stream.conf".text = ''
+    [stream]
+        enabled = yes
+        destination = ${config.myEnv.monitoring.netdata_aggregator}
+        api key = ${config.myEnv.monitoring.netdata_keys.eldiron}
+  '';
   secrets.keys = [
     {
       dest = "zrepl_backup/identity";
index 2241b2b71d579be9e952aea089651cb2df9f9878..188162ac99605efff4e04725ee6cfb63778a9d98 100644 (file)
     })
   ];
 
+  services.netdata.enable = true;
+  services.netdata.config.web."allow dashboard from" = "localhost";
+  services.netdata.config.web."allow badges from" = "*";
+  services.netdata.config.web."allow streaming from" = "*";
+  services.netdata.config.web."allow netdata.conf from" = "fd*";
+  services.netdata.config.web."allow management from" = "fd*";
+  networking.firewall.allowedTCPPorts = [ 19999 ];
+  environment.etc."netdata/stream.conf".text = builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList (_: key: ''
+    [${key}]
+        enabled = yes
+        default history = 3600
+        default memory = ram
+        health enabled by default = auto
+  '') config.myEnv.monitoring.netdata_keys);
   # This value determines the NixOS release with which your system is
   # to be compatible, in order to avoid breaking some software such as
   # database servers. You should change this only after NixOS release
index 4ce3c27d2e3db66640a5478aae93b813b7005061..c91ba443bf2849b8fb81fc72818b77be77b3aabf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4ce3c27d2e3db66640a5478aae93b813b7005061
+Subproject commit c91ba443bf2849b8fb81fc72818b77be77b3aabf