Add postgresql metrics exporter
This commit is contained in:
parent
2d4558f7b6
commit
4738b6a5da
2 changed files with 12 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
{pkgs, ...}: {
|
{pkgs, ...}: {
|
||||||
containers.postgresql = {
|
containers.postgresql = rec {
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
privateNetwork = true;
|
privateNetwork = true;
|
||||||
hostAddress6 = "fc00::1";
|
hostAddress6 = "fc00::1";
|
||||||
|
@ -18,7 +18,11 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {pkgs, ...}: {
|
config = {
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.postgresql_16;
|
package = pkgs.postgresql_16;
|
||||||
|
@ -39,6 +43,10 @@
|
||||||
"d /persist - postgres postgres - -"
|
"d /persist - postgres postgres - -"
|
||||||
"d /backup - postgres postgres - -"
|
"d /backup - postgres postgres - -"
|
||||||
];
|
];
|
||||||
|
services.prometheus.exporters.postgres.enable = true;
|
||||||
|
networking.firewall.extraCommands = ''
|
||||||
|
ip6tables -A nixos-fw -p tcp -s _gateway -m tcp --dport ${toString config.services.prometheus.exporters.postgres.port} -m comment --comment postgres-exporter -j nixos-fw-accept
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
|
|
|
@ -16,5 +16,7 @@ pkgs.testers.runNixOSTest {
|
||||||
postgresql.wait_for_unit("container@postgresql.service")
|
postgresql.wait_for_unit("container@postgresql.service")
|
||||||
postgresql.succeed("nixos-container run postgresql -- systemctl start postgresqlBackup.service")
|
postgresql.succeed("nixos-container run postgresql -- systemctl start postgresqlBackup.service")
|
||||||
postgresql.succeed("stat /persist/backup/postgresql/all.sql.zstd")
|
postgresql.succeed("stat /persist/backup/postgresql/all.sql.zstd")
|
||||||
|
postgresql.succeed("sleep 5")
|
||||||
|
postgresql.succeed("curl -v 'http://postgresql:9187/metrics'")
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue