Skip to content

Dropwizard HealthChecks

Brett Wooldridge edited this page Jan 30, 2015 · 12 revisions

HikariCP 2.3.2+ supports Dropwizard HealthChecks.

You can enable health checks by configuring a HealthCheckRegistry instance in HikariConfig or HikariDataSource (depending on which you use for configuration). There is a method, setHealthCheckRegistry(HealthCheckRegistry), for this purpose.

HikariCP also supports additional health check specific configuration through the addHealthCheckProperty(key, value) and/or setHealthCheckProperties(Properties) methods. The properties specific to each health check is documented below.


<pool name>.pool.ConnectivityCheck

This health check will obtain a Connection from the pool and immediately return it. The standard HikariCP internal "aliveness" check will be run.

By default this health check will use the standard pool connectionTimeout when obtaining a Connection. However, if the connectionTimeout is disabled (set to 0) then a timeout of 10 seconds will be used.

A specific timeout can also be set through a health check property called connectivityCheckTimeoutMs:

config.addHealthCheckProperty("connectivityCheckTimeoutMs", "1000");

If an "alive" Connection can be obtained, a HealthCheck.Result that is healthy will be returned. If the connection fails or times out the SQLException of the failure is available through the Result.getError() method.


<pool name>.pool.Connection99Percent (optional)

This health check checks that, on average, 99% of all calls to getConnection() obtain a Connection within a specified number of milliseconds. The 99th percentile calculation is provided Dropwizard Metrics and is heavily biased to the past 5 minutes of measurement.

This health check is only available if a Dropwizard MetricRegistry has been configured. Additionally, a expected99thPercentileMs health check property must be specified to enable this health check. For example:

config.addHealthCheckProperty("expected99thPercentileMs", "10");

In this example, the health check will return a HealthCheck.Result that is healthy if the 99th percentile of getConnection() calls complete within 10ms. If the 99th percentile of getConnnection() completion times exceeds 10ms, an unhealthy result is returned and a message similar to the one below is available through the Result.getMessage() method.

99th percentile connection wait time of 54ms exceeds the threshold 10ms