nestjs / terminus

Terminus module for Nest framework (node.js) :robot:
https://nestjs.com/
MIT License
678 stars 99 forks source link

DiskHealthIndicator always reports: "Used disk storage exceeded the set threshold" #2522

Closed itinance closed 9 months ago

itinance commented 9 months ago

Is there an existing issue for this?

Current behavior

The DiskHealthIndicator always reports "Used disk storage exceeded the set threshold", no matter which values will be applied and no matter how free or full the disk actually is.

Minimum reproduction code

  @HealthCheck()
  check() {
    return this.health.check([
      () => this.db.pingCheck('database', { timeout: 10000 }),
      () =>
        this.disk.checkStorage('storage', {
          path: '/',
          threshold: 2, // 2GB
        }),
    ]);
  }

Steps to reproduce

just implement the check-method using DiskHealthIndicator

Expected behavior

it would not report "storage exceeds" if there is enough space left according to the threshold or thresholdPercentage value

Package version

10.2.0

NestJS version

9.0.0

Node.js version

18.17.1

In which operating systems have you tested?

Other

A debug option would be helpful to identify which values have been detected.

BrunnerLivio commented 9 months ago

the option threshold is in Bytes, not GB. If you want 2GB as your threshold, try this:

  @HealthCheck()
  check() {
    return this.health.check([
      () =>
        this.disk.checkStorage('storage', {
          path: '/',
          threshold: 2 * 1024 * 1024 * 1024, // 2GB
        }),
    ]);
  }