New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
services.logstash: default options, examples and address update #21311
Conversation
@makefu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @offlinehacker, @cstrahan and @edolstra to be potential reviewers. |
Unrelated to this patch, but the tests currently fail for me:
The default configuration made logstash stopped after startup. Presumably stdin is closed in the service. I added user/group support so that logstash does not need to be run as root: diff --git a/nixos/modules/services/logging/logstash.nix b/nixos/modules/services/logging/logstash.nix
index 74ad037834..b1a8aa8784 100644
--- a/nixos/modules/services/logging/logstash.nix
+++ b/nixos/modules/services/logging/logstash.nix
@@ -38,6 +38,16 @@ in
description = "Logstash package to use.";
};
+ extraGroups = mkOption {
+ type = types.listOf types.str;
+ default = [];
+ example = ["systemd-journal"];
+ description = ''
+ List of groups which logstash user is added to. This might be used to
+ grant logstash access to certain types of logs.
+ '';
+ };
+
plugins = mkOption {
type = types.listOf types.path;
default = [ ];
@@ -77,7 +87,7 @@ in
inputConfig = mkOption {
type = types.lines;
- default = ''stdin { type => "example" }'';
+ default = ''file { path => "/var/log/boot.log" }'';
description = "Logstash input configuration.";
example = ''
# Read from journal
@@ -123,12 +133,26 @@ in
###### implementation
config = mkIf cfg.enable {
+ users.extraUsers.logstash = {
+ home = "/var/lib/logstash";
+ extraGroups = cfg.extraGroups;
+ createHome = true;
+ };
systemd.services.logstash = with pkgs; {
description = "Logstash Daemon";
wantedBy = [ "multi-user.target" ];
- environment = { JAVA_HOME = jre; };
+ environment = {
+ JAVA_HOME = jre;
+ HOME = "/var/lib/logstash";
+ };
path = [ pkgs.bash ];
+ preStart = ''
+ install -d -m 755 -o logstash /var/lib/logstash
+ chown -R logstash /var/lib/logstash
+ '';
serviceConfig = {
+ User = "logstash";
+ PermissionsStartOnly = true;
ExecStart =
"${cfg.package}/bin/logstash agent " +
"-w ${toString cfg.filterWorkers} " + |
Error in travis-ci is:
|
@pSub i cannot reproduce the build error described by @Mic92 https://gist.github.com/makefu/63f4defda611a4f859a843c8a542b1e1 Adding a separate user for logstash was not in scope of this PR - it was simply for cleaning up insane defaults. |
981553c
to
e9c6cf0
Compare
At least the travis job is fine now. I will try to test this locally in the next few days. |
thanks! |
Motivation for this change
services.logstash contains obsolete defaults,examples and uses
address
instead oflistenAddress
. Cleaning up these defaults will result in a logstash service which works out of the box and the documentation will show a sane example configThings done