Reputation: 39224
You can add numerous custom health indicators to spring boot's actuator which is great as their total status is considered your application's health status.
Is it possible to just query one of the indicators specifically though?
I have about 10 indicators for a complex application to tell my total application health, and the overall check takes ~20 seconds.
There are some indicators I would like to hit more often as they provide quick responses to high-throughput components. Is it possible to query a single indicator somehow?
Upvotes: 4
Views: 2223
Reputation: 4554
It's all some autoconfigured beans
at the end When it comes to spring-boot
. All you need to do is to autowire the specific healthCheckIndicatorBean
of your choice and get things done with that bean.
for example,
@Autowired
DiskSpaceHealthIndicator diskSpaceHealthIndicator;
@Scheduled(fixedDelay = 10000)
void printDiskHealthCheckEveryTenSeconds() {
logger.info("Current Disk health {}", diskSpaceHealthIndicator.health().getStatus());
logger.info("Current Disk details {}", diskSpaceHealthIndicator.health().getDetails());
}
And, The following is the list of AutoConfigured
health Check Indicator beans that you could make use of.
CassandraHealthIndicator - Checks that a Cassandra database is up.
DiskSpaceHealthIndicator - Checks for low disk space.
DataSourceHealthIndicator - Checks that a connection to DataSource can be obtained.
ElasticsearchHealthIndicator - Checks that an Elasticsearch cluster is up.
InfluxDbHealthIndicator - Checks that an InfluxDB server is up.
JmsHealthIndicator - Checks that a JMS broker is up.
MailHealthIndicator - Checks that a mail server is up.
MongoHealthIndicator - Checks that a Mongo database is up.
Neo4jHealthIndicator - Checks that a Neo4j server is up.
RabbitHealthIndicator - Checks that a Rabbit server is up.
RedisHealthIndicator - Checks that a Redis server is up.
SolrHealthIndicator - Checks that a Solr server is up.
Upvotes: 4