1{ lib, pkgs, ... }:
2let
3
4 username = "vltest";
5 password = "rUceu1W41U"; # random string
6 passwordFile = pkgs.writeText "password-file" password;
7in
8{
9 name = "victorialogs-remote-write-with-vlagent";
10 meta.maintainers = [ lib.maintainers.shawn8901 ];
11
12 nodes.server =
13 { pkgs, ... }:
14 {
15 networking.firewall.allowedTCPPorts = [ 9428 ];
16 services.victorialogs = {
17 enable = true;
18 basicAuthUsername = username;
19 basicAuthPasswordFile = toString passwordFile;
20 };
21 };
22
23 nodes.client =
24 { pkgs, ... }:
25 {
26 services.vlagent = {
27 enable = true;
28 remoteWrite = {
29 url = "http://server:9428/internal/insert";
30 basicAuthUsername = username;
31 basicAuthPasswordFile = toString passwordFile;
32 };
33 };
34
35 services.journald.upload = {
36 enable = true;
37 settings = {
38 Upload.URL = "http://localhost:9429/insert/journald";
39 };
40 };
41 environment.systemPackages = [ pkgs.curl ];
42
43 };
44
45 testScript = ''
46 server.wait_for_unit("victorialogs.service")
47 server.wait_for_open_port(9428)
48
49 client.wait_for_unit("vlagent")
50 client.wait_for_open_port(9429)
51
52 client.wait_for_unit("systemd-journal-upload")
53
54 client.succeed("echo 'meow' | systemd-cat -p info")
55
56 server.wait_until_succeeds("curl -u ${username}:${password} --fail http://localhost:9428/select/logsql/query -d 'query=\"meow\"' | grep meow")
57 '';
58}