albertodonato / query-exporter

Export Prometheus metrics from SQL queries
GNU General Public License v3.0
436 stars 101 forks source link

Add Cross Server Query Correlation/Join #179

Open bp-rocket opened 8 months ago

bp-rocket commented 8 months ago

I'm trying to join queries from two or more databases on different servers. For example, db1 on svr_a has half the data I need and db2 on svr_b has the other half. Both have similar key-like values that can be used to join the two results. It would be nice if the exporter could join the two queries.

I have a generally static table in an application database that contains client information such as host name, IP address, etc. The table is essentially a white-list of acceptable clients. I want to be able to map clients that should have a connection (queried from the static client table) with actual connections against a database on another server.

If we use the OUTER JOIN type of logic (i.e. - client info LEFT OUTER JOIN database connection), the client info would be non-null and the database connection info would be null. So maybe any non-null value = client database connection and any null value = no client database connection.

Describe alternatives you've considered MSSQL linked servers can solve my problem, but I'd like to avoid making my database server a client to another database server if possible.

Additional context