Open stgrace opened 1 year ago
Before starting on the code, I would suggest that you outline the queries that you would use to gather this data and which metrics you propose adding to the collector as a result of that data. That would help us understand the direction before make any decisions
For example, we can use this statement to find the invalid indexes:
SELECT relnamespace::regnamespace::text,relname FROM pg_class, pg_index WHERE pg_index.indisvalid = false AND pg_index.indexrelid = pg_class.oid
or
SELECT d.datname, count(*) FROM pg_class as c, pg_index as i, pg_database as d WHERE i.indisvalid = false AND i.indexrelid = c.oid AND d.datname = current_database() AND d.datname not in ('cloudsqladmin','db_template','postgres','postgres_exporter_user','template0','template1') GROUP BY d.datname
@sysadmind hi. Is there any way to execute a custom query on each of discovered databases ? Of course, in scope of broken index count monitoring.
Thanks!
Proposal
Add a collector for tables with corrupt indexes. This has been causing some issues when executing certain update queries. It would be nice to proactively be informed of indexes that are corrupt, before we try to update data and notice this issue.
If you agree on this idea, I can add a PR to add a collector with this functionality.