【问题标题】:in Spring actuator: does HealthEndPoint.health() give the same result as calling /health endpoint?在 Spring 执行器中:HealthEndPoint.health() 是否给出与调用 /health 端点相同的结果?
【发布时间】:2020-01-14 11:03:13
【问题描述】:

我有一个 Spring boot (2.1.10.RELEASE) 应用程序,并且我已激活执行器来监控应用程序的运行状况。我在标题中的问题已经解释过:调用 HealthEndPoint 的方法 health 将给出与调用相同的结果,例如http://localhost:8080/health?还是后者会检查更多我不知道的事情?

【问题讨论】:

    标签: spring spring-boot-actuator spring-boot-2


    【解决方案1】:

    是的,状态结果将是相同的,但您可以通过创建自定义运行状况指示器来自定义详细信息以执行某些特定的运行状况检查

    自定义执行器健康端点

    @Override
        public Health health() {
            int errorCode = check(); // perform some specific health check
            if (errorCode != 0) {
                return Health.down().withDetail("Error Code", errorCode).build();
            }
            return Health.up().build();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 2018-06-18
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 2020-09-13
      相关资源
      最近更新 更多