2015-03-18 19:33:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.fluentd;
|
2017-08-08 22:02:56 +00:00
|
|
|
|
2024-08-27 18:43:29 +00:00
|
|
|
pluginArgs = lib.concatStringsSep " " (map (x: "-p ${x}") cfg.plugins);
|
2015-03-18 19:33:52 +00:00
|
|
|
in {
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fluentd = {
|
2024-08-27 18:43:29 +00:00
|
|
|
enable = lib.mkEnableOption "fluentd, a data/log collector";
|
2015-03-18 19:33:52 +00:00
|
|
|
|
2024-08-27 18:43:29 +00:00
|
|
|
config = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2015-03-18 19:33:52 +00:00
|
|
|
default = "";
|
|
|
|
description = "Fluentd config.";
|
|
|
|
};
|
2017-01-27 15:08:17 +00:00
|
|
|
|
2024-08-27 18:43:29 +00:00
|
|
|
package = lib.mkPackageOption pkgs "fluentd" { };
|
2017-08-08 22:02:56 +00:00
|
|
|
|
2024-08-27 18:43:29 +00:00
|
|
|
plugins = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.path;
|
2017-08-08 22:02:56 +00:00
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files
|
|
|
|
there available in your config.
|
|
|
|
'';
|
|
|
|
};
|
2015-03-18 19:33:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2024-08-27 18:43:29 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2015-03-18 19:33:52 +00:00
|
|
|
systemd.services.fluentd = with pkgs; {
|
|
|
|
description = "Fluentd Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2017-08-08 22:02:56 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}";
|
2015-04-25 12:21:27 +00:00
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
2015-03-18 19:33:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|