From c43ccffcb881046ac1f4431108d71521f35110cc Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sat, 20 Jul 2024 20:15:41 +0530 Subject: [PATCH] wynne: enable postgresql_exporter --- hosts/shared/prometheus-exporters.nix | 8 +++++++- hosts/wynne/services/apps/postgresql.nix | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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}";