nixos/modules/crans/monitoring.nix

41 lines
815 B
Nix
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
config,
info,
lib,
...
}:
let
cfg = info.monitoring;
nginxEnable = config.services.nginx.enable;
inherit (lib) mkIf optional;
boolToStr = b: if b then "true" else "false";
in
{
# Options ../info/monitoring.nix
config = {
warnings = optional (cfg.enable && (nginxEnable != cfg.nginx.enable)) ''
${info.name} : config.services.nginx.enable (${boolToStr nginxEnable}) n’est pas cohérent avec le monitoring déclaré dans l’info.nix (${boolToStr cfg.nginx.enable})
'';
services.prometheus.exporters = mkIf cfg.enable {
node = {
enable = true;
port = 9100;
openFirewall = true;
};
nginx = {
enable = cfg.nginx.enable;
port = 9117;
scrapeUri = "http://[::1]:6424/stub_status";
};
};
};
}