-
Hello everyone, I'm using the burningalchemist/sql_exporter Docker image to collect metrics from my PostgreSQL database and expose them to Prometheus. However, I'm encountering an issue where sql-exporter reports duplicate metrics errors. Configuration DetailsSQL Exporter Configuration (sql-exporter.yml):
Collector Configuration (table_sizes.collector.yml):
Error MessageDespite the configuration, I keep encountering the following error in the sql-exporter logs:
Steps Taken
NeedI need a complete example of how to configure sql-exporter to collect metrics from multiple PostgreSQL databases without encountering duplicate metric errors. Questions
Any help or suggestions would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 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 |
Beta Was this translation helpful? Give feedback.
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