Health Checks

The checks that run before each heartbeat, and how to add your own.

Built in

  • datasource:<name> for each entry in datasources. Runs datasourceCheckSql (SELECT 1).
  • disk:<path> for each entry in diskPaths. degraded below diskDegradedPct (10%) free, down below diskDownPct (3%).

Your own

Register a check from anywhere in your app:

jsmonitorRegisterCheck( "queue", () => {
	var waiting = queueDepth()
	return { status: waiting < 100 ? "ok" : "degraded", detail: "#waiting# waiting" }
} )

The function returns { status: "ok" | "degraded" | "down", detail: "" }.

What happensReported as
The check throwsdown, with its message, redacted
It returns anything elsedown
It runs past checkTimeoutMsdown
It's still running from the previous heartbeatnot started again

The heartbeat's overall status is the worst check. With no checks, it's ok.

monitorRegisterCheck() does nothing when the module is disabled and never throws, so the call can stay in place everywhere.

Datasources defined in Application.bx

Checks run on a background thread, outside your application, so a datasource that only your Application.bx defines can't be found by name, neither by datasources nor by a check of your own. It reports down with a detail saying so.

Hand the check the definition instead:

jsvar definition = getApplicationMetadata().datasources.main
monitorRegisterCheck( "datasource:main", () => {
	queryExecute( "SELECT 1", [], { datasource: definition } )
	return { status: "ok", detail: "" }
} )