summary refs log tree commit diff
path: root/nixos/tests/telegraf.nix
blob: d99680ce2c3c4f16a2fc7f766dfa5264275f2b94 (plain) (blame)
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
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "telegraf";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ mic92 ];
  };

  machine = { ... }: {
    services.telegraf.enable = true;
    services.telegraf.environmentFiles = [(pkgs.writeText "secrets" ''
      SECRET=example
    '')];
    services.telegraf.extraConfig = {
      agent.interval = "1s";
      agent.flush_interval = "1s";
      inputs.exec = {
        commands = [
          "${pkgs.runtimeShell} -c 'echo $SECRET,tag=a i=42i'"
        ];
        timeout = "5s";
        data_format = "influx";
      };
      outputs.file.files = ["/tmp/metrics.out"];
      outputs.file.data_format = "influx";
    };
  };

  testScript = ''
    start_all()

    machine.wait_for_unit("telegraf.service")
    machine.wait_until_succeeds("grep -q example /tmp/metrics.out")
  '';
})