diff --git a/nixos/modules/services/monitoring/statsd.nix b/nixos/modules/services/monitoring/statsd.nix index 74f3deb4c29..942ce72f6a3 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";