您可以向 spring boot 的执行器添加许多自定义健康指标,这很棒,因为它们的总体状态被视为您的应用程序的健康状态。
是否可以只查询其中一个指标?
对于一个复杂的应用程序,我有大约 10 个指标可以告诉我整个应用程序的健康状况,总体检查需要大约 20 秒。
有一些指标我想更频繁地点击,因为它们可以对高吞吐量组件提供快速响应。是否可以以某种方式查询单个指标?
最佳答案
都是一些autoconfigured beans
最后说到spring-boot
.您需要做的就是 Autowiring 特定的 healthCheckIndicatorBean
并使用该 bean 完成任务。
例如,
@Autowired
DiskSpaceHealthIndicator diskSpaceHealthIndicator;
@Scheduled(fixedDelay = 10000)
void printDiskHealthCheckEveryTenSeconds() {
logger.info("Current Disk health {}", diskSpaceHealthIndicator.health().getStatus());
logger.info("Current Disk details {}", diskSpaceHealthIndicator.health().getDetails());
}
并且,以下是list的
AutoConfigured
您可以使用的健康检查指标 bean。CassandraHealthIndicator - 检查 Cassandra 数据库是否已启动。
磁盘空间健康指示器 - 检查磁盘空间是否不足。
数据源健康指标 - 检查是否可以获得到数据源的连接。
ElasticsearchHealthIndicator - 检查 Elasticsearch 集群是否已启动。
InfluxDbHealthIndicator - 检查 InfluxDB 服务器是否已启动。
JmsHealthIndicator - 检查 JMS 代理是否已启动。
MailHealthIndicator - 检查邮件服务器是否已启动。
MongoHealthIndicator - 检查 Mongo 数据库是否已启动。
Neo4jHealthIndicator - 检查 Neo4j 服务器是否已启动。
RabbitHealthIndicator - 检查 Rabbit 服务器是否已启动。
RedisHealthIndicator - 检查 Redis 服务器是否已启动。
SolrHealthIndicator - 检查 Solr 服务器是否已启动。
关于spring-boot - Spring Boot Actuator - 查询特定的健康指标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46594007/