diff --git a/hosts/shared/prometheus-exporters.nix b/hosts/shared/prometheus-exporters.nix index 4b8395f..747cf5a 100644 --- a/hosts/shared/prometheus-exporters.nix +++ b/hosts/shared/prometheus-exporters.nix @@ -1,4 +1,4 @@ -{ config, ... }: { +{ lib, config, ... }: { services = { caddy = { virtualHosts."${config.networking.hostName}.labs.adtya.xyz" = { @@ -10,6 +10,12 @@ uri replace /systemd-metrics /metrics reverse_proxy 127.0.0.1:9558 } + ${lib.optionalString config.services.prometheus.exporters.postgres.enable '' + handle /postgres-metrics { + uri replace /postgres-metrics /metrics + reverse_proxy ${config.services.prometheus.exporters.postgres.listenAddress}:${toString config.services.prometheus.exporters.postgres.port} + } + ''} tls /persist/secrets/caddy/certs/default.crt /persist/secrets/caddy/certs/default.key ''; }; diff --git a/hosts/wynne/services/apps/postgresql.nix b/hosts/wynne/services/apps/postgresql.nix index f3f864c..b9023a8 100644 --- a/hosts/wynne/services/apps/postgresql.nix +++ b/hosts/wynne/services/apps/postgresql.nix @@ -1,5 +1,11 @@ { config, pkgs, ... }: { services = { + prometheus.exporters.postgres = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9187; + runAsLocalSuperUser = true; + }; postgresql = { enable = true; dataDir = "/mnt/data/postgresql/${config.services.postgresql.package.psqlSchema}";