diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2017-01-24 17:56:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-24 17:56:48 +0000 |
commit | ae4f2fd145d4d817e39c66f846f8e70b66c09aa6 (patch) | |
tree | bbd9e4526ca5426da979fa47435c04a19172d8d0 | |
parent | 7516dbe35e8813dc6015755e74908104ed023126 (diff) | |
parent | 00444cbf25fcc7d1db64e6fe482815b52f699353 (diff) | |
download | nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.tar nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.tar.gz nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.tar.bz2 nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.tar.lz nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.tar.xz nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.tar.zst nixlib-ae4f2fd145d4d817e39c66f846f8e70b66c09aa6.zip |
Merge pull request #22066 from mbrgm/journalbeat
journalbeat service: init at 5.1.2
-rw-r--r-- | lib/maintainers.nix | 1 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/logging/journalbeat.nix | 76 | ||||
-rw-r--r-- | pkgs/tools/system/journalbeat/default.nix | 34 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
5 files changed, 114 insertions, 0 deletions
diff --git a/lib/maintainers.nix b/lib/maintainers.nix index 1e9a6fe0f0d8..43e79fa2d32b 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -290,6 +290,7 @@ mbbx6spp = "Susan Potter <me@susanpotter.net>"; mbe = "Brandon Edens <brandonedens@gmail.com>"; mboes = "Mathieu Boespflug <mboes@tweag.net>"; + mbrgm = "Marius Bergmann <marius@yeai.de>"; mcmtroffaes = "Matthias C. M. Troffaes <matthias.troffaes@gmail.com>"; mdaiter = "Matthew S. Daiter <mdaiter8121@gmail.com>"; meditans = "Carlo Nucera <meditans@gmail.com>"; diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 936d579b24ca..888f6ff955fd 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -212,6 +212,7 @@ ./services/logging/awstats.nix ./services/logging/fluentd.nix ./services/logging/graylog.nix + ./services/logging/journalbeat.nix ./services/logging/klogd.nix ./services/logging/logcheck.nix ./services/logging/logrotate.nix diff --git a/nixos/modules/services/logging/journalbeat.nix b/nixos/modules/services/logging/journalbeat.nix new file mode 100644 index 000000000000..8186a3b02c37 --- /dev/null +++ b/nixos/modules/services/logging/journalbeat.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.journalbeat; + + journalbeatYml = pkgs.writeText "journalbeat.yml" '' + name: ${cfg.name} + tags: ${builtins.toJSON cfg.tags} + + journalbeat.cursor_state_file: ${cfg.stateDir}/cursor-state + + ${cfg.extraConfig} + ''; + +in +{ + options = { + + services.journalbeat = { + + enable = mkEnableOption "journalbeat"; + + name = mkOption { + type = types.str; + default = "journalbeat"; + description = "Name of the beat"; + }; + + tags = mkOption { + type = types.listOf types.str; + default = []; + description = "Tags to place on the shipped log messages"; + }; + + stateDir = mkOption { + type = types.str; + default = "/var/lib/journalbeat"; + description = "The state directory. Journalbeat's own logs and other data are stored here."; + }; + + extraConfig = mkOption { + type = types.lines; + default = '' + journalbeat: + seek_position: cursor + cursor_seek_fallback: tail + write_cursor_state: true + cursor_flush_period: 5s + clean_field_names: true + convert_to_numbers: false + move_metadata_to_field: journal + default_type: journal + ''; + description = "Any other configuration options you want to add"; + }; + + }; + }; + + config = mkIf cfg.enable { + + systemd.services.journalbeat = with pkgs; { + description = "Journalbeat log shipper"; + wantedBy = [ "multi-user.target" ]; + preStart = '' + mkdir -p ${cfg.stateDir}/data + mkdir -p ${cfg.stateDir}/logs + ''; + serviceConfig = { + ExecStart = "${pkgs.journalbeat}/bin/journalbeat -c ${journalbeatYml} -path.data ${cfg.stateDir}/data -path.logs ${cfg.stateDir}/logs"; + }; + }; + }; +} diff --git a/pkgs/tools/system/journalbeat/default.nix b/pkgs/tools/system/journalbeat/default.nix new file mode 100644 index 000000000000..5a66fcf52990 --- /dev/null +++ b/pkgs/tools/system/journalbeat/default.nix @@ -0,0 +1,34 @@ +{ lib, pkgs, buildGoPackage, fetchFromGitHub, makeWrapper }: + +let + + libPath = lib.makeLibraryPath [ pkgs.systemd.lib ]; + +in buildGoPackage rec { + + name = "journalbeat-${version}"; + version = "5.1.2"; + + goPackagePath = "github.com/mheese/journalbeat"; + + buildInputs = [ makeWrapper pkgs.systemd ]; + + postInstall = '' + wrapProgram $bin/bin/journalbeat \ + --prefix LD_LIBRARY_PATH : ${libPath} + ''; + + src = fetchFromGitHub { + owner = "mheese"; + repo = "journalbeat"; + rev = "v${version}"; + sha256 = "179jayzvd5k4mwhn73yflbzl5md1fmv7a9hb8vz2ir76lvr33g3l"; + }; + + meta = with lib; { + homepage = https://github.com/mheese/journalbeat; + description = "Journalbeat is a log shipper from systemd/journald to Logstash/Elasticsearch"; + license = licenses.asl20; + maintainers = with maintainers; [ mbrgm ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6328455aa081..4eeb5ef6748d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2361,6 +2361,8 @@ in gcc = gcc49; # doesn't build with gcc5 }; + journalbeat = callPackage ../tools/system/journalbeat { }; + jp = callPackage ../development/tools/jp { }; jp2a = callPackage ../applications/misc/jp2a { }; |