logstash service improvements

* add logstash-contrib plugins package
* add additional options to the logstash service

+91 -11
+58 -11
nixos/modules/services/logging/logstash.nix
··· 4 4 5 5 let 6 6 cfg = config.services.logstash; 7 + pluginPath = lib.concatStringsSep ":" cfg.plugins; 8 + havePluginPath = lib.length cfg.plugins > 0; 9 + ops = lib.optionalString; 7 10 8 11 in 9 12 ··· 20 23 description = "Enable logstash."; 21 24 }; 22 25 26 + package = mkOption { 27 + type = types.package; 28 + default = pkgs.logstash; 29 + example = literalExample "pkgs.logstash"; 30 + description = "Logstash package to use."; 31 + }; 32 + 33 + plugins = mkOption { 34 + type = types.listOf types.path; 35 + default = [ ]; 36 + example = literalExample "[ pkgs.logstash-contrib ]"; 37 + description = "The paths to find other logstash plugins in."; 38 + }; 39 + 40 + watchdogTimeout = mkOption { 41 + type = types.int; 42 + default = 10; 43 + description = "Set watchdog timeout value in seconds."; 44 + }; 45 + 46 + filterWorkers = mkOption { 47 + type = types.int; 48 + default = 1; 49 + description = "The quantity of filter workers to run."; 50 + }; 51 + 23 52 enableWeb = mkOption { 24 53 type = types.bool; 25 54 default = false; 26 55 description = "Enable the logstash web interface."; 27 56 }; 28 57 58 + address = mkOption { 59 + type = types.str; 60 + default = "0.0.0.0"; 61 + description = "Address on which to start webserver."; 62 + }; 63 + 64 + port = mkOption { 65 + type = types.str; 66 + default = "9292"; 67 + description = "Port on which to start webserver."; 68 + }; 69 + 29 70 inputConfig = mkOption { 30 71 type = types.lines; 31 72 default = ''stdin { type => "example" }''; ··· 79 120 wantedBy = [ "multi-user.target" ]; 80 121 environment = { JAVA_HOME = jre; }; 81 122 serviceConfig = { 82 - ExecStart = "${logstash}/bin/logstash agent -f ${writeText "logstash.conf" '' 83 - input { 84 - ${cfg.inputConfig} 85 - } 123 + ExecStart = 124 + "${cfg.package}/bin/logstash agent " + 125 + "-w ${toString cfg.filterWorkers} " + 126 + ops havePluginPath "--pluginpath ${pluginPath} " + 127 + "--watchdog-timeout ${toString cfg.watchdogTimeout} " + 128 + "-f ${writeText "logstash.conf" '' 129 + input { 130 + ${cfg.inputConfig} 131 + } 86 132 87 - filter { 88 - ${cfg.filterConfig} 89 - } 133 + filter { 134 + ${cfg.filterConfig} 135 + } 90 136 91 - output { 92 - ${cfg.outputConfig} 93 - } 94 - ''} ${optionalString cfg.enableWeb "-- web"}"; 137 + output { 138 + ${cfg.outputConfig} 139 + } 140 + ''} " + 141 + ops cfg.enableWeb "-- web -a ${cfg.address} -p ${cfg.port}"; 95 142 }; 96 143 }; 97 144 };
+31
pkgs/tools/misc/logstash/contrib.nix
··· 1 + { stdenv, lib, fetchzip }: 2 + 3 + # Note that plugins are supposed to be installed as: 4 + # $path/logstash/{inputs,codecs,filters,outputs}/*.rb 5 + stdenv.mkDerivation rec { 6 + version = "1.4.2"; 7 + name = "logstash-contrib-${version}"; 8 + 9 + src = fetchzip { 10 + url = "http://download.elasticsearch.org/logstash/logstash/logstash-contrib-${version}.tar.gz"; 11 + sha256 = "1yj8sf3b526gixh3c6zhgkfpg4f0c72p1lzhfhdx8b3lw7zjkj0k"; 12 + }; 13 + 14 + dontBuild = true; 15 + dontPatchELF = true; 16 + dontStrip = true; 17 + dontPatchShebangs = true; 18 + 19 + installPhase = '' 20 + mkdir -p $out/logstash 21 + cp -r lib/* $out 22 + ''; 23 + 24 + meta = with lib; { 25 + description = "Community-maintained logstash plugins"; 26 + homepage = https://github.com/elasticsearch/logstash-contrib; 27 + license = stdenv.lib.licenses.asl20; 28 + platforms = stdenv.lib.platforms.unix; 29 + maintainers = with maintainers; [ cstrahan ]; 30 + }; 31 + }
+2
pkgs/top-level/all-packages.nix
··· 1494 1494 1495 1495 logstash = callPackage ../tools/misc/logstash { }; 1496 1496 1497 + logstash-contrib = callPackage ../tools/misc/logstash/contrib.nix { }; 1498 + 1497 1499 logstash-forwarder = callPackage ../tools/misc/logstash-forwarder { }; 1498 1500 1499 1501 kippo = callPackage ../servers/kippo { };