infrastructure/machines/rescue01/uptime-kuma.nix

157 lines
3.1 KiB
Nix
Raw Normal View History

{
2024-04-23 22:02:04 +02:00
config,
lib,
nodes,
sources,
...
}:
2024-03-28 16:25:29 +01:00
let
2024-04-23 22:02:04 +02:00
inherit (lib)
concatLists
mapAttrsToList
mkForce
mkMerge
;
inherit (config.statelessUptimeKuma.lib)
pingProbesFromHive
fromHive
httpProbesFromConfig
probesWithTag
;
2024-04-23 22:02:04 +02:00
probesCfg = config.statelessUptimeKuma.probesConfig;
mkMonitors = name: builtins.attrNames (probesWithTag { inherit name; } probesCfg);
2024-03-28 16:25:29 +01:00
host = "status.dgnum.eu";
port = 3001;
httpExcludes = [
"localhost"
"ens.cal.dgnum.eu"
"luj-current.cal.dgnum.eu"
"s3.dgnum.eu"
"cdn.dgnum.eu"
"saml-idp.dgnum.eu"
"status.dgnum.eu"
"radius.dgnum.eu"
2024-04-23 22:02:04 +02:00
] ++ (concatLists (mapAttrsToList (_: { config, ... }: config.dgn-redirections.retired) nodes));
extraProbes = {
monitors = {
"prometheus.dgnum.eu" = {
2024-04-23 22:02:04 +02:00
type = mkForce "http";
accepted_statuscodes = [ "401" ];
};
2024-04-23 22:02:04 +02:00
"ollama.beta.dgnum.eu" = {
type = mkForce "http";
accepted_statuscodes = [ "401" ];
};
"s3-admin.dgnum.eu" = {
type = mkForce "http";
accepted_statuscodes = [ "400" ];
};
"api.meet.dgnum.eu" = {
keyword = "Crab Fit API";
};
};
};
status_pages = {
"dgnum" = {
title = "DGNum";
description = "Etat de l'infra de la DGNum";
showTags = true;
publicGroupList = [
{
name = "Services";
weight = 1;
2024-04-23 22:02:04 +02:00
monitorList = mkMonitors "Service";
}
{
name = "Serveurs";
weight = 2;
2024-04-23 22:02:04 +02:00
monitorList = mkMonitors "Ping";
}
{
name = "VPN Interne";
weight = 2;
2024-04-23 22:02:04 +02:00
monitorList = mkMonitors "VPN";
}
];
};
};
pingProbes = pingProbesFromHive {
inherit nodes;
mkHost = _: config: config.networking.fqdn;
tags = [ { name = "Ping"; } ];
excludes = [
"geo01"
"geo02"
"rescue01"
];
};
vpnProbes = pingProbesFromHive {
inherit nodes;
prefix = "VPN - ";
mkHost = node: _: "${node}.dgnum";
tags = [ { name = "VPN"; } ];
excludes = [
"rescue01"
"web02"
];
};
httpProbes = fromHive {
inherit nodes;
builder =
_: module:
httpProbesFromConfig {
inherit (module) config;
tags = [
{
name = "Host";
value = module.config.networking.fqdn;
}
{ name = "Service"; }
];
excludes = httpExcludes;
};
};
2024-03-28 16:25:29 +01:00
in
{
imports = [ (sources.stateless-uptime-kuma + "/nixos/module.nix") ];
nixpkgs.overlays = [ (import (sources.stateless-uptime-kuma + "/overlay.nix")) ];
2024-04-23 22:02:04 +02:00
2024-03-28 16:25:29 +01:00
services.uptime-kuma.enable = true;
dgn-web.simpleProxies.uptime-kuma = {
inherit host port;
proxyWebsockets = true;
2024-03-28 16:25:29 +01:00
};
statelessUptimeKuma = {
2024-04-23 22:02:04 +02:00
probesConfig = mkMerge [
pingProbes
httpProbes
extraProbes
vpnProbes
{ inherit status_pages; }
];
2024-04-23 22:02:04 +02:00
extraFlags = [ "-s" ];
host = "http://localhost:${builtins.toString port}/";
username = "dgnum";
passwordFile = config.age.secrets."stateless-uptime-kuma-password".path;
enableService = true;
};
2024-03-28 16:25:29 +01:00
}