mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(monitoring): cloudflared metrics
This commit is contained in:
parent
1d19f0821d
commit
ec7e322e2d
10 changed files with 124 additions and 29 deletions
43
modules/system/exports/cloudflared.nix
Normal file
43
modules/system/exports/cloudflared.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
in {
|
||||
config.exports.services.cloudflared = {config, systemConfig, ...}: let
|
||||
assertMetrics = nixosConfig: let
|
||||
cfg = nixosConfig.services.cloudflared;
|
||||
metricsPort =
|
||||
if config.ports.metrics.enable
|
||||
then config.ports.metrics.port
|
||||
else null;
|
||||
in {
|
||||
assertion = metricsPort == cfg.metricsPort;
|
||||
message = "metricsPort mismatch";
|
||||
};
|
||||
in {
|
||||
displayName = mkAlmostOptionDefault "Cloudflare Tunnel/${systemConfig.name}";
|
||||
nixos = {
|
||||
serviceAttr = "cloudflared";
|
||||
assertions = mkIf config.enable [
|
||||
assertMetrics
|
||||
];
|
||||
};
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = {
|
||||
metrics = {
|
||||
port = mkAlmostOptionDefault 3011;
|
||||
protocol = "http";
|
||||
status = {
|
||||
enable = true;
|
||||
gatus.http = {
|
||||
statusCondition = mkAlmostOptionDefault "[STATUS] == 404";
|
||||
};
|
||||
};
|
||||
prometheus.exporter.enable = mkAlmostOptionDefault true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -3,9 +3,8 @@
|
|||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.lists) all imap0;
|
||||
inherit (lib.trivial) id;
|
||||
in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue