Looking for a way to get the number of available connections

Hi there,

for our production monitoring with prometheus, I would like to be able to monitor available postgres connections in the Ecto connection pool (poolboy I guess). I did some stupid mistakes with transactions, like putting to much stuff (calls to rest services) into the transaction, and got into issues with the connection-pool. For the future I would feel much better if I could monitor that.

I tried digging into the sources, but don’t see an easy way of doing that. Any ideas? :slight_smile:


iex(2)> :poolboy.status(MyApp.Repo.Pool)
{:ready, 2, 0, 0}

I think it’s {state, available workers, overflow workers, busy workers}, where state is one of [:ready, :full, :overflow]. I think with Ecto overflow is not normally used.