Commit bd2f16c
committed
fix(metrics): rank don't filter — keep pg_catalog/pg_toast/timescale visible
The first revision read from pg_stat_user_*/pg_statio_user_*, which the
Postgres views define as 'pg_stat_all_* WHERE schemaname NOT IN
(pg_catalog, information_schema) AND schemaname !~ ^pg_toast'. That's
identity-based filtering wearing a different hat: it silently hides bloat
in pg_toast, hot scans in pg_catalog, and any issue inside
_timescaledb_internal. If a TOAST table is bloated or a catalog index is
being hammered, the operator wouldn't see it.
Rework the four metrics to read pg_stat_all_*/pg_statio_all_* directly
and rely PURELY on cardinality control:
- Top 100 by relevance per database (idx_scan / pg_total_relation_size /
heap_blks_read / idx_blks_read).
- Tail aggregated into a single 'other' row so totals stay correct.
- No pg_temp%, no pg_toast%, no _timescaledb% schema filtering anywhere.
A relation enters the top-N by activity or by size; if it's not in the
top-N, it's in 'other'.
The only WHERE filter kept is the zero-counter row skip on the two statio
metrics — those rows literally carry no information (every gauge is 0)
and cannot mask any issue, so dropping them is information-preserving,
not identity-based.
Smoke-tested against PG16:
- pg_stat_all_tables: 101 rows, 75 from pg_catalog/etc. in top-100.
- pg_stat_all_indexes: 101 rows, 98 from system schemas.
- pg_statio_all_tables / pg_statio_all_indexes: catalog/toast rows
appear in top-N once they have any I/O.
Regression tests updated to assert: reads pg_stat_all_*/pg_statio_all_*,
no schemaname/nspname LIKE patterns, no 'pg_toast'/'pg_catalog'/
'_timescaledb' literals — top-N + 'other' is the only mechanism.1 parent 10c153e commit bd2f16c
2 files changed
Lines changed: 73 additions & 50 deletions
File tree
- config/pgwatch-prometheus
- tests/compliance_vectors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1552 | 1552 | | |
1553 | 1553 | | |
1554 | 1554 | | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
1562 | 1564 | | |
1563 | 1565 | | |
1564 | 1566 | | |
| |||
1570 | 1572 | | |
1571 | 1573 | | |
1572 | 1574 | | |
1573 | | - | |
1574 | | - | |
| 1575 | + | |
1575 | 1576 | | |
1576 | 1577 | | |
1577 | 1578 | | |
| |||
1601 | 1602 | | |
1602 | 1603 | | |
1603 | 1604 | | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
1609 | 1614 | | |
1610 | 1615 | | |
1611 | 1616 | | |
| |||
1631 | 1636 | | |
1632 | 1637 | | |
1633 | 1638 | | |
1634 | | - | |
| 1639 | + | |
1635 | 1640 | | |
1636 | 1641 | | |
1637 | 1642 | | |
| |||
2961 | 2966 | | |
2962 | 2967 | | |
2963 | 2968 | | |
2964 | | - | |
2965 | | - | |
2966 | | - | |
2967 | | - | |
2968 | | - | |
2969 | | - | |
2970 | | - | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
2971 | 2979 | | |
2972 | 2980 | | |
2973 | 2981 | | |
| |||
2984 | 2992 | | |
2985 | 2993 | | |
2986 | 2994 | | |
2987 | | - | |
| 2995 | + | |
2988 | 2996 | | |
2989 | 2997 | | |
2990 | 2998 | | |
| |||
3028 | 3036 | | |
3029 | 3037 | | |
3030 | 3038 | | |
3031 | | - | |
3032 | | - | |
3033 | | - | |
3034 | | - | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
3035 | 3043 | | |
3036 | | - | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
3037 | 3048 | | |
3038 | 3049 | | |
3039 | 3050 | | |
| |||
3045 | 3056 | | |
3046 | 3057 | | |
3047 | 3058 | | |
3048 | | - | |
3049 | | - | |
3050 | | - | |
3051 | | - | |
| 3059 | + | |
| 3060 | + | |
3052 | 3061 | | |
3053 | 3062 | | |
3054 | 3063 | | |
| |||
Lines changed: 32 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
107 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
| |||
0 commit comments