spring-boot - Spring Boot Actuator - 查询特定的健康指标?

标签 spring-boot monitoring spring-boot-actuator

您可以向 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());
  }

并且,以下是listAutoConfigured您可以使用的健康检查指标 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/

相关文章:

Spring-boot 2.0.0 M1 - 执行器不工作

spring - 如何在Spring Boot中的存储库中的@Aggregation注释中添加 "allowDiskUse"?

java - Maria DB 通信链接失败异常

javascript - 使用 Prometheus 监控 Angular 前端

linux - 如何在 Zabbix Server 中添加特定的 Windows 服务以通过电子邮件警报进行监控?

cocoa - 在 Mac OS 中监视剪贴板

spring-boot - Spring Boot 2 Actuator (2.0.1-RELEASE) - 请求和响应主体

java - 将 Spring-Boot 与 StatsD 连接的最佳方式是什么,尤其是对于计时器?

spring-boot - Netflix Zuul CORS

java - Springboot - AWS Elasticbeanstalk - 资源无法解析