Skip to content

Instantly share code, notes, and snippets.

@munisystem
Created September 26, 2019 11:33
Show Gist options
  • Save munisystem/18bce9f7a566dd75e6774dcc25e48d14 to your computer and use it in GitHub Desktop.
Save munisystem/18bce9f7a566dd75e6774dcc25e48d14 to your computer and use it in GitHub Desktop.
A configuration file of wrouesnel/postgres_exporter for collecting each table size
pg_class:
query: "SELECT n.nspname as schema, c.relname as relname, (c.relpages * 8192) as relsize_bytes FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r','') AND n.nspname <> 'pg_catalog' AND n.nspname <> 'information_schema' AND n.nspname !~ '^pg_toast' AND pg_catalog.pg_table_is_visible(c.oid);"
metrics:
- schema:
usage: "LABEL"
description: "Schema of this table"
- relname:
usage: "LABEL"
description: "Name of this table"
- relsize_bytes:
usage: "GAUGE"
description: "Size of this table"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment