Skip to content

SQL Exporter: Error Collecting Metrics from Multiple PostgreSQL Databases #603

Closed Answered by keithf4
ludatos asked this question in Q&A
Discussion options

You must be logged in to vote

When you're collecting per-database metrics like this (the same metric but across different databases) you have to add something else into the metric labels that makes it different for each database you're connecting to. Easiest way with something like you have here (table size) is to use the current_database() function as an additional column. See example here:

https://github.com/CrunchyData/pgmonitor-extension/blob/main/sql/matviews/matviews.sql#L34

Also recommend including the schema to avoid similar issues with the same table in different schemas

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ludatos
Comment options

Answer selected by ludatos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants