terminus icon indicating copy to clipboard operation
terminus copied to clipboard

How to return all rejected health checks?

Open denchik92 opened this issue 4 years ago • 3 comments

Expected behavior

Have some health indicators for database, Redis and Rabbit:

import { Get, Controller } from '@nestjs/common';
import {
  HealthCheck,
  HealthCheckResult,
  HealthCheckService,
  HealthIndicatorResult,
  TypeOrmHealthIndicator,
} from '@nestjs/terminus';
import { RedisHealthIndicator } from '@/services/health/redis.health';
import { RabbitHealthIndicator } from '@/services/health/rabbit.health';

@Controller('system')
export class SystemController {
  public constructor(
    private readonly health: HealthCheckService,
    private readonly db: TypeOrmHealthIndicator,
    private readonly redisHealthIndicator: RedisHealthIndicator,
    private readonly rabbitHealthIndicator: RabbitHealthIndicator,
  ) {}

  @Get('healthcheck')
  @HealthCheck()
  public check(): Promise<HealthCheckResult> {
    return this.health.check([
      (): Promise<HealthIndicatorResult> => this.db.pingCheck('database'),
      (): Promise<HealthIndicatorResult> =>
        this.redisHealthIndicator.isHealthy(),
      (): Promise<HealthIndicatorResult> =>
        this.rabbitHealthIndicator.isHealthy(),
    ]);
  }
}

In case I turn off both Redis and Rabbit this healthcheck endpoint will return only one first rejected health indicator in "error" object: { "status": "error", "info": { "database": { "status": "up" } }, "error": { "status": "down", "details": "Rabbit check failed: socket hang up" }, "details": { "database": { "status": "up" }, "status": "down", "details": "Rabbit check failed: socket hang up" } }

As you can see there is no any word about Redis health indicator in response. Is there any chance to return all health indicators?

denchik92 avatar Dec 03 '21 15:12 denchik92

Could you be more specific about the Pantheon API you are attempting to call? (This doesn't look like a Terminus issue)

greg-1-anderson avatar Dec 03 '21 17:12 greg-1-anderson

Could you be more specific about the Pantheon API you are attempting to call? (This doesn't look like a Terminus issue)

edited

denchik92 avatar Dec 03 '21 18:12 denchik92

Unfamiliar with this code. This doesn't look like a Terminus issue.

greg-1-anderson avatar Dec 08 '21 22:12 greg-1-anderson

This is not Pantheon Terminus related.

scottbuscemi avatar Nov 29 '22 18:11 scottbuscemi