From dfd52e2cd5e90d33222e7ebed9011fde8b2b4c43 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 29 Jul 2023 19:33:13 +0000 Subject: [PATCH] enable gitea metrics --- modules/nixos/services/gitea.nix | 38 ++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/modules/nixos/services/gitea.nix b/modules/nixos/services/gitea.nix index dd5ec38..da0f795 100644 --- a/modules/nixos/services/gitea.nix +++ b/modules/nixos/services/gitea.nix @@ -9,6 +9,7 @@ in { database.type = "sqlite3"; settings = { actions.ENABLED = true; + metrics.ENABLED = true; repository = { DEFAULT_PUSH_CREATE_PRIVATE = true; DISABLE_HTTP_GIT = false; @@ -37,13 +38,36 @@ in { networking.firewall.allowedTCPPorts = [ 122 ]; users.users.${config.user}.extraGroups = [ "gitea" ]; - caddy.routes = [{ - match = [{ host = [ config.hostnames.git ]; }]; - handle = [{ - handler = "reverse_proxy"; - upstreams = [{ dial = "localhost:3001"; }]; - }]; - }]; + caddy.routes = [ + { + match = [{ + host = [ config.hostnames.git ]; + path = [ "/metrics*" ]; + }]; + handle = [{ + handler = "static_response"; + status_code = "403"; + }]; + } + { + match = [{ host = [ config.hostnames.git ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ + dial = "localhost:${ + builtins.toString + config.services.gitea.settings.server.HTTP_PORT + }"; + }]; + }]; + } + ]; + + prometheus.scrapeTargets = [ + "127.0.0.1:${ + builtins.toString config.services.gitea.settings.server.HTTP_PORT + }" + ]; ## Backup config