Comments on: Adding PostgreSQL Databases/Tables Size Dashboard to the Percona Monitoring and Management Plugin https://www.percona.com/blog/adding-postgresql-databases-tables-size-dashboard-to-the-percona-monitoring-and-management-plugin/ Thu, 29 Oct 2020 12:14:39 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: coolthecold https://www.percona.com/blog/adding-postgresql-databases-tables-size-dashboard-to-the-percona-monitoring-and-management-plugin/#comment-10972810 Thu, 29 Oct 2020 12:14:39 +0000 https://www.percona.com/blog/?p=65263#comment-10972810 @vadim, when using https://github.com/wrouesnel/postgres_exporter , I was able to gather stats for table size per DB with setting like this


# pg_table_size_size_bytes
pg_table_size:
query: 'SELECT current_database() datname, nspname AS "schemaname", relname, pg_relation_size(C.oid) AS "size_bytes" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN (''pg_catalog'', ''information_schema'', ''pg_toast'') ORDER BY pg_relation_size(C.oid)'
metrics:
- datname:
usage: "LABEL"
description: "Name of the database"
- schemaname:
usage: "LABEL"
description: "Name of the schema that this table is in"
- relname:
usage: "LABEL"
description: "Name of this table"
- size_bytes:
usage: "GAUGE"
description: "Disk space used by the table"

database autodiscovery needs to be turned on – was possible without special bash script/dblink, hope it will help you as well.

]]>