Skip to main content

Function: determineMonitorStatus()

function determineMonitorStatus(httpStatus: number):
| "degraded"
| "down"
| "up";

Defined in: shared/utils/httpStatusUtils.ts:66

Determines monitor status ("up", "degraded", or "down") from an HTTP status code.

Parametersโ€‹

httpStatusโ€‹

number

The HTTP status code to evaluate (integer).

Returnsโ€‹

"degraded" | "down" | "up"

Up if the site is responding normally, "degraded" if responding certain server issues, "down" if server error or invalid code.

Remarksโ€‹

1xxโ€“4xx: "up" (site is responding)

  • 5xx degraded errors: "degraded" (server responding but with issues)

    • 501 Not Implemented
    • 505 HTTP Version Not Supported
    • 510 Not Extended
  • 5xx server errors: "down" (server not functioning properly)

    • 500 Internal Server Error
    • 502 Bad Gateway
    • 503 Service Unavailable
    • 504 Gateway Timeout
    • Others
  • <100 or >599: "down" (invalid code)

Used by monitoring services to classify site health with three-state model.

Exampleโ€‹

determineMonitorStatus(200); // "up"
determineMonitorStatus(404); // "up"
determineMonitorStatus(501); // "degraded"
determineMonitorStatus(500); // "down"
determineMonitorStatus(999); // "down"

Seeโ€‹

MDN: HTTP response status codes