@@ -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 };