Reduce metrics noise from the postgres_exporter

With the large number of tables in the database, the number of metrics for pg_stat_user_tables has been multiplying.

With almost 500 tables in a base install and 20 metrics, we have 10,000 metrics just for these tables. This is about 30% of the metrics load on the embedded Prometheus server.

We need to verify which of the metrics we need to keep, and if we can reduce the label set.

List of metrics to keep:

  • pg_stat_user_tables_analyze_count
  • pg_stat_user_tables_autoanalyze_count
  • pg_stat_user_tables_autovacuum_count
  • pg_stat_user_tables_coalesce
  • pg_stat_user_tables_idx_scan
  • pg_stat_user_tables_idx_tup_fetch
  • pg_stat_user_tables_last_analyze
  • pg_stat_user_tables_last_autoanalyze
  • pg_stat_user_tables_last_autovacuum
  • pg_stat_user_tables_last_vacuum
  • pg_stat_user_tables_n_dead_tup
  • pg_stat_user_tables_n_live_tup
  • pg_stat_user_tables_n_mod_since_analyze
  • pg_stat_user_tables_n_tup_del
  • pg_stat_user_tables_n_tup_hot_upd
  • pg_stat_user_tables_n_tup_ins
  • pg_stat_user_tables_n_tup_upd
  • pg_stat_user_tables_seq_scan
  • pg_stat_user_tables_seq_tup_read
  • pg_stat_user_tables_vacuum_count

Labels:

- datname:
    usage: "LABEL"
    description: "Name of current database"
- schemaname:
    usage: "LABEL"
    description: "Name of the schema that this table is in"
- relname:
    usage: "LABEL"
    description: "Name of this table"
Edited by Alejandro Rodríguez