vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / vector / file-sink.nix
blob2220d20ac55c37c0ff2865a9fb93cf7205544d66
1 import ../make-test-python.nix ({ lib, pkgs, ... }:
4   name = "vector-test1";
5   meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
7   nodes.machine = { config, pkgs, ... }: {
8     services.vector = {
9       enable = true;
10       journaldAccess = true;
11       settings = {
12         sources = {
13           journald.type = "journald";
15           vector_metrics.type = "internal_metrics";
17           vector_logs.type = "internal_logs";
18         };
20         sinks = {
21           file = {
22             type = "file";
23             inputs = [ "journald" "vector_logs" ];
24             path = "/var/lib/vector/logs.log";
25             encoding = { codec = "json"; };
26           };
28           prometheus_exporter = {
29             type = "prometheus_exporter";
30             inputs = [ "vector_metrics" ];
31             address = "[::]:9598";
32           };
33         };
34       };
35     };
36   };
38   # ensure vector is forwarding the messages appropriately
39   testScript = ''
40     machine.wait_for_unit("vector.service")
41     machine.wait_for_open_port(9598)
42     machine.wait_until_succeeds("journalctl -o cat -u vector.service | grep 'version=\"${pkgs.vector.version}\"'")
43     machine.wait_until_succeeds("journalctl -o cat -u vector.service | grep 'API is disabled'")
44     machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_build_info")
45     machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_component_received_bytes_total | grep journald")
46     machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_utilization | grep prometheus_exporter")
47     machine.wait_for_file("/var/lib/vector/logs.log")
48   '';