Simplify config for gatus endpoints

This commit is contained in:
SebastianStork 2025-06-22 20:44:04 +02:00
parent f65bf51905
commit 6c0ff3393b
9 changed files with 29 additions and 61 deletions

View file

@ -25,7 +25,5 @@ in
inherit (cfg) port;
};
};
custom.services.gatus.endpoints."Actual Budget".url = "https://${cfg.domain}/";
};
}

View file

@ -93,13 +93,5 @@ in
"d ${config.services.forgejo.customDir}/public 750 ${user} ${group} - -"
"L+ ${config.services.forgejo.customDir}/public/robots.txt 750 - - - ${disallow-all-robots}"
];
custom.services.gatus.endpoints = {
"Forgejo" = {
url = "https://${cfg.domain}/api/healthz";
extraConditions = [ "[BODY].status == pass" ];
};
"Forgejo SSH".url = "ssh://${cfg.domain}";
};
};
}

View file

@ -1,9 +1,4 @@
{
config,
self,
lib,
...
}:
{ config, lib, ... }:
let
cfg = config.custom.services.gatus;
in
@ -36,6 +31,10 @@ in
type = lib.types.nonEmptyStr;
default = "";
};
appendPath = lib.mkOption {
type = lib.types.str;
default = "";
};
extraConditions = lib.mkOption {
type = lib.types.listOf lib.types.nonEmptyStr;
default = [ ];
@ -58,6 +57,14 @@ in
'';
};
custom.services.gatus.endpoints =
let
getSubdomain = domain: domain |> lib.splitString "." |> lib.head;
in
config.meta.domains.globalList
|> lib.map (domain: lib.nameValuePair (getSubdomain domain) { url = "https://${domain}"; })
|> lib.listToAttrs;
services.gatus = {
enable = true;
environmentFile = config.sops.templates."gatus.env".path;
@ -99,6 +106,7 @@ in
name,
group,
url,
appendPath,
extraConditions,
}:
let
@ -106,9 +114,9 @@ in
deducedGroup = if isPrivate then "Private" else "Public";
in
{
inherit name url;
group = if group == null then deducedGroup else group;
interval = "30s";
inherit name;
group = if group != null then group else deducedGroup;
url = url + appendPath;
alerts = [ { type = "ntfy"; } ];
ssh = lib.mkIf (lib.hasPrefix "ssh" url) {
username = "";
@ -125,20 +133,14 @@ in
in
[
{
name = "Healthchecks.io";
name = "healthchecks.io";
group = "Monitoring";
url = "https://hc-ping.com/\${HEALTHCHECKS_PING_KEY}/gatus-uptime?create=1";
url = "https://hc-ping.com/\${HEALTHCHECKS_PING_KEY}/${config.networking.hostName}-gatus-uptime?create=1";
interval = "2h";
conditions = [ "[STATUS] == 200" ];
}
]
++ (
self.nixosConfigurations
|> lib.mapAttrsToList (_: value: value.config.custom.services.gatus.endpoints)
|> lib.map (entry: lib.mapAttrsToList (_: value: value) entry)
|> lib.concatLists
|> lib.map (entry: mkEndpoint entry)
);
++ (cfg.endpoints |> lib.mapAttrsToList (_: value: value) |> lib.map (entry: mkEndpoint entry));
};
};
};

View file

@ -79,10 +79,5 @@ in
};
environment.shellAliases.hedgedoc-manage-users = "sudo --user=${user} ${manage_users}";
custom.services.gatus.endpoints."Hedgedoc" = {
url = "https://${cfg.domain}/_health";
extraConditions = [ "[BODY].ready == true" ];
};
};
}

View file

@ -29,10 +29,5 @@ in
root = "${pkgs.it-tools}/lib";
configuration.general.health = true;
};
custom.services.gatus.endpoints."IT Tools" = {
url = "https://${cfg.domain}/health";
extraConditions = [ "[BODY] == OK" ];
};
};
}

View file

@ -72,14 +72,5 @@ in
};
};
};
custom.services.gatus.endpoints."Nextcloud" = {
url = "https://${cfg.domain}/status.php";
extraConditions = [
"[BODY].installed == true"
"[BODY].maintenance == false"
"[BODY].needsDbUpgrade == false"
];
};
};
}

View file

@ -27,11 +27,5 @@ in
web-root = "disable";
};
};
custom.services.gatus.endpoints."Ntfy" = {
group = "Monitoring";
url = "https://${cfg.domain}/v1/health";
extraConditions = [ "[BODY].healthy == true" ];
};
};
}

View file

@ -97,13 +97,5 @@ in
};
};
};
custom.services.gatus.endpoints = lib.mkIf cfg.isServer {
"Syncthing".url = "tcp://${config.networking.hostName}.${tailscaleCfg.domain}:22000";
"Syncthing GUI" = {
url = "https://${cfg.gui.domain}/rest/noauth/health";
extraConditions = [ "[BODY].status == OK" ];
};
};
};
}