Skip to content

Monitoring

Prometheus metrics and Kubernetes-style health endpoints are served on port 9090 by @open-xchange/fastify-sdk, separate from the API port (8080).

Health endpoints

  • /live - returns 200 while the process is alive. Failing this restarts the pod.
  • /ready - returns 200 only when ready for traffic (database reachable when SQL_ENABLED=true, no pending migrations blocking startup).

The Helm chart's livenessProbe/readinessProbe values point at these by default (see Configuration).

Metrics

Scrape /metrics. Booking-specific counters (src/services/metrics.ts):

MetricTypeLabelsPurpose
booking_polls_totalcounteroperation (created|finalized|deleted|expired)Poll lifecycle events, including auto-deletion by the cleanup job
booking_voters_totalcounteroperation (created|updated|deleted)Voter mutations
booking_votes_totalcounter-Votes cast or updated
booking_appointment_types_totalcounteroperation (created|updated|paused|unpaused|deleted|purged)Appointment type operations (owner API). purged is the cleanup job finishing a deletion the owner asked for earlier — see below
booking_bookings_totalcounteroperation (created|cancelled|rebooked|conflict|expired)Booking lifecycle: conflict is the 409 on a slot that is not bookable, counted both when a booking is created and when a verified booking is refused at its start, before any code is mailed (the contention/abuse signal worth watching); expired is auto-deletion by the cleanup job. A rebook counts once as rebooked, once as cancelled (the old booking), and once as created (the new one). No actor split on cancelled (owner vs. booker) in this first cut — counters are append-only, a label can be added later
booking_verifications_totalcounteroperation (issued|verified|invalid|expired|exhausted|resent)Email verification challenges, where a page requires the booker to confirm their address (see Configuration). Only moves where features.emailVerification is on. The gap between issued and verified is the drop-off, and invalid and expired say why bookers fall into it. An abandoned challenge increments neither: expired needs someone to come back with a stale code. invalid also covers an unknown or already-spent verification id, so a sweep for ids shows up there rather than as its own signal. exhausted is an attempt on a challenge whose five guesses are already gone, and the booking page hides both buttons at that point, so a repeated exhausted is a client that is not the booking page. issued and resent count codes actually sent: a start or resend refused for the cooldown or either cap is counted nowhere
booking_slot_refusals_totalcounterreason (outside-windows|overlaps-booking|too-soon|beyond-horizon|day-cap-reached)Why the slot check refused a booking attempt: the transactional recheck when a booking is created, or the check at the start of a verified booking, before any code is mailed. Reasons are server-internal — clients only ever see an opaque "slot unavailable"
booking_mcp_tool_calls_totalcountertool (a catalog name or unknown), outcome (ok|domain_error|invalid|not_found)Calls to the MCP endpoint's tools. Only moves once mcp.enabled is set. A rising not_found is the capability-enumeration signal: someone sweeping for page ids or manage tokens. The domain counters above keep firing from the service layer, so bookings made through a tool are counted there as well
booking_freebusy_fetch_totalcountersource (rest|servlet), outcome (ok|error|restricted|unresolved|other)Free/busy lookups for calendar conflict checking. source says which busy source a deployment is on — rest is the administrative free/busy REST API, servlet the deprecated interim one; watch it during a migration. Everything but ok failed open, but the reasons differ and only error is a fault: error is a transport or HTTP failure, while restricted (the owner withdrew their free/busy visibility) and unresolved (the calendar does not know the owner) are answers — the check ran and came back blind, so those pages offer slots as if the setting were off. A steady restricted rate is a deployment whose com.openexchange.calendar.freeBusyVisibility.default is not all; unresolved rising for every owner at once means the preliminary endpoint moved, not that the owners vanished. Lookups served from the 30-second cache are not counted
booking_mail_totalcountertemplate, operation (enqueued|sent|retried|failed)Outbound mail outcomes per template. Expected template values: booking-confirmation, booking-invitation, booking-owner-notification, booking-rescheduled, booking-rescheduled-owner, booking-cancellation, booking-cancelled-owner, booking-manage-link, booking-verification. A growing failed count means mails exhausted their retries — check the SMTP config and the mail_outbox table

Standard Node.js and Fastify metrics are also exposed (nodejs_heap_size_used_bytes, nodejs_eventloop_lag_seconds, http_request_duration_seconds, etc.) via the SDK.

The legacy Java service's ?metrics=true JSON/HTML dumps are intentionally not ported - Prometheus scraping replaces them entirely.

Cleanup job visibility

The auto-deletion job (src/services/cleanup.ts) runs on a fixed interval (autoDeletionIntervalMinutes from config.yaml, default 12 hours) with an initial delay of half that interval. One run has four independently error-tolerant stages (one failing stage never starves the others), each deleting in batches of 5000 rows:

  1. Expired polls — logs BK Server: auto-deleted <n> polls, increments booking_polls_total{operation="expired"}.
  2. Expired bookings — rows whose retention anchor (slot end for confirmed bookings, cancellation time for cancelled ones) lies more than autoDeletionDelayAfterBookingEndMinutes in the past; logs BK Server: auto-deleted <n> bookings, increments booking_bookings_total{operation="expired"}.
  3. Deleted booking pages — a page the owner deleted while an appointment booked through it was still upcoming is kept as a tombstone, because its booking rows are what block those times on the owner's other pages. This stage removes the tombstone once stage 2 has taken its last booking row; logs BK Server: purged <n> deleted booking pages, increments booking_appointment_types_total{operation="purged"}. It runs after the bookings stage on purpose. A live booking page is still never auto-deleted.
  4. Settled outbox mails — sent/failed mail_outbox rows older than 7 days (fixed); logs BK Server: purged <n> settled outbox mails.

A configured interval of 0 or less disables the whole job - the expired counters simply stay flat in that case, which is expected, not a fault. Deleted booking pages then stay on disk as well, since stage 3 is the only thing that reclaims them. They hold one row each and stay invisible to owners and bookers, so this costs storage rather than correctness.

The job requires no cross-replica coordination: every stage is a batched conditional DELETE, so each replica's delete only affects rows still matching its own query and concurrent replicas racing the same batch are harmless (a row already deleted by one replica just isn't matched by another's next query).

Suggested alerts

- alert: BookingHighErrorRate
  expr: sum(rate(http_request_duration_seconds_count{code=~"5.."}[5m])) > 1
  for: 5m

- alert: BookingEventLoopLag
  expr: nodejs_eventloop_lag_seconds > 0.1
  for: 5m

- alert: BookingReadinessFlapping
  expr: changes(up{job="booking"}[15m]) > 3
  for: 5m

Tune thresholds to observed traffic - Booking has no built-in SLOs to calibrate against yet.

Logs

Booking logs via Pino (through the SDK). Set LOG_LEVEL to tune verbosity; avoid trace in production since it can include request bodies (including voter names/emails on public voting endpoints).

Manage tokens appear in query strings. A booking's manage link has the form {bookingBaseURL}?manage=<secret> - the same URL-as-capability model as poll and booking-page links, but more sensitive: the token authorizes cancelling/rebooking that booking. Query strings routinely end up in proxy and access logs, so treat any log layer in front of Booking accordingly: do not log query strings on /booking/book (and ideally on /booking/v1/manage/*), or scrub/truncate them - e.g. nginx with a dedicated location /booking/book whose log_format omits $args, or the equivalent filter in your ingress/CDN. The service itself does not log manage tokens. Accepted for v1 (recorded trade-off); path-style manage URLs may come before GA if log-hygiene requirements harden.

Debugging

Inspect the database directly when a poll seems stuck or a cleanup pass looks wrong:

kubectl exec deployment/<release>-booking -- \
  node -e "console.log(process.env.DB_BOOKING_HOST)"

Then connect with a MariaDB client using the same credentials the pod uses, and inspect poll.delete_at / poll.status directly against the bookingdb schema described in ADR-0004.