christiangalsterer / pg-promise-prometheus-exporter

A prometheus exporter for pg-promise
MIT License
0 stars 0 forks source link

Support monitoring multiple pools #23

Closed peter-lockhart-pub closed 1 month ago

peter-lockhart-pub commented 1 month ago

If a project defines multiple pools or clients, it cannot use this library to monitor them. For example, more than 1 call to monitorPgPool will result in an error

A metric with the name pg_pool_connections_created_total has already been registered.

because a new PgPoolPrometheusExporter is created each time, which defines metrics as properties to that instance.

Consider a project that might maintain a pool of instances to a DB with write access, and then a pool of instances to a read replica - you would want to monitor these 2 separate pools.

This could be resolved by letting a user of the library specify a prefix or inject a string into the name of the metrics? Or changing the metrics to be declared in a central place and then differentiate the metrics of different exporters by a label?

christiangalsterer commented 1 month ago

Thanks @peter-lockhart-pub for reaching out. The request is totally valid and I have it already implemented for some other exporters so that metrics are only registered once and can monitor different instances with the same exporter. I will definitely add it, but I'm traveling for a view days so may need a few extra days.

christiangalsterer commented 1 month ago

A new release 2.2.0 is now available.