summaryrefslogtreecommitdiffstats
path: root/nixos/tests/vector/api.nix
blob: 84a140fda9e3f09498db649909d821fda88a509c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ lib, pkgs, ... }:

{
  name = "vector-api";
  meta.maintainers = [ pkgs.lib.maintainers.happysalada ];

  nodes.machineapi =
    { config, pkgs, ... }:
    {
      services.vector = {
        enable = true;
        journaldAccess = false;
        settings = {
          api.enabled = true;

          sources = {
            demo_logs = {
              type = "demo_logs";
              format = "json";
            };
          };

          sinks = {
            file = {
              type = "file";
              inputs = [ "demo_logs" ];
              path = "/var/lib/vector/logs.log";
              encoding = {
                codec = "json";
              };
            };
          };
        };
      };
    };

  testScript = ''
    machineapi.wait_for_unit("vector")
    machineapi.wait_for_open_port(8686)
    machineapi.succeed("journalctl -o cat -u vector.service | grep 'API server running'")
    machineapi.wait_until_succeeds("curl -sSf http://localhost:8686/health")
  '';
}