git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #4392 from cstrahan/logstash

logstash service improvements

commitdd0758ab6b1ac3a96e99661f159a62942b31240e authorJaka Hudoklin <jakahudoklin@gmail.com> dateSun 12 Oct 2014, 23:02 (12 years ago) parent42da129fc7098a
3 files changed+91−11
nixos/modules/services/logging/logstash.nix+58−11 pkgs/tools/misc/logstash/contrib.nix+31 pkgs/top-level/all-packages.nix+2
nixos/modules/services/logging/logstash.nix+58−11
@@ -4,6 +4,9 @@ with lib;
44
55let
66 cfg = config.services.logstash;
7+ pluginPath = lib.concatStringsSep ":" cfg.plugins;
8+ havePluginPath = lib.length cfg.plugins > 0;
9+ ops = lib.optionalString;
710
811in
912
@@ -20,12 +23,50 @@ in
2023 description = "Enable logstash.";
2124 };
2225
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+
2352 enableWeb = mkOption {
2453 type = types.bool;
2554 default = false;
2655 description = "Enable the logstash web interface.";
2756 };
2857
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+
2970 inputConfig = mkOption {
3071 type = types.lines;
3172 default = ''stdin { type => "example" }'';
@@ -79,19 +120,25 @@ in
79120 wantedBy = [ "multi-user.target" ];
80121 environment = { JAVA_HOME = jre; };
81122 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+ }
86132
87− filter {
88− ${cfg.filterConfig}
89− }
133+ filter {
134+ ${cfg.filterConfig}
135+ }
90136
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}";
95142 };
96143 };
97144 };
pkgs/tools/misc/logstash/contrib.nixnew file+31
@@ -0,0 +1,31 @@
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+}
pkgs/top-level/all-packages.nix+2
@@ -1504,6 +1504,8 @@ let
15041504
15051505 logstash = callPackage ../tools/misc/logstash { };
15061506
1507+ logstash-contrib = callPackage ../tools/misc/logstash/contrib.nix { };
1508+
15071509 logstash-forwarder = callPackage ../tools/misc/logstash-forwarder { };
15081510
15091511 kippo = callPackage ../servers/kippo { };