Ga naar hoofdinhoud

Health and metrics

Stackiq has two endpoints for monitoring: a health check that an uptime probe can call without logging in, and Prometheus metrics for administrators. Both come from OpenRegister's AppHost and answer from the observability block in src/manifest.json, so a new check or metric is configuration, not code.

Health: GET /api/health​

GET https://<host>/index.php/apps/stackiq/api/health
  • Public: no session or app password is needed, so a load balancer or uptime monitor can call it.
  • Rate limited to 240 anonymous calls a minute, which is enough for a probe every few seconds.
  • The body names the overall status, the app, the installed version and the result of each check:
{
"status": "ok",
"app": "stackiq",
"version": "0.2.13",
"checks": {
"database": "ok",
"openregister": "ok"
}
}
CheckWhat it checks
databaseNextcloud's database answers a query (SELECT 1)
openregisterOpenRegister's object service can be reached; stackiq keeps all its data there

A failed check reads failed or failed: <reason> instead of ok, for example failed: openregister unavailable. The reason never carries internal error text; that goes to the Nextcloud log.

Status codes​

The manifest sets statusCodePolicy to adr006:

Overall statusWhenHTTP code
okEvery check passed200
degradedOnly a check marked degraded failed200
errorA critical check failed (both checks are critical)503

A probe only has to look at the HTTP code: 503 means stackiq cannot serve its users.

Example probe:

curl -fsS https://<host>/index.php/apps/stackiq/api/health || echo "stackiq is down"

Metrics: GET /api/metrics​

GET https://<host>/index.php/apps/stackiq/api/metrics
  • Administrators only. Anyone else gets the Nextcloud login redirect or a 401, never metric data.
  • The response is Prometheus text exposition format 0.0.4 (Content-Type: text/plain; version=0.0.4; charset=utf-8).
  • Every metric name starts with stackiq_.
MetricTypeMeaning
stackiq_infogaugeAlways 1; its labels carry the app version, the PHP version and the Nextcloud version
stackiq_upgauge1 while the app answers
stackiq_gebruik_totalgaugeThe number of usage records in the stackiq register (schema usage)

Example scrape configuration, with an app password of an administrator account:

scrape_configs:
- job_name: stackiq
scheme: https
metrics_path: /index.php/apps/stackiq/api/metrics
basic_auth:
username: monitoring-admin
password: <app password>
static_configs:
- targets: ['<host>']

The manifest is the source of truth​

The checks and metrics are listed in the observability block of src/manifest.json:

"observability": {
"health": {
"statusCodePolicy": "adr006",
"checks": [
{ "id": "database", "type": "database" },
{ "id": "openregister", "type": "orAvailable" }
]
},
"metrics": [
{
"name": "gebruik_total",
"type": "gauge",
"help": "Gebruik (usage) records",
"source": { "kind": "objectCount", "register": "stackiq", "schema": "usage" }
}
]
}

To add a check or a metric, add an entry here. stackiq_info and stackiq_up are always there and are not listed.

/api/settings/status is not a health check​

GET /api/settings/status says whether stackiq's settings are configured (fullyConfigured, autoConfigCompleted, the version information). It needs a login and answers 200 even when OpenRegister is down, so a monitor must not use it as a health check. Use /api/health instead.