nixos/tests/prometheus-exporters: add exportarr-sonarr test

This commit is contained in:
Felix Buehler 2024-01-31 20:13:32 +01:00
parent c762005190
commit 4851b2be01

View File

@ -257,6 +257,46 @@ let
'';
};
exportarr-sonarr = let apikey = "eccff6a992bc2e4b88e46d064b26bb4e"; in {
nodeName = "exportarr_sonarr";
exporterConfig = {
enable = true;
url = "http://127.0.0.1:8989";
apiKeyFile = pkgs.writeText "dummy-api-key" apikey;
};
metricProvider = {
services.sonarr.enable = true;
systemd.services.sonarr.serviceConfig.ExecStartPre =
let
sonarr_config = pkgs.writeText "config.xml" ''
<Config>
<LogLevel>info</LogLevel>
<EnableSsl>False</EnableSsl>
<Port>8989</Port>
<SslPort>9898</SslPort>
<UrlBase></UrlBase>
<BindAddress>*</BindAddress>
<ApiKey>${apikey}</ApiKey>
<AuthenticationMethod>None</AuthenticationMethod>
<UpdateMechanism>BuiltIn</UpdateMechanism>
<Branch>main</Branch>
<InstanceName>Sonarr</InstanceName>
</Config>
'';
in
[
''${pkgs.coreutils}/bin/install -D -m 777 ${sonarr_config} -T /var/lib/sonarr/.config/NzbDrone/config.xml''
];
};
exporterTest = ''
wait_for_unit("sonarr.service")
wait_for_open_port(8989)
wait_for_unit("prometheus-exportarr-sonarr-exporter.service")
wait_for_open_port(9708)
succeed("curl -sSf http://localhost:9708/metrics | grep sonarr_series_total")
'';
};
fastly = {
exporterConfig = {
enable = true;