diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index a358344a8880..a3405c069b34 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -239,8 +239,9 @@ ./services/logging/logrotate.nix ./services/logging/logstash.nix ./services/logging/rsyslogd.nix - ./services/logging/syslogd.nix + ./services/logging/SystemdJournal2Gelf.nix ./services/logging/syslog-ng.nix + ./services/logging/syslogd.nix ./services/mail/dovecot.nix ./services/mail/dspam.nix ./services/mail/exim.nix diff --git a/nixos/modules/services/logging/SystemdJournal2Gelf.nix b/nixos/modules/services/logging/SystemdJournal2Gelf.nix new file mode 100644 index 000000000000..e90d9e7a12b6 --- /dev/null +++ b/nixos/modules/services/logging/SystemdJournal2Gelf.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.SystemdJournal2Gelf; +in + +{ options = { + services.SystemdJournal2Gelf = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable SystemdJournal2Gelf. + ''; + }; + + graylogServer = mkOption { + type = types.string; + example = "graylog2.example.com:11201"; + description = '' + Host and port of your graylog2 input. This should be a GELF + UDP input. + ''; + }; + + extraOptions = mkOption { + type = types.string; + default = ""; + description = '' + Any extra flags to pass to SystemdJournal2Gelf. Note that + these are basically journalctl flags. + ''; + }; + + package = mkOption { + type = types.package; + default = pkgs.systemd-journal2gelf; + description = '' + 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"; + }; + }; + }; +} \ No newline at end of file