2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let cfg = config.services.SystemdJournal2Gelf;
|
|
|
|
in
|
|
|
|
|
|
|
|
{ options = {
|
|
|
|
services.SystemdJournal2Gelf = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable SystemdJournal2Gelf.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
graylogServer = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "graylog2.example.com:11201";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Host and port of your graylog2 input. This should be a GELF
|
|
|
|
UDP input.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.separatedString " ";
|
|
|
|
default = "";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Any extra flags to pass to SystemdJournal2Gelf. Note that
|
2022-08-12 12:06:08 +00:00
|
|
|
these are basically `journalctl` flags.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "systemd-journal2gelf" { };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|