1{ lib, pkgs, ... }:
2
3{
4 name = "vector-test1";
5 meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
6
7 nodes.machine =
8 { config, pkgs, ... }:
9 {
10 services.vector = {
11 enable = true;
12 journaldAccess = true;
13 settings = {
14 sources = {
15 journald.type = "journald";
16
17 vector_metrics.type = "internal_metrics";
18
19 vector_logs.type = "internal_logs";
20 };
21
22 sinks = {
23 file = {
24 type = "file";
25 inputs = [
26 "journald"
27 "vector_logs"
28 ];
29 path = "/var/lib/vector/logs.log";
30 encoding = {
31 codec = "json";
32 };
33 };
34
35 prometheus_exporter = {
36 type = "prometheus_exporter";
37 inputs = [ "vector_metrics" ];
38 address = "[::]:9598";
39 };
40 };
41 };
42 };
43 };
44
45 # ensure vector is forwarding the messages appropriately
46 testScript = ''
47 machine.wait_for_unit("vector.service")
48 machine.wait_for_open_port(9598)
49 machine.wait_until_succeeds("journalctl -o cat -u vector.service | grep 'version=\"${pkgs.vector.version}\"'")
50 machine.wait_until_succeeds("journalctl -o cat -u vector.service | grep 'API is disabled'")
51 machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_build_info")
52 machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_component_received_bytes_total | grep journald")
53 machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_utilization | grep prometheus_exporter")
54 machine.wait_for_file("/var/lib/vector/logs.log")
55 '';
56}