aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/nixos/tests/loki.nix
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/nixpkgs/nixos/tests/loki.nix')
-rw-r--r--infra/libkookie/nixpkgs/nixos/tests/loki.nix33
1 files changed, 24 insertions, 9 deletions
diff --git a/infra/libkookie/nixpkgs/nixos/tests/loki.nix b/infra/libkookie/nixpkgs/nixos/tests/loki.nix
index dbf1e8a650f5..bede775b7d3c 100644
--- a/infra/libkookie/nixpkgs/nixos/tests/loki.nix
+++ b/infra/libkookie/nixpkgs/nixos/tests/loki.nix
@@ -12,15 +12,28 @@ import ./make-test-python.nix ({ lib, pkgs, ... }:
enable = true;
configFile = "${pkgs.grafana-loki.src}/cmd/loki/loki-local-config.yaml";
};
- systemd.services.promtail = {
- description = "Promtail service for Loki test";
- wantedBy = [ "multi-user.target" ];
-
- serviceConfig = {
- ExecStart = ''
- ${pkgs.grafana-loki}/bin/promtail --config.file ${pkgs.grafana-loki.src}/cmd/promtail/promtail-local-config.yaml
- '';
- DynamicUser = true;
+ services.promtail = {
+ enable = true;
+ configuration = {
+ server = {
+ http_listen_port = 9080;
+ grpc_listen_port = 0;
+ };
+ clients = [ { url = "http://localhost:3100/loki/api/v1/push"; } ];
+ scrape_configs = [
+ {
+ job_name = "system";
+ static_configs = [
+ {
+ targets = [ "localhost" ];
+ labels = {
+ job = "varlogs";
+ __path__ = "/var/log/*log";
+ };
+ }
+ ];
+ }
+ ];
};
};
};
@@ -32,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'"
)