Hikari pool metrics - how to

2,098 views
Skip to first unread message

Debajyoti Pathak

unread,
Dec 12, 2019, 7:49:34 AM12/12/19
to HikariCP
I have used the HikariPoolMXBean bean to get some of the metrics and it seems all fine.
Total, active, idle & pending connections

But I couldn't find any way to get the following metrics from the MBean:
  • Average wait time to get a connection
  • Max wait time to get a connection
  • Average in-use time of a connection
  • Max in-use time of a connection
  • Max number of connections in simultaneous use.

I set up a metric registry and obtained the following timer & histogram. But I am not sure if what I am doing is correct.

Timer timerWT = timers.get(pool.getPoolName() + ".pool.Wait");
System.out.println(" Average wait time = "+ timerWT.getSnapshot().getMean());
System.out.println(" Peak wait time = "+ timerWT.getSnapshot().getMax());

Histogram histogramPC = histograms.get(pool.getPoolName() + ".pool.Usage");
System.out.println(" Peak number of connections = "+ histogramPC.getSnapshot().getMax());

And I couldn't even figure out how to get the average & max in-use time.

~Debajyoti

Brett Wooldridge

unread,
Dec 12, 2019, 9:56:23 AM12/12/19
to hika...@googlegroups.com
Have you looked at the examples in https://github.com/brettwooldridge/HikariCP/tree/dev/src/test/java/com/zaxxer/hikari/metrics (ignoring the "mocks" used by the test harness)?  The metrics that you cited, such as "Average wait time to get a connection", are only available via the use of a metrics library (Dropwizard, Prometheus, or micrometer), as you surmised.

-Brett
Reply all
Reply to author
Forward
0 new messages