about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCharles Strahan <charles.c.strahan@gmail.com>2014-10-05 13:57:15 -0400
committerCharles Strahan <charles.c.strahan@gmail.com>2014-10-05 21:53:05 -0400
commitfc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b (patch)
treed387bdfc8c8572fcf2ef3511096f3b11574bc4d3
parent58de52c6f0e063fa152b94908075f3b6e4f9cea4 (diff)
downloadnixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.tar
nixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.tar.gz
nixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.tar.bz2
nixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.tar.lz
nixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.tar.xz
nixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.tar.zst
nixlib-fc7098abf772ad5b4e737f4e6df1fd8b7e9e7f2b.zip
logstash service improvements
* add logstash-contrib plugins package
* add additional options to the logstash service
-rw-r--r--nixos/modules/services/logging/logstash.nix69
-rw-r--r--pkgs/tools/misc/logstash/contrib.nix31
-rw-r--r--pkgs/top-level/all-packages.nix2
3 files changed, 91 insertions, 11 deletions
diff --git a/nixos/modules/services/logging/logstash.nix b/nixos/modules/services/logging/logstash.nix
index df81ac142dc3..41f71be2365c 100644
--- a/nixos/modules/services/logging/logstash.nix
+++ b/nixos/modules/services/logging/logstash.nix
@@ -4,6 +4,9 @@ with lib;
 
 let
   cfg = config.services.logstash;
+  pluginPath = lib.concatStringsSep ":" cfg.plugins;
+  havePluginPath = lib.length cfg.plugins > 0;
+  ops = lib.optionalString;
 
 in
 
@@ -20,12 +23,50 @@ in
         description = "Enable logstash.";
       };
 
+      package = mkOption {
+        type = types.package;
+        default = pkgs.logstash;
+        example = literalExample "pkgs.logstash";
+        description = "Logstash package to use.";
+      };
+
+      plugins = mkOption {
+        type = types.listOf types.path;
+        default = [ ];
+        example = literalExample "[ pkgs.logstash-contrib ]";
+        description = "The paths to find other logstash plugins in.";
+      };
+
+      watchdogTimeout = mkOption {
+        type = types.int;
+        default = 10;
+        description = "Set watchdog timeout value in seconds.";
+      };
+
+      filterWorkers = mkOption {
+        type = types.int;
+        default = 1;
+        description = "The quantity of filter workers to run.";
+      };
+
       enableWeb = mkOption {
         type = types.bool;
         default = false;
         description = "Enable the logstash web interface.";
       };
 
+      address = mkOption {
+        type = types.str;
+        default = "0.0.0.0";
+        description = "Address on which to start webserver.";
+      };
+
+      port = mkOption {
+        type = types.str;
+        default = "9292";
+        description = "Port on which to start webserver.";
+      };
+
       inputConfig = mkOption {
         type = types.lines;
         default = ''stdin { type => "example" }'';
@@ -79,19 +120,25 @@ in
       wantedBy = [ "multi-user.target" ];
       environment = { JAVA_HOME = jre; };
       serviceConfig = {
-        ExecStart = "${logstash}/bin/logstash agent -f ${writeText "logstash.conf" ''
-          input {
-            ${cfg.inputConfig}
-          }
+        ExecStart =
+          "${cfg.package}/bin/logstash agent " +
+          "-w ${toString cfg.filterWorkers} " +
+          ops havePluginPath "--pluginpath ${pluginPath} " +
+          "--watchdog-timeout ${toString cfg.watchdogTimeout} " +
+          "-f ${writeText "logstash.conf" ''
+            input {
+              ${cfg.inputConfig}
+            }
 
-          filter {
-            ${cfg.filterConfig}
-          }
+            filter {
+              ${cfg.filterConfig}
+            }
 
-          output {
-            ${cfg.outputConfig}
-          }
-        ''} ${optionalString cfg.enableWeb "-- web"}";
+            output {
+              ${cfg.outputConfig}
+            }
+          ''} " +
+          ops cfg.enableWeb "-- web -a ${cfg.address} -p ${cfg.port}";
       };
     };
   };
diff --git a/pkgs/tools/misc/logstash/contrib.nix b/pkgs/tools/misc/logstash/contrib.nix
new file mode 100644
index 000000000000..c019803f9035
--- /dev/null
+++ b/pkgs/tools/misc/logstash/contrib.nix
@@ -0,0 +1,31 @@
+{ stdenv, lib, fetchzip }:
+
+# Note that plugins are supposed to be installed as:
+#   $path/logstash/{inputs,codecs,filters,outputs}/*.rb 
+stdenv.mkDerivation rec {
+  version = "1.4.2";
+  name = "logstash-contrib-${version}";
+
+  src = fetchzip {
+   url = "http://download.elasticsearch.org/logstash/logstash/logstash-contrib-${version}.tar.gz";
+   sha256 = "1yj8sf3b526gixh3c6zhgkfpg4f0c72p1lzhfhdx8b3lw7zjkj0k";
+  };
+
+  dontBuild    = true;
+  dontPatchELF = true;
+  dontStrip    = true;
+  dontPatchShebangs = true;
+
+  installPhase = ''
+    mkdir -p $out/logstash
+    cp -r lib/* $out
+  '';
+
+  meta = with lib; {
+    description = "Community-maintained logstash plugins";
+    homepage    = https://github.com/elasticsearch/logstash-contrib;
+    license     = stdenv.lib.licenses.asl20;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with maintainers; [ cstrahan ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f4286623be8d..ba26fca87f2b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1494,6 +1494,8 @@ let
 
   logstash = callPackage ../tools/misc/logstash { };
 
+  logstash-contrib = callPackage ../tools/misc/logstash/contrib.nix { };
+
   logstash-forwarder = callPackage ../tools/misc/logstash-forwarder { };
 
   kippo = callPackage ../servers/kippo { };