My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nomicon/nixos/modules/services/logging/logstash.nix

63 lines
1.2 KiB

{ 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}
}
''}";
};
};
};
}