nixpkgs/nixos/tests/telegraf.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.0 KiB
Nix
Raw Permalink Normal View History

2019-11-06 14:40:43 +03:00
import ./make-test-python.nix ({ pkgs, ...} : {
2019-01-21 14:30:11 +03:00
name = "telegraf";
meta = with pkgs.lib.maintainers; {
2019-01-21 14:30:11 +03:00
maintainers = [ mic92 ];
};
2022-03-21 02:15:30 +03:00
nodes.machine = { ... }: {
2019-01-21 14:30:11 +03:00
services.telegraf.enable = true;
2020-11-18 23:30:29 +03:00
services.telegraf.environmentFiles = [(pkgs.writeText "secrets" ''
SECRET=example
2020-11-18 23:30:29 +03:00
'')];
2019-01-21 14:30:11 +03:00
services.telegraf.extraConfig = {
agent.interval = "1s";
agent.flush_interval = "1s";
inputs.exec = {
commands = [
"${pkgs.runtimeShell} -c 'echo $SECRET,tag=a i=42i'"
2019-01-21 14:30:11 +03:00
];
timeout = "5s";
data_format = "influx";
};
inputs.ping = {
urls = ["127.0.0.1"];
count = 4;
interval = "10s";
timeout = 1.0;
};
2019-01-21 14:30:11 +03:00
outputs.file.files = ["/tmp/metrics.out"];
outputs.file.data_format = "influx";
};
};
testScript = ''
2019-11-06 14:40:43 +03:00
start_all()
2019-01-21 14:30:11 +03:00
2019-11-06 14:40:43 +03:00
machine.wait_for_unit("telegraf.service")
machine.wait_until_succeeds("grep -q example /tmp/metrics.out")
machine.wait_until_succeeds("grep -q ping /tmp/metrics.out")
2019-01-21 14:30:11 +03:00
'';
})