mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-16 09:54:52 +00:00
63 lines
1.2 KiB
Nix
63 lines
1.2 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
cfg = config.services.logstash;
|
|
|
|
in
|
|
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
services.logstash = {
|
|
enable = mkOption {
|
|
default = false;
|
|
description = "Enable logstash";
|
|
};
|
|
|
|
inputConfig = mkOption {
|
|
default = ''stdin { type => "example" }'';
|
|
description = "Logstash input configuration";
|
|
};
|
|
|
|
filterConfig = mkOption {
|
|
default = ''noop {}'';
|
|
description = "logstash filter configuration";
|
|
};
|
|
|
|
outputConfig = mkOption {
|
|
default = ''stdout { debug => true debug_format => "json"}'';
|
|
description = "Logstash output configuration";
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.logstash = with pkgs; {
|
|
description = "Logstash daemon";
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${jre}/bin/java -jar ${logstash} agent -f ${writeText "logstash.conf" ''
|
|
input {
|
|
${cfg.inputConfig}
|
|
}
|
|
|
|
filter {
|
|
${cfg.filterConfig}
|
|
}
|
|
|
|
output {
|
|
${cfg.outputConfig}
|
|
}
|
|
''}";
|
|
};
|
|
};
|
|
};
|
|
}
|