# Database/sql + lib/pq connection pool metrics

**URL:** <https://forum.golangbridge.org/t/database-sql-lib-pq-connection-pool-metrics/7985>\
**Category:** Getting Help\
**Created:** [January 30, 2018, 7:19pm UTC](https://forum.golangbridge.org/t/database-sql-lib-pq-connection-pool-metrics/7985 "2018-01-30T19:19:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![falun](https://forum.golangbridge.org/letter_avatar_proxy/v4/letter/f/71c47a/32.png) [@falun](https://forum.golangbridge.org/u/falun)\
**Post date:** [January 30, 2018, 7:19pm UTC](https://forum.golangbridge.org/t/database-sql-lib-pq-connection-pool-metrics/7985/1 "2018-01-30T19:19:09Z")

</div>

Hi there! Hopefully an easy question about DB connection observability.

I’m using `database/sql` + `lib/pq` in my API service and publishing various stats about service performance into a statsd observability stack. I would like to add things like the number of open connections and the number of idle connections to the graphs I’m generating to monitor service health but as far as I can tell there is no way to find that information.

The connection pool seems totally owned by `database/sql` but there doesn’t look to be any ability to pull info out of that and swapping drivers doesn’t seem like it is a useful option since the stuff I’m interested in is above that layer.

Am I missing something here?

---

<div class="post-metadata">

**Author:** ![acim](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/acim/32/3277_2.png) [@acim](https://forum.golangbridge.org/u/acim)\
**Post date:** [January 30, 2018, 9:19pm UTC](https://forum.golangbridge.org/t/database-sql-lib-pq-connection-pool-metrics/7985/2 "2018-01-30T21:19:58Z")

</div>

It’s probably better idea to monitor pg server instead.

---

<div class="post-metadata">

**Author:** ![acim](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/acim/32/3277_2.png) [@acim](https://forum.golangbridge.org/u/acim)\
**Post date:** [January 30, 2018, 9:28pm UTC](https://forum.golangbridge.org/t/database-sql-lib-pq-connection-pool-metrics/7985/3 "2018-01-30T21:28:25Z")

</div>

[https://golang.org/pkg/database/sql/#DBStats](https://golang.org/pkg/database/sql/#DBStats)

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [April 30, 2018, 9:28pm UTC](https://forum.golangbridge.org/t/database-sql-lib-pq-connection-pool-metrics/7985/4 "2018-04-30T21:28:35Z")

</div>

Closed on April 30, 2018, 9:28pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
