34 lines
915 B
Nix
34 lines
915 B
Nix
{ config, pkgs, ... }:
|
|
|
|
{
|
|
services.prometheus.exporters.postgres = {
|
|
enable = true;
|
|
listenAddress = "localhost";
|
|
runAsLocalSuperUser = true;
|
|
|
|
extraFlags = let
|
|
extraQuery = pkgs.writeText "prometehus-postgres-query.yaml" ''
|
|
pg_database:
|
|
query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size FROM pg_database"
|
|
metrics:
|
|
- datname:
|
|
usage: "LABEL"
|
|
description: "Name of the database"
|
|
- size:
|
|
usage: "GAUGE"
|
|
description: "Disk space used by the database"
|
|
'';
|
|
in [
|
|
"--extend.query-path=${extraQuery}"
|
|
];
|
|
};
|
|
|
|
services.prometheus.scrapeConfigs = [
|
|
{
|
|
job_name = "postgres";
|
|
static_configs = [{
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.postgres.port}" ];
|
|
}];
|
|
}
|
|
];
|
|
}
|