wynne: enable postgresql_exporter

This commit is contained in:
Adithya 2024-07-20 20:15:41 +05:30
parent 36ed3c73b5
commit c43ccffcb8
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
2 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,4 @@
{ config, ... }: { { lib, config, ... }: {
services = { services = {
caddy = { caddy = {
virtualHosts."${config.networking.hostName}.labs.adtya.xyz" = { virtualHosts."${config.networking.hostName}.labs.adtya.xyz" = {
@ -10,6 +10,12 @@
uri replace /systemd-metrics /metrics uri replace /systemd-metrics /metrics
reverse_proxy 127.0.0.1:9558 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 tls /persist/secrets/caddy/certs/default.crt /persist/secrets/caddy/certs/default.key
''; '';
}; };

View file

@ -1,5 +1,11 @@
{ config, pkgs, ... }: { { config, pkgs, ... }: {
services = { services = {
prometheus.exporters.postgres = {
enable = true;
listenAddress = "127.0.0.1";
port = 9187;
runAsLocalSuperUser = true;
};
postgresql = { postgresql = {
enable = true; enable = true;
dataDir = "/mnt/data/postgresql/${config.services.postgresql.package.psqlSchema}"; dataDir = "/mnt/data/postgresql/${config.services.postgresql.package.psqlSchema}";