albertodonato / query-exporter

Export Prometheus metrics from SQL queries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider adding Auto Discover Databases

qfritz opened this issue · comments

Is your feature request related to a problem? Please describe.
It seems that I have to declare every one of my databases.
Problem: in my context, people may create new databases independently and I don't want to manually redeclare them. Imagine a postgreSQL instance with 25 distinct databases on it, but tomorrow may be 26 without me knowing.

Describe the solution you'd like
I'd love a feature where I can just declare one of the databases (let's say in my example, the postgres default one) and the tool could auto-discover the other ones at connection step, and just repeat the queries on each database. Even better if we can choose which queries would be executed once and which queries needs to be repeated for each databases.
Example with a query that retrieves user index stats for the current database:

SELECT current_database() datname, us.schemaname, us.relname, us.indexrelname, us.idx_scan, us.idx_tup_read, us.idx_tup_fetch, io.idx_blks_read, io.idx_blks_hit, ind.indisvalid
    FROM pg_index as ind, pg_stat_user_indexes as us, pg_statio_user_indexes as io
    WHERE ind.indexrelid = us.indexrelid
    AND ind.indexrelid = io.indexrelid;
# This query need to be executed per database to resolve relname (relid::regclass)

Describe alternatives you've considered
Alternative is too have a side deamon that would update the list of databases and regenerate the config every day.