When looking at the connection count metric for my DB/backends, it doesn't appear to match up with what I expect (e.g., - 40 connections are shown when only 20 are expected). Is this metric wrong?
The Connection Count metric is actually measuring Connection related objects in memory - not the actual number of open connections. The Java Agent Implementation Guide's section on SQL Metrics goes into more detail on what this is actually measuring:
The number of active connection objects in memory. These objects are open (active) connections that are not closed or not yet garbage collected.
A connection is opened when connect() method is invoked for a driver. A connection closed when the connection invocation is closed using the close() method. The SQL Agent maintains weak references to connections in a set. When the connection objects are closed or garbage collected, the count reflects the changes.
In newer versions of APM, this metric has been renamed to the more descriptive "Active Connection Object Count".
For an actual count of open connections to a database, it is recommended to look at metric data supplied by application platforms, such as JMX or PMI, which often contain an Open Connection Count metric.