@Bean
public HealthIndicator healthIndicator(DataSource dataSource) {
if (dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource) {
org.apache.tomcat.jdbc.pool.DataSource tcDataSource =
(org.apache.tomcat.jdbc.pool.DataSource) dataSource;
return new AbstractHealthIndicator() {
@Override
protected void doHealthCheck(Builder healthBuilder) throws Exception {
healthBuilder.up().withDetail("active", tcDataSource.getActive())
.withDetail("max_active", tcDataSource.getMaxActive())
.withDetail("idle", tcDataSource.getIdle())