about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/statsd.nix
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2014-09-11 18:11:16 +0200
committerJaka Hudoklin <jakahudoklin@gmail.com>2014-09-11 18:11:16 +0200
commitbc6b180d909b2f67a3d3db173b3eb889304df85c (patch)
tree38990038577eddc3d378cf923a9a772ed4052642 /nixos/modules/services/monitoring/statsd.nix
parentdbae0b628e88cb80648c8c0b927b720618910669 (diff)
downloadnixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.tar
nixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.tar.gz
nixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.tar.bz2
nixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.tar.lz
nixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.tar.xz
nixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.tar.zst
nixlib-bc6b180d909b2f67a3d3db173b3eb889304df85c.zip
nixos/statsd: add support for external backends, fix a few options
Diffstat (limited to 'nixos/modules/services/monitoring/statsd.nix')
-rw-r--r--nixos/modules/services/monitoring/statsd.nix32
1 files changed, 22 insertions, 10 deletions
diff --git a/nixos/modules/services/monitoring/statsd.nix b/nixos/modules/services/monitoring/statsd.nix
index 74f3deb4c290..942ce72f6a36 100644
--- a/nixos/modules/services/monitoring/statsd.nix
+++ b/nixos/modules/services/monitoring/statsd.nix
@@ -8,13 +8,20 @@ let
 
   configFile = pkgs.writeText "statsd.conf" ''
     {
-      host: "${cfg.host}",
+      address: "${cfg.host}",
       port: "${toString cfg.port}",
       mgmt_address: "${cfg.mgmt_address}",
       mgmt_port: "${toString cfg.mgmt_port}",
-      backends: [${concatMapStrings (el: ''"./backends/${el}",'') cfg.backends}],
-      graphiteHost: "${cfg.graphiteHost}",
-      graphitePort: "${toString cfg.graphitePort}",
+      backends: [${concatMapStringsSep "," (el: if (nixType el) == "string" then ''"./backends/${el}"'' else ''"${head el.names}"'') cfg.backends}],
+      ${optionalString (cfg.graphiteHost!=null) ''graphiteHost: "${cfg.graphiteHost}",''}
+      ${optionalString (cfg.graphitePort!=null) ''graphitePort: "${toString cfg.graphitePort}",''}
+      console: {
+        prettyprint: false
+      },
+      log: {
+        backend: "syslog"
+      },
+      automaticConfigReload: false${optionalString (cfg.extraConfig != null) ","}
       ${cfg.extraConfig}
     }
   '';
@@ -60,24 +67,26 @@ in
     backends = mkOption {
       description = "List of backends statsd will use for data persistance";
       default = ["graphite"];
+      example = ["graphite" pkgs.nodePackages."statsd-influxdb-backend"];
+      type = types.listOf (types.either types.str types.package);
     };
 
     graphiteHost = mkOption {
       description = "Hostname or IP of Graphite server";
-      default = config.services.graphite.web.host;
-      type = types.str;
+      default = null;
+      type = types.nullOr types.str;
     };
 
     graphitePort = mkOption {
       description = "Port of Graphite server (i.e. carbon-cache).";
-      default = 2003;
-      type = types.uniq types.int;
+      default = null;
+      type = types.nullOr types.int;
     };
 
     extraConfig = mkOption {
-      default = "";
       description = "Extra configuration options for statsd";
-      type = types.str;
+      default = "";
+      type = types.nullOr types.str;
     };
 
   };
@@ -95,6 +104,9 @@ in
     systemd.services.statsd = {
       description = "Statsd Server";
       wantedBy = [ "multi-user.target" ];
+      environment = {
+        NODE_PATH=concatMapStringsSep ":" (el: "${el}/lib/node_modules") (filter (el: (nixType el) != "string") cfg.backends);
+      };
       serviceConfig = {
         ExecStart = "${pkgs.nodePackages.statsd}/bin/statsd ${configFile}";
         User = "statsd";