add prometheus deluge exporter
This commit is contained in:
parent
848083dacc
commit
a4c4ee1670
4 changed files with 72 additions and 2 deletions
|
@ -18,6 +18,7 @@
|
||||||
- Revert Loki to major version 2 because upgrading to version 3 required manual intervention as Loki
|
- Revert Loki to major version 2 because upgrading to version 3 required manual intervention as Loki
|
||||||
refuses to start. So until this issue is tackled, reverting is the best immediate fix.
|
refuses to start. So until this issue is tackled, reverting is the best immediate fix.
|
||||||
See https://github.com/NixOS/nixpkgs/commit/8f95320f39d7e4e4a29ee70b8718974295a619f4
|
See https://github.com/NixOS/nixpkgs/commit/8f95320f39d7e4e4a29ee70b8718974295a619f4
|
||||||
|
- Add prometheus deluge exporter support. It just needs the `shb.deluge.prometheusScraperPasswordFile` option to be set.
|
||||||
|
|
||||||
## Other Changes
|
## Other Changes
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/315018.patch";
|
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/315018.patch";
|
||||||
hash = "sha256-8jcGyO/d+htfv/ZajxXh89S3OiDZAr7/fsWC1JpGczM=";
|
hash = "sha256-8jcGyO/d+htfv/ZajxXh89S3OiDZAr7/fsWC1JpGczM=";
|
||||||
})
|
})
|
||||||
|
(originPkgs.fetchpatch {
|
||||||
|
url = "https://github.com/NixOS/nixpkgs/pull/317107.patch";
|
||||||
|
hash = "sha256-/bFQVxQgrDrMlACQGWBpMk76+PaA5mP9HuWm9MwCs/0=";
|
||||||
|
})
|
||||||
];
|
];
|
||||||
patchedNixpkgs = originPkgs.applyPatches {
|
patchedNixpkgs = originPkgs.applyPatches {
|
||||||
name = "nixpkgs-patched";
|
name = "nixpkgs-patched";
|
||||||
|
|
|
@ -182,6 +182,12 @@ in
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
prometheusScraperPasswordFile = lib.mkOption {
|
||||||
|
description = "File containing password for prometheus scraper. Setting this option will activate the prometheus deluge exporter.";
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
enabledPlugins = lib.mkOption {
|
enabledPlugins = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -266,7 +272,9 @@ in
|
||||||
systemd.services.deluged.preStart = lib.mkBefore (shblib.replaceSecrets {
|
systemd.services.deluged.preStart = lib.mkBefore (shblib.replaceSecrets {
|
||||||
userConfig = cfg.extraUsers // {
|
userConfig = cfg.extraUsers // {
|
||||||
localclient.password.source = config.shb.deluge.localclientPasswordFile;
|
localclient.password.source = config.shb.deluge.localclientPasswordFile;
|
||||||
};
|
} // (lib.optionalAttrs (config.shb.deluge.prometheusScraperPasswordFile != null) {
|
||||||
|
prometheus_scraper.password.source = config.shb.deluge.prometheusScraperPasswordFile;
|
||||||
|
});
|
||||||
resultPath = "${config.services.deluge.dataDir}/.config/deluge/authTemplate";
|
resultPath = "${config.services.deluge.dataDir}/.config/deluge/authTemplate";
|
||||||
generator = name: value: pkgs.writeText "delugeAuth" (authGenerator value);
|
generator = name: value: pkgs.writeText "delugeAuth" (authGenerator value);
|
||||||
});
|
});
|
||||||
|
@ -320,5 +328,24 @@ in
|
||||||
};
|
};
|
||||||
} {
|
} {
|
||||||
systemd.services.deluged.serviceConfig = cfg.extraServiceConfig;
|
systemd.services.deluged.serviceConfig = cfg.extraServiceConfig;
|
||||||
}]);
|
} (lib.mkIf (config.shb.deluge.prometheusScraperPasswordFile != null) {
|
||||||
|
services.prometheus.exporters.deluge = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
delugeHost = "127.0.0.1";
|
||||||
|
delugePort = config.services.deluge.config.daemon_port;
|
||||||
|
delugeUser = "prometheus_scraper";
|
||||||
|
delugePasswordFile = config.shb.deluge.prometheusScraperPasswordFile;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "deluge";
|
||||||
|
static_configs = [{
|
||||||
|
targets = ["127.0.0.1:${toString config.services.prometheus.exporters.deluge.port}"];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
})
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,21 @@ let
|
||||||
raise Exception(f"result had an error {response['error']}")
|
raise Exception(f"result had an error {response['error']}")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
prometheusTestScript = { nodes, ... }:
|
||||||
|
let
|
||||||
|
hasSSL = !(isNull nodes.server.shb.deluge.ssl);
|
||||||
|
proto_fqdn = if hasSSL then "https://${fqdn}" else "http://${fqdn}";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
server.wait_for_open_port(${toString nodes.server.services.prometheus.exporters.deluge.port})
|
||||||
|
with subtest("prometheus"):
|
||||||
|
response = server.succeed(
|
||||||
|
"curl -sSf "
|
||||||
|
+ " http://localhost:${toString nodes.server.services.prometheus.exporters.deluge.port}/metrics"
|
||||||
|
)
|
||||||
|
print(response)
|
||||||
|
'';
|
||||||
|
|
||||||
base = {
|
base = {
|
||||||
imports = [
|
imports = [
|
||||||
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
|
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
|
||||||
|
@ -293,4 +308,27 @@ in
|
||||||
#
|
#
|
||||||
# testScript = commonTestScript;
|
# testScript = commonTestScript;
|
||||||
# };
|
# };
|
||||||
|
|
||||||
|
prometheus = pkgs.testers.runNixOSTest {
|
||||||
|
name = "deluge_https";
|
||||||
|
|
||||||
|
nodes.server = lib.mkMerge [
|
||||||
|
base
|
||||||
|
certs
|
||||||
|
basic
|
||||||
|
https
|
||||||
|
prometheus
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
shb.authelia = lib.mkOption { type = lib.types.anything; };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
nodes.client = {};
|
||||||
|
|
||||||
|
testScript = inputs:
|
||||||
|
(commonTestScript inputs)
|
||||||
|
+ (prometheusTestScript inputs);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue