2024-07-05 12:51:26 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.bagel.monitoring.exporters.postgres;
|
|
|
|
inherit (lib) mkEnableOption mkIf;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.bagel.monitoring.exporters.postgres.enable = (mkEnableOption "Postgres exporter") // { default = config.services.postgresql.enable; };
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.prometheus.exporters.postgres = {
|
|
|
|
enable = true;
|
|
|
|
port = 9104;
|
|
|
|
runAsLocalSuperUser = true;
|
|
|
|
extraFlags = [
|
|
|
|
"--collector.long_running_transactions"
|
|
|
|
"--collector.stat_activity_autovacuum"
|
|
|
|
"--collector.stat_statements"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql.settings.shared_preload_libraries = "pg_stat_statements";
|
2024-10-21 12:33:18 +00:00
|
|
|
systemd.services.postgresql.postStart = lib.mkAfter ''
|
|
|
|
${config.services.postgresql.package}/bin/psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS pg_stat_statements;";
|
|
|
|
'';
|
2024-07-05 12:51:26 +00:00
|
|
|
|
2024-07-07 22:34:30 +00:00
|
|
|
bagel.monitoring.grafana-agent.exporters.postgres.port = 9104;
|
2024-07-05 12:51:26 +00:00
|
|
|
};
|
2024-10-21 12:33:18 +00:00
|
|
|
}
|