2017-05-25 17:23:45 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let cfg = config.services.SystemdJournal2Gelf;
|
|
|
|
in
|
|
|
|
|
|
|
|
{ options = {
|
|
|
|
services.SystemdJournal2Gelf = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2017-05-25 17:23:45 +00:00
|
|
|
Whether to enable SystemdJournal2Gelf.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
graylogServer = mkOption {
|
2019-08-08 20:48:27 +00:00
|
|
|
type = types.str;
|
2017-05-25 17:23:45 +00:00
|
|
|
example = "graylog2.example.com:11201";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2017-05-25 17:23:45 +00:00
|
|
|
Host and port of your graylog2 input. This should be a GELF
|
|
|
|
UDP input.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
2019-08-08 20:48:27 +00:00
|
|
|
type = types.separatedString " ";
|
2017-05-25 17:23:45 +00:00
|
|
|
default = "";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2017-05-25 17:23:45 +00:00
|
|
|
Any extra flags to pass to SystemdJournal2Gelf. Note that
|
2022-07-28 21:19:15 +00:00
|
|
|
these are basically `journalctl` flags.
|
2017-05-25 17:23:45 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.systemd-journal2gelf;
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression "pkgs.systemd-journal2gelf";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2017-05-25 17:23:45 +00:00
|
|
|
SystemdJournal2Gelf package to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.SystemdJournal2Gelf = {
|
|
|
|
description = "SystemdJournal2Gelf";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${cfg.package}/bin/SystemdJournal2Gelf ${cfg.graylogServer} --follow ${cfg.extraOptions}";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = "30";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2019-08-08 20:48:27 +00:00
|
|
|
}
|