modules/monitoring: clean up tailscale and caddy config
This commit is contained in:
parent
756357552a
commit
9a21ab6621
10 changed files with 109 additions and 47 deletions
|
@ -82,19 +82,9 @@ in
|
|||
];
|
||||
}
|
||||
(mkIf cfg.enable {
|
||||
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
permitCertUid = config.services.caddy.user;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts."${config.networking.hostName}.coho-tet.ts.net".extraConfig = ''
|
||||
reverse_proxy 127.0.0.1:${toString config.services.prometheus.port}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."${config.networking.hostName}.coho-tet.ts.net".extraConfig = ''
|
||||
reverse_proxy 127.0.0.1:${toString config.services.prometheus.port}
|
||||
'';
|
||||
services.prometheus = mkIf cfg.enable {
|
||||
enable = true;
|
||||
port = 9091;
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib) mkIf concatStringsSep;
|
||||
inherit (config.my-lib.settings) prometheusCollectors;
|
||||
cfg = config.custom.prometheus.exporters;
|
||||
in
|
||||
{
|
||||
|
@ -95,8 +96,28 @@ in
|
|||
metrics
|
||||
}
|
||||
|
||||
admin ${config.networking.hostName}.coho-tet.ts.net:2019 {
|
||||
admin unix//var/run/caddy/admin.sock {
|
||||
origins 127.0.0.1 ${config.networking.hostName}.coho-tet.ts.net:2019
|
||||
}
|
||||
'';
|
||||
|
||||
systemd.services.caddy.serviceConfig = {
|
||||
RuntimeDirectory = "caddy";
|
||||
RuntimeDirectoryMode = "0700";
|
||||
};
|
||||
|
||||
services.tailscale = {
|
||||
permitCertUid = config.services.caddy.user;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
services.caddy = {
|
||||
virtualHosts."https://${config.networking.hostName}.coho-tet.ts.net:2019".extraConfig = ''
|
||||
handle /metrics {
|
||||
reverse_proxy unix//var/run/caddy/admin.sock
|
||||
}
|
||||
respond 403
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -241,17 +241,42 @@ in
|
|||
];
|
||||
}
|
||||
# {
|
||||
# job_name = "caddy-access";
|
||||
# file_sd_configs = {
|
||||
# files = [
|
||||
# "/var/log/caddy/*.log"
|
||||
# ];
|
||||
# refresh_interval = "5m";
|
||||
# };
|
||||
# job_name = "caddy";
|
||||
# static_configs = [
|
||||
# {
|
||||
# targets = [ "localhost" ];
|
||||
# labels = {
|
||||
# job = "caddy";
|
||||
# __path__ = "/var/log/caddy/*log";
|
||||
# agent = "caddy-promtail";
|
||||
# };
|
||||
# }
|
||||
# ];
|
||||
# pipeline_stages = [
|
||||
# {
|
||||
# json = {
|
||||
# expressions = {
|
||||
# duration = "duration";
|
||||
# status = "status";
|
||||
# };
|
||||
# };
|
||||
# }
|
||||
# {
|
||||
# labels = {
|
||||
# duration = null;
|
||||
# status = null;
|
||||
# };
|
||||
# }
|
||||
# ];
|
||||
# }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.caddy.logFormat = ''
|
||||
format json
|
||||
level INFO
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue