mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 18:41:34 +01:00
gatus: Refactor again
This commit is contained in:
parent
c55be783b1
commit
5a960a1074
2 changed files with 32 additions and 26 deletions
|
|
@ -31,17 +31,14 @@
|
||||||
gatus = {
|
gatus = {
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "status.${tailscaleDomain}";
|
domain = "status.${tailscaleDomain}";
|
||||||
domainsToMonitor = config.meta.domains.globalList;
|
generateDefaultEndpoints = true;
|
||||||
endpoints = {
|
endpoints = {
|
||||||
"alerts" = {
|
"alerts" = {
|
||||||
group = "Monitoring";
|
|
||||||
path = "/v1/health";
|
path = "/v1/health";
|
||||||
extraConditions = [ "[BODY].healthy == true" ];
|
extraConditions = [ "[BODY].healthy == true" ];
|
||||||
};
|
};
|
||||||
"grafana".group = "Monitoring";
|
|
||||||
"metrics".group = "Monitoring";
|
|
||||||
"logs".group = "Monitoring";
|
|
||||||
"git ssh" = {
|
"git ssh" = {
|
||||||
|
group = "srv-public";
|
||||||
protocol = "ssh";
|
protocol = "ssh";
|
||||||
domain = "git.sstork.dev";
|
domain = "git.sstork.dev";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
self,
|
||||||
pkgs-unstable,
|
pkgs-unstable,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.custom.services.gatus;
|
cfg = config.custom.services.gatus;
|
||||||
|
|
||||||
tailscaleDomain = config.custom.services.tailscale.domain;
|
|
||||||
dataDir = "/var/lib/gatus";
|
dataDir = "/var/lib/gatus";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -21,14 +20,11 @@ in
|
||||||
type = lib.types.port;
|
type = lib.types.port;
|
||||||
default = 8080;
|
default = 8080;
|
||||||
};
|
};
|
||||||
domainsToMonitor = lib.mkOption {
|
generateDefaultEndpoints = lib.mkEnableOption "";
|
||||||
type = lib.types.listOf lib.types.nonEmptyStr;
|
|
||||||
default = [ ];
|
|
||||||
};
|
|
||||||
endpoints = lib.mkOption {
|
endpoints = lib.mkOption {
|
||||||
type = lib.types.attrsOf (
|
type = lib.types.attrsOf (
|
||||||
lib.types.submodule (
|
lib.types.submodule (
|
||||||
{ name, config, ... }:
|
{ name, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
name = lib.mkOption {
|
name = lib.mkOption {
|
||||||
|
|
@ -37,7 +33,7 @@ in
|
||||||
};
|
};
|
||||||
group = lib.mkOption {
|
group = lib.mkOption {
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
default = if config.domain |> lib.hasSuffix tailscaleDomain then "Private" else "Public";
|
default = "";
|
||||||
};
|
};
|
||||||
protocol = lib.mkOption {
|
protocol = lib.mkOption {
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
|
|
@ -106,20 +102,33 @@ in
|
||||||
getSubdomain = domain: domain |> lib.splitString "." |> lib.head;
|
getSubdomain = domain: domain |> lib.splitString "." |> lib.head;
|
||||||
|
|
||||||
defaultEndpoints =
|
defaultEndpoints =
|
||||||
cfg.domainsToMonitor
|
self.nixosConfigurations
|
||||||
|
|> lib.mapAttrs (_: value: value.config.meta.domains.list)
|
||||||
|
|> lib.concatMapAttrs (
|
||||||
|
hostName: domains:
|
||||||
|
domains
|
||||||
|> lib.filter (domain: domain != cfg.domain)
|
|> lib.filter (domain: domain != cfg.domain)
|
||||||
|> lib.map (domain: lib.nameValuePair (getSubdomain domain) { inherit domain; })
|
|> lib.map (
|
||||||
|> lib.listToAttrs;
|
domain:
|
||||||
|
lib.nameValuePair (getSubdomain domain) {
|
||||||
|
inherit domain;
|
||||||
|
group = hostName;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|> lib.listToAttrs
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
lib.mkIf cfg.generateDefaultEndpoints (
|
||||||
|
defaultEndpoints
|
||||||
|
// {
|
||||||
"healthchecks.io" = {
|
"healthchecks.io" = {
|
||||||
group = "Monitoring";
|
group = "external";
|
||||||
domain = "hc-ping.com";
|
domain = "hc-ping.com";
|
||||||
path = "/\${HEALTHCHECKS_PING_KEY}/${config.networking.hostName}-gatus-uptime?create=1";
|
path = "/\${HEALTHCHECKS_PING_KEY}/${config.networking.hostName}-gatus-uptime?create=1";
|
||||||
interval = "2h";
|
interval = "2h";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// defaultEndpoints;
|
);
|
||||||
|
|
||||||
services.gatus = {
|
services.gatus = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue