1

Hell,

Is there any that I can get the HkariCP connection pool metric information such as total connections, idle connections and so on?

I know HikariPool logs such information like:

Before cleanup pool stats db (total=20, inUse=0, avail=20, waiting=0)

But it is too frequently and my code cannot control it. I would like to log such information in a configurable period such as 1 minutes. BTW, I use Scala Slick 3.0

hy0521
  • 63
  • 1
  • 1
  • 6

2 Answers2

8

HikariCP supports Dropwizard Metrics. Check out this link:

https://github.com/brettwooldridge/HikariCP/wiki/Dropwizard-Metrics

brettw
  • 10,664
  • 2
  • 42
  • 59
0

Dropwizard Metrics: (from https://stackoverflow.com/a/42301023)

    private MetricRegistry metricRegistry;
    ...
    if(dataSource instanceof HikariDataSource) {
        ((HikariDataSource) dataSource).setMetricRegistry(metricRegistry);
    }

Prometheus Metrics:

    private DataSource dataSource;
    ...
    if (dataSource instanceof HikariDataSource) {
        ((HikariDataSource) dataSource).setMetricsTrackerFactory(new PrometheusMetricsTrackerFactory());
    }
Mikhail Ionkin
  • 568
  • 4
  • 20