forked from DGNum/infrastructure
feat: declarative probes for uptime-kuma
This commit is contained in:
parent
c4154e0a35
commit
20d3354a4d
5 changed files with 225 additions and 42 deletions
|
@ -1,9 +1,116 @@
|
|||
{
|
||||
lib,
|
||||
nodes,
|
||||
config,
|
||||
sources,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (config.statelessUptimeKuma.lib)
|
||||
pingProbesFromHive
|
||||
fromHive
|
||||
httpProbesFromConfig
|
||||
probesWithTag
|
||||
;
|
||||
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"
|
||||
] ++ nodes.web01.config.dgn-redirections.retired;
|
||||
|
||||
extraProbes = {
|
||||
monitors = {
|
||||
"prometheus.dgnum.eu" = {
|
||||
type = lib.mkForce "http";
|
||||
accepted_statuscodes = [ "401" ];
|
||||
};
|
||||
"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;
|
||||
monitorList = builtins.attrNames (
|
||||
probesWithTag { name = "Service"; } config.statelessUptimeKuma.probesConfig
|
||||
);
|
||||
}
|
||||
{
|
||||
name = "Serveurs";
|
||||
weight = 2;
|
||||
monitorList = builtins.attrNames (
|
||||
probesWithTag { name = "Ping"; } config.statelessUptimeKuma.probesConfig
|
||||
);
|
||||
}
|
||||
{
|
||||
name = "VPN Interne";
|
||||
weight = 2;
|
||||
monitorList = builtins.attrNames (
|
||||
probesWithTag { name = "VPN"; } config.statelessUptimeKuma.probesConfig
|
||||
);
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ (sources.stateless-uptime-kuma + "/nixos/module.nix") ];
|
||||
nixpkgs.overlays = [ (import (sources.stateless-uptime-kuma + "/overlay.nix")) ];
|
||||
services.uptime-kuma.enable = true;
|
||||
|
||||
services.nginx = {
|
||||
|
@ -23,4 +130,22 @@ in
|
|||
80
|
||||
443
|
||||
];
|
||||
|
||||
statelessUptimeKuma = {
|
||||
probesConfig = lib.mkMerge [
|
||||
pingProbes
|
||||
httpProbes
|
||||
extraProbes
|
||||
vpnProbes
|
||||
{ inherit status_pages; }
|
||||
];
|
||||
extraFlags = [
|
||||
"-v DEBUG"
|
||||
"-s"
|
||||
];
|
||||
host = "http://localhost:${builtins.toString port}/";
|
||||
username = "dgnum";
|
||||
passwordFile = config.age.secrets."stateless-uptime-kuma-password".path;
|
||||
enableService = true;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue