Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fdb4b55a0964
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8cc52aa5d922
Choose a head ref
  • 6 commits
  • 4 files changed
  • 2 contributors

Commits on Nov 10, 2020

  1. nixos/loki: add logcli to system path

    Admins quite likely want to query loki for debugging purpose.
    Mic92 committed Nov 10, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    Mic92 Jörg Thalheim
    Copy the full SHA
    689eb49 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    Mic92 Jörg Thalheim
    Copy the full SHA
    88d1da8 View commit details
  3. nixos/loki: mergeable configuration

    type.attrs is not mergable
    Mic92 committed Nov 10, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    Mic92 Jörg Thalheim
    Copy the full SHA
    4c64fa2 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    Mic92 Jörg Thalheim
    Copy the full SHA
    31a0b5d View commit details
  5. loki: reference nixosTests

    Mic92 committed Nov 10, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    Mic92 Jörg Thalheim
    Copy the full SHA
    37a7436 View commit details
  6. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8cc52aa View commit details
Showing with 21 additions and 16 deletions.
  1. +5 −14 nixos/modules/services/logging/promtail.nix
  2. +3 −1 nixos/modules/services/monitoring/loki.nix
  3. +2 −0 nixos/tests/loki.nix
  4. +11 −1 pkgs/servers/monitoring/loki/default.nix
19 changes: 5 additions & 14 deletions nixos/modules/services/logging/promtail.nix
Original file line number Diff line number Diff line change
@@ -6,25 +6,14 @@ let
echo '${builtins.toJSON conf}' | ${pkgs.buildPackages.jq}/bin/jq 'del(._module)' > $out
'';

allowSystemdJournal = cfg.configuration ? scrape_configs && lib.any (v: v ? journal) cfg.configuration.scrape_configs;
in {
options.services.promtail = with types; {
enable = mkEnableOption "the Promtail ingresser";


configuration = mkOption {
type = with lib.types; let
valueType = nullOr (oneOf [
bool
int
float
str
(lazyAttrsOf valueType)
(listOf valueType)
]) // {
description = "JSON value";
emptyValue.value = {};
deprecationMessage = null;
};
in valueType;
type = (pkgs.formats.json {}).type;
description = ''
Specify the configuration for Promtail in Nix.
'';
@@ -80,6 +69,8 @@ in {
RestrictRealtime = true;
MemoryDenyWriteExecute = true;
PrivateUsers = true;

SupplementaryGroups = lib.optional (allowSystemdJournal) "systemd-journal";
} // (optionalAttrs (!pkgs.stdenv.isAarch64) { # FIXME: figure out why this breaks on aarch64
SystemCallFilter = "@system-service";
});
4 changes: 3 additions & 1 deletion nixos/modules/services/monitoring/loki.nix
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ in {
};

configuration = mkOption {
type = types.attrs;
type = (pkgs.formats.json {}).type;
default = {};
description = ''
Specify the configuration for Loki in Nix.
@@ -78,6 +78,8 @@ in {
'';
}];

environment.systemPackages = [ pkgs.grafana-loki ]; # logcli

users.groups.${cfg.group} = { };
users.users.${cfg.user} = {
description = "Loki Service User";
2 changes: 2 additions & 0 deletions nixos/tests/loki.nix
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@ import ./make-test-python.nix ({ lib, pkgs, ... }:
machine.wait_for_open_port(3100)
machine.wait_for_open_port(9080)
machine.succeed("echo 'Loki Ingestion Test' > /var/log/testlog")
# should not have access to journal unless specified
machine.fail("systemctl show --property=SupplementaryGroups promtail | grep -q systemd-journal")
machine.wait_until_succeeds(
"${pkgs.grafana-loki}/bin/logcli --addr='http://localhost:3100' query --no-labels '{job=\"varlogs\",filename=\"/var/log/testlog\"}' | grep -q 'Loki Ingestion Test'"
)
12 changes: 11 additions & 1 deletion pkgs/servers/monitoring/loki/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{ stdenv, lib, buildGoModule, fetchFromGitHub, makeWrapper, systemd, fetchpatch }:
{ stdenv
, lib
, buildGoModule
, fetchFromGitHub
, makeWrapper
, nixosTests
, systemd
, fetchpatch
}:

buildGoModule rec {
version = "2.0.0";
@@ -32,6 +40,8 @@ buildGoModule rec {
--prefix LD_LIBRARY_PATH : "${lib.getLib systemd}/lib"
'';

passthru.tests = { inherit (nixosTests) loki; };

doCheck = true;

meta = with stdenv.lib; {