summary refs log tree commit diff
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2017-05-25 18:23:45 +0100
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2017-05-25 19:04:40 +0100
commit80918692e1d865e75cb2286705d392f12829f728 (patch)
tree907bf021cdfd6da292864011f72e0b549ac04284
parente1239fdb1b0489f122f7497e714c86f7b6199077 (diff)
downloadnixpkgs-80918692e1d865e75cb2286705d392f12829f728.tar
nixpkgs-80918692e1d865e75cb2286705d392f12829f728.tar.gz
nixpkgs-80918692e1d865e75cb2286705d392f12829f728.tar.bz2
nixpkgs-80918692e1d865e75cb2286705d392f12829f728.tar.lz
nixpkgs-80918692e1d865e75cb2286705d392f12829f728.tar.xz
nixpkgs-80918692e1d865e75cb2286705d392f12829f728.tar.zst
nixpkgs-80918692e1d865e75cb2286705d392f12829f728.zip
SystemdJournal2Gelf.service: new service
-rw-r--r--nixos/modules/module-list.nix3
-rw-r--r--nixos/modules/services/logging/SystemdJournal2Gelf.nix59
2 files changed, 61 insertions, 1 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index a358344a888..a3405c069b3 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 00000000000..e90d9e7a12b
--- /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 <literal>journalctl</literal> 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