Monitoring
Reminders, sync links and backups run in the background, where a failure shows no error page. GET /metrics exposes them in the Prometheus format, and GET /healthz is a liveness check. Every request is also logged as one JSON line with a correlation id.
Turning it on
/metrics is off by default. The numbers reveal how the instance is used (how many accounts, how busy it is, when people are active), so you choose who can read them. There are two ways to do that, and you can use both.
A bearer token on the main port
METRICS_TOKEN=$(openssl rand -hex 32)/metrics then answers on the normal port, and only to requests carrying Authorization: Bearer <token>. Without the variable the route answers 404; with it but without the right header, 401. Use this when Prometheus reaches HyperCloud through your reverse proxy or from another host.
A separate listener with no token
METRICS_LISTEN=127.0.0.1:9464This opens a second port that serves only /metrics, with no authentication. Its address is what keeps it private, so by default it must bind a loopback address (127.0.0.1, ::1, localhost), and the server refuses to start otherwise. This suits a Prometheus or agent running on the same machine.
In Docker, loopback inside the container is unreachable from a Prometheus container next to it. If the port is on a network only Prometheus can reach, say so explicitly:
environment:
METRICS_LISTEN: 0.0.0.0:9464
METRICS_LISTEN_ALLOW_PUBLIC: "1"
# and do not publish 9464 under `ports:`The server logs a warning on every boot with that combination.
Scraping
# prometheus.yml
scrape_configs:
- job_name: hypercloud
scrape_interval: 15s
scheme: https
authorization:
type: Bearer
credentials_file: /etc/prometheus/hypercloud-token
static_configs:
- targets: ["calendar.example.com"]For the separate listener, drop scheme and authorization and target 127.0.0.1:9464 (or the container's name and port).
Health check
GET /healthz needs no authentication. It answers 200 ok when the database responds, and 503 when it does not. The Docker image's HEALTHCHECK uses it, and it works as a Kubernetes liveness probe:
livenessProbe:
httpGet: { path: /healthz, port: 3001 }
periodSeconds: 30What is exported
Every metric is prefixed hypercloud_, except the standard process_* ones, which use the names stock dashboards expect.
Reminders
| Metric | Type | Labels |
|---|---|---|
hypercloud_reminder_scheduler_lag_seconds | histogram | |
hypercloud_reminder_scheduler_last_tick_timestamp_seconds | gauge | |
hypercloud_reminder_scheduler_tick_failures_total | counter | |
hypercloud_reminders_sent_total | counter | channel, status |
Lag is the time between a reminder's scheduled instant and when it was actually sent. The scheduler wakes every 30 seconds, so anything up to 30 seconds is normal.
The last-tick timestamp is the one to alert on. A stalled scheduler sends nothing, and a reminder that is never sent records no lag at all. Neither metric exists when Web Push (VAPID_*) is not configured, since there is then no scheduler.
reminders_sent_total counts one delivery per device. Its status label is ok, error (the push service refused), or gone (the device unsubscribed and was removed, which is normal). channel is webpush.
Sync
| Metric | Type | Labels |
|---|---|---|
hypercloud_dav_sync_runs_total | counter | kind, result |
hypercloud_dav_requests_total | counter | kind, method, status |
hypercloud_subscription_fetches_total | counter | result |
hypercloud_sync_links | gauge | kind, state |
hypercloud_sync_oldest_success_timestamp_seconds | gauge | kind |
The label values are:
kind:caldav,carddav(address books) orics(subscriptions).result:okorerror. ICS fetches can also benot_modified.state:okorfailing.failingmeans the last sync ended in an error.status: a status class (2xx,4xx, …), orerrorwhen no response arrived at all (DNS failure, timeout, refused address).
oldest_success is the least recent successful sync across all links of that kind. A link that has never succeeded counts from when it was created. When nothing of a kind is linked, the series is absent.
Backups
| Metric | Type | Labels |
|---|---|---|
hypercloud_backup_last_success_timestamp_seconds | gauge | kind |
hypercloud_backup_last_duration_seconds | gauge | kind |
hypercloud_backup_failures_total | counter | kind |
kind is database (the daily VACUUM INTO snapshot) or accounts (the backups into each account's Files, and the daily per-user .hypercalendar files of accounts without Files). For accounts the success is the last hourly pass in which no account's backup failed, so it stays fresh while accounts back up weekly. The backups keep their outcomes in the database and these are read from there, so the failures count does not restart with the server.
Audit log
| Metric | Type | Labels |
|---|---|---|
hypercloud_audit_events_total | counter | |
hypercloud_audit_dropped_total | counter | |
hypercloud_audit_pruned_total | counter |
HTTP
| Metric | Type | Labels |
|---|---|---|
hypercloud_http_requests_total | counter | route, method, status |
hypercloud_http_request_duration_seconds | histogram | route, method |
Load
| Metric | Type | Labels |
|---|---|---|
hypercloud_memory_budget_bytes | gauge | state (total, in_use) |
hypercloud_memory_limit_bytes | gauge | |
hypercloud_requests_refused_total | counter | reason (busy, memory, too_large, timeout) |
The memory budget is what the work holding whole files in memory may hold at once. hypercloud_memory_limit_bytes is the container's memory limit, and is missing without one. A request is refused as busy past MAX_REQUESTS, as memory when its body found no room in the budget in time, as too_large when it never could, and as timeout past REQUEST_TIMEOUT.
Instance
| Metric | Type | Labels |
|---|---|---|
hypercloud_db_size_bytes | gauge | |
hypercloud_users | gauge | |
hypercloud_events | gauge | |
hypercloud_build_info | gauge | version, node_version (empty) |
process_resident_memory_bytes | gauge | |
process_cpu_seconds_total | counter | |
process_start_time_seconds | gauge |
hypercloud_db_size_bytes measures the main database file and excludes the WAL. hypercloud_events excludes the trash.
What labels never contain
Labels never carry a user, event, calendar or link. They never include a name, an id, a URL, or a token from a feed or poll link.
routeis the pattern that answered (/api/events/:id), never the path. A request no route matched is labelled with the pattern of the middleware that answered it, orunmatched.methodcollapses anything unexpected toother.
Dashboard and alerts
Grafana dashboard: import it in Grafana (Dashboards → New → Import) and pick your Prometheus data source. It has panels for health, reminders, sync, HTTP and the process.
Alert rules: load them with
rule_files: [alerts.yml]. They cover:- a scheduler with no pass in 5 minutes;
- reminder p95 lag over 2 minutes;
- pushes failing;
- links failing for 6 hours, or not synced in 3 days;
- backups older than 26 hours, or failed;
- more than 5% of requests answered with a 5xx;
- memory over 90% of the container's limit;
- requests being turned away under load;
- the server restarting more than twice in an hour (killed for memory, mostly).
The thresholds are starting points; tune them to your instance.