Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Actuator Health Indicator

We have been using Spring Boot for several projects now, We are using the latest version 1.2.3. We are incorporating Actuator. So far things are working well except we are finding that the /health indicator [default] is showing that the service is down. This is not true. These services are that implement with datasources. It may call other SOAP or Rest services. What is the health service looking at to measure whether a service is down?

like image 999
Jay Wagner Avatar asked Dec 03 '22 17:12

Jay Wagner


1 Answers

As #derFuerst said the DataSourceHealthIndicator has the default query to check whether the DB is up or not.

If you want to use this the proper vendor specific query you should write your own health indicator in your configuration class, like this in case of Oracle data source:

@Autowired(required = false)
private DataSource dataSource;

@Bean
@Primary
public DataSourceHealthIndicator dataSourceHealthIndicator() {
    return new DataSourceHealthIndicator(dataSource, "SELECT 1 FROM DUAL");
}
like image 84
StMa Avatar answered Dec 14 '22 06:12

StMa