2020-04-24 23:36:52 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
|
|
|
name = "telegraf";
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = [ mic92 ];
|
|
|
|
};
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
nodes.machine = { ... }: {
|
2020-04-24 23:36:52 +00:00
|
|
|
services.telegraf.enable = true;
|
2020-11-19 00:13:47 +00:00
|
|
|
services.telegraf.environmentFiles = [(pkgs.writeText "secrets" ''
|
2020-11-15 13:44:38 +00:00
|
|
|
SECRET=example
|
2020-11-19 00:13:47 +00:00
|
|
|
'')];
|
2020-04-24 23:36:52 +00:00
|
|
|
services.telegraf.extraConfig = {
|
|
|
|
agent.interval = "1s";
|
|
|
|
agent.flush_interval = "1s";
|
|
|
|
inputs.exec = {
|
|
|
|
commands = [
|
2020-11-15 13:44:38 +00:00
|
|
|
"${pkgs.runtimeShell} -c 'echo $SECRET,tag=a i=42i'"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
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")
|
|
|
|
'';
|
|
|
|
})
|