I'm somewhat new to the Node ecosystem and am trying to instrument some of our Node services to provide better metrics about their internal state and one of the glaring blindspots we currently have is around our database connection pools.
Coming from a Java background, I've primarily relied on libraries like Hikari which exposes key metrics like total connections, active connections, idle connections, and threads queued and waiting for a connection from the pool (https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management). These are all critical metrics to understand to ensure your connection pool is properly sized and your application is functioning as expected.
In our current Node services we are using TypeORM and connecting to a Postgres DB. I'd like to find a way to access and expose these same core metrics but I'm finding little to no information about the best way to do it so I have two questions:
With TypeORM and Postgres, is there a way to get a handle on the connection pool internals? It looks like I may be able to get part way there with something like
getConnectionManager().connectionsbut I'm not seeing any way to get more detailed information like distinguishing between active and idle connections.Is there a standard mechanism to expose internal application metrics for a Node service that's somewhat comparable to JMX on the JVM?