Extensions
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HikariCP JMX – Unable to split Pool metrics by pool name when multiple pools exist in the same JVM

Mouadrhm
Visitor

Hi everyone,

I’m working with Dynatrace Managed on prem and a custom JMX extension to collect HikariCP metrics.

I can successfully collect metrics from both:

  • com.zaxxer.hikari:type=PoolConfig
  • com.zaxxer.hikari:type=Pool

There is however an important difference between the two:

  • PoolConfig exposes a PoolName attribute → I can define a dimension (e.g. pool.name) and split metrics per pool 
    Mouadrhm_0-1777973544830.png

     



  • Pool does not expose the pool name as an attribute → the pool name only appears in the ObjectName display, not as a key property 

    Mouadrhm_1-1777973618034.pngMouadrhm_2-1777973646376.png

     

Because of this, when multiple Hikari pools run in the same JVM, Dynatrace:

  • collects Pool metrics correctly
  • but aggregates them at JVM level
  • making it impossible to split runtime metrics (ActiveConnections, IdleConnections, etc.) per pool

Example:

  • Pool A: IdleConnections = 2
  • Pool B: IdleConnections = 5
  • Dynatrace reports: IdleConnections = 7 for the same process

This makes per‑pool monitoring and alerting unreliable.

Constraints:

  • I cannot modify the application code
  • I cannot change how HikariCP exposes its JMX MBeans
  • Only the Dynatrace side (extension/configuration) can be adjusted

Question:
Is this a known limitation with HikariCP JMX in Dynatrace Managed?
Is there any supported Dynatrace‑side workaround to avoid Pool metric aggregation when multiple pools exist in the same JVM?

Thanks in advance for any feedback or guidance.
My extension code : 

name: custom:hikari.jmx.metrics
version: 1.0.1
minDynatraceVersion: 1.303.0

author:
  name: M
metrics:
  - key: hikari.connections.active
    metadata:
      displayName: Hikari Active Connections
      unit: Count

  - key: hikari.connections.idle
    metadata:
      displayName: Hikari Idle Connections
      unit: Count

  - key: hikari.connections.total
    metadata:
      displayName: Hikari Total Connections
      unit: Count

  - key: hikari.threads.awaiting
    metadata:
      displayName: Hikari Threads Awaiting Connection
      unit: Count

  - key: hikari.connections.acquired
    metadata:
      displayName: Hikari Connections Acquired
      unit: Count

  - key: hikari.connections.created
    metadata:
      displayName: Hikari Connections Created
      unit: Count

  - key: hikari.connections.timeout
    metadata:
      displayName: Hikari Connections Timeout
      unit: Count

  - key: hikari.config.connection.timeout
    metadata:
      displayName: Hikari Connection Timeout
      unit: MilliSecond

  - key: hikari.config.idle.timeout
    metadata:
      displayName: Hikari Idle Timeout
      unit: MilliSecond

  - key: hikari.config.max.lifetime
    metadata:
      displayName: Hikari Max Lifetime
      unit: MilliSecond

  - key: hikari.config.validation.timeout
    metadata:
      displayName: Hikari Validation Timeout
      unit: MilliSecond

  - key: hikari.config.minimum.idle
    metadata:
      displayName: Hikari Minimum Idle
      unit: Count

  - key: hikari.config.maximum.pool.size
    metadata:
      displayName: Hikari Maximum Pool Size
      unit: Count

  - key: hikari.config.leak.detection.threshold
    metadata:
      displayName: Hikari Leak Detection Threshold
      unit: MilliSecond

  - key: hikari.config.keepalive.time
    metadata:
      displayName: Hikari Keepalive Time
      unit: MilliSecond

  - key: hikari.config.initialization.fail.timeout
    metadata:
      displayName: Hikari Initialization Fail Timeout
      unit: MilliSecond

jmx:
  groups:
    - group: hikari
      subgroups:

        # =========================
        # POOL (pool.name depuis ObjectName)
        # =========================
        - subgroup: pool
          query: "com.zaxxer.hikari:type=Pool (*)"

          dimensions:
            - key: pool.name
              value: property:name

          metrics:
            - key: hikari.connections.active
              type: gauge
              value:
                attribute: ActiveConnections

            - key: hikari.connections.idle
              type: gauge
              value:
                attribute: IdleConnections

            - key: hikari.connections.total
              type: gauge
              value:
                attribute: TotalConnections

            - key: hikari.threads.awaiting
              type: gauge
              value:
                attribute: ThreadsAwaitingConnection

            - key: hikari.connections.acquired
              type: count
              value:
                attribute: ConnectionsAcquired

            - key: hikari.connections.created
              type: count
              value:
                attribute: ConnectionsCreated

            - key: hikari.connections.timeout
              type: count
              value:
                attribute: ConnectionsTimeout

        # =========================
        # POOL CONFIG (pool.name via attribute)
        # =========================
        - subgroup: poolconfig
          query: "com.zaxxer.hikari:type=PoolConfig (*)"

          dimensions:
            - key: pool.name
              value:
                attribute: PoolName

          metrics:
            - key: hikari.config.connection.timeout
              type: gauge
              value:
                attribute: ConnectionTimeout

            - key: hikari.config.idle.timeout
              type: gauge
              value:
                attribute: IdleTimeout

            - key: hikari.config.max.lifetime
              type: gauge
              value:
                attribute: MaxLifetime

            - key: hikari.config.validation.timeout
              type: gauge
              value:
                attribute: ValidationTimeout

            - key: hikari.config.minimum.idle
              type: gauge
              value:
                attribute: MinimumIdle

            - key: hikari.config.maximum.pool.size
              type: gauge
              value:
                attribute: MaximumPoolSize

            - key: hikari.config.leak.detection.threshold
              type: gauge
              value:
                attribute: LeakDetectionThreshold

            - key: hikari.config.keepalive.time
              type: gauge
              value:
                attribute: KeepaliveTime

            - key: hikari.config.initialization.fail.timeout
              type: gauge
              value:
                attribute: InitializationFailTimeout



0 REPLIES 0

Featured Posts