A video-call app I maintain failed silently. A recording got stuck, or for three days finished recordings were discarded, and nothing paged.

Browser errors went unseen too.

So I built three watchers: a daily report on the last 24 hours, Sentry in the browser, and deadline alerts for recordings and transcriptions that do not finish in time.

Daily report from Prometheus and MongoDB

metrics-reporter is a Go program that GitHub Actions schedules daily. It queries the app’s Prometheus through nginx basic auth, adds counts from a token-protected backend endpoint, and sends one report with usage, errors and latency.

Data flow: GitHub Actions cron to metrics-reporter, which reads Prometheus and the backend’s daily-counts endpoint, backed by MongoDB, and produces the daily report

One report, two sources

The reporter makes one query per metric and takes the metric from whichever source is durable for it. Simplified from cmd/main.go:

// Rows that exist in MongoDB: counted by the backend, so a restart cannot reset them.
counts, err := queryDailyCounts() // GET /api/metrics/daily-counts, token-protected

// Measurements with no database row: Prometheus.
errorsBackend := queryMetricLogged("sum(increase(app_errors_backend_total[24h]))")
msgLatencyP95 := queryMetricLogged(
	"histogram_quantile(0.95, sum(rate(app_message_latency_bucket[24h])) by (le))")
if math.IsNaN(msgLatencyP95) {
	msgLatencyP95 = 0 // too little data is not an error
}

Two details in the queries came from the first reports. A counter with a label, such as app_messages_sent_total by conversation_id, returns a series (a time line) per label value, and the reporter’s client reads only the first series of a result. Before sum(...) wrapped each query, the report counted one conversation and dropped the remaining series. The latency histogram uses sum(rate(...)) by (le), which merges the label values but keeps each bucket boundary (le) separate, as histogram_quantile needs.

An all-zero report

The first report from production showed zeros everywhere. The query helper discarded every error (_, _ := queryMetric(...)). A wrong URL or bad credentials looked the same as a quiet day. The helper now logs the error. A second flaw sat next to it: histogram_quantile returns NaN, not an error, when a window has too little data, and the report printed “NaNms”. NaN now counts as no data.

Counters that reset

The remaining undercount had two causes. Counters live in memory in the Node process: every restart zeroes them; the backend restarted several times in a single deploy session. And increase() measures a slope between the scrapes Prometheus made (it polls each service every 15 seconds): a counter that appears between two scrapes, as a rare event does, reads about 0 though its value is correct.

Neither is a query defect, so the metrics split by whether a durable source exists:

  • No database row, ever (errors, message latency, whiteboard draw events, active connections): they stay on Prometheus.
  • A row already exists (users, groups, recordings, messages, transcription segments): the report counts rows by timestamp, which a restart cannot reset.

The reporter reaches those counts through a backend endpoint, GET /api/metrics/daily-counts, which requires a token.

I considered two other ways to read those counts. A public proxy to MongoDB (nginx stream{}) would expose the whole database to read daily counts. A cron on the production host would put the reporter’s code on the machine it reports on.

Two findings from production’s Prometheus

Wiring the queries to production meant reading its Prometheus read-only, and two findings were unrelated to the report:

  • Every deploy restarts every container on the host, Jitsi included. After a deploy the containers showed start times within 8 seconds of each other, and host uptime was 8.8 days, which rules out a reboot. A release drops in-flight group calls.

  • Prometheus had been connected to the app network manually, outside the repo’s compose file. nginx /prometheus/ and the reporter depended on that connection, and recreating the container would have dropped it. The compose file now connects Prometheus to the network.

Stubs validated the config, not the network

I tested the compose and scrape config locally with stub containers serving copies of the /metrics bodies of Jitsi Video Bridge and Jicofo (Jitsi’s conference focus) from production. That surfaced a defect: Prometheus rejected Jicofo’s metrics with “invalid metric type info”, because my stub served text/plain and Jicofo serves OpenMetrics.

It could not surface that Jicofo’s REST server binds 127.0.0.1 only, because my stubs listened on all interfaces. A probe from Prometheus’s container on production got “connection refused”. The stubs validated the config; reachability needed the production network.

The reporter now reads measurements with no row from Prometheus and counts with a durable row from MongoDB through an authenticated endpoint, and it logs every failed query.

Sentry in the browser

Nothing watched the browser. I added @sentry/react to the frontend, along with a CallTranscriberDown alert (for the service that transcribes calls) and Alertmanager on the Prometheus side.

Hosted Sentry, not self-hosted GlitchTip

I weighed two ways to catch browser errors. GlitchTip is a self-hosted tracker that accepts events from Sentry’s SDKs, but it needs a web process, a worker and Postgres, with Valkey or Redis optional for larger instances, on the same host that already runs Jitsi, MongoDB and the monitoring stack. Production traffic is low and the hosted Sentry service fits.

Sentry and OpenTelemetry are not alternatives here. OpenTelemetry is the telemetry pipeline; Sentry adds issue grouping, source-mapped traces, release attribution and new-error notifications. Production exports OpenTelemetry metrics to Prometheus, with traces off and no trace backend or collector.

Sentry settings in use

From frontend/src/utils/sentryInit.ts, with the environment and beforeSend options left out:

Sentry.init({
	dsn,
	release: process.env.REACT_APP_VERSION,
	integrations: [new Sentry.Replay({ maskAllText: true, blockAllMedia: true })],
	tracesSampleRate: 0.1,
	replaysSessionSampleRate: 0.1, // 10% of sessions
	replaysOnErrorSampleRate: 1.0, // every session with an error
	sendDefaultPii: false,
});

Errors that never throw

Sentry captures what throws. Two defects threw no error: an ICE (connection negotiation) ordering defect in call setup, and a null socket in AuthContext. The release also reports socket failures through a reportSignalingError helper.

Today main reports the app socket’s failures: connect_error, socket_error and reconnect_failed. Two planned reports are not written yet: the error events the Go signaling service sends to the browser, and a call that does not reach connected in time.

Alerts on the event stream

Metrics show that the system is up. They cannot show a recording that started and never finished. The silent recording failures from the opening were missing outcomes. The third watcher is a service, the alerter, that consumes the backend’s events from NATS, applies 11 rules and sends alerts to Alertmanager.

Outcome and deadline rules

Event flow: backend and call-transcriber publish to NATS JetStream; the alerter applies 11 rules and sends to Alertmanager and to a notices box for routine events; Prometheus scrapes the alerter

Rules come in two kinds. An outcome rule matches a single event: a recording.deleted with reason stop-file-never-appeared is a critical alert. A deadline rule opens a timer on a first event and closes it on a second event. This rule, trimmed from alerter/rules.yaml (the sinks and summary fields are left out), gives a requested stop four minutes to end in a stored or deleted recording:

- name: RecordingStopNeverStored
  kind: deadline
  key: [conversationId]
  severity: critical
  within: 4m
  open: { subject: [recording.stop-requested, recording.stop-triggered] }
  close:
    - subject: [recording.stored, recording.deleted]

If neither closing event arrives in time, the alert goes off. The key pairs the events: a closing event stops the timer that an opening event with the same key value started. Four deadlines cover the recording and transcription paths (120 seconds, 4 minutes, 25 minutes, 5 minutes). The engine has no recording logic: rules are YAML, and each rule names where its findings go. Four of the 11 rules are informational: recording started, recording stored, transcript started and transcript processed send a notice, not an alert.

Two defects in the end-to-end test

The test found two defects in the design before production saw it:

  • A new critical alert could wait up to 10 minutes behind another alert, because the Alertmanager route had no group_by.
  • A deadline that never closed would be re-posted every minute with no end, until the 2-hour give_up was added.

Both are fixed. The re-run delivered two stuck recordings, 55 seconds apart, each at its 120-second deadline; before the fix the second alert could have waited up to 10 minutes.

That test used payloads I had written: copies of the backend’s event shape, not traffic from production. Before the deploy I read payloads from the production stream, read-only, and looked for the fields the rules read. They were all there, including complete as a JSON boolean and conversationId on every recording subject.

Production after the deploy

  • At startup the alerter loaded 11 rules and caught up on the backlog in 1 second; consumer lag was 0.

  • On live traffic, a recording lasted 10 minutes 9 seconds (the backend stops at its 10-minute cap), and a transcription produced transcript.processed 60 seconds after the end. Neither raised an alert.

  • Three synthetic incidents (a recording that timed out before starting, a missing stop file, an incomplete transcript) each reached Alertmanager about 10 seconds after the event, which is the group_wait.

  • A recording confirmed before its 120-second deadline raised no alert.

  • With the alerter stopped, AlerterDown went off after 151 seconds.

The alerter restarted after its 30-minute replay window on purpose, because a restart inside the window re-sends the outcome alerts.

Where my test setup misled me

One synthetic case, “session ended, never processed”, raised nothing. The backend’s transcript processor consumed my synthetic event and processed it: my test publisher had become a second consumer of the stream. A local test with the shipped rules produced the alert.

The first genuine failure arrived in the same session: a recording.deleted with reason: stop-file-never-appeared, after I stopped Jibri (Jitsi’s recorder) under a live recording. It raised a critical alert. The stop also cut off a manual parallel-recording test that was running; reading the stream before stopping Jibri would have shown the test in progress.

The event stream’s blind spot

The alerter cannot see a stream that degrades while it keeps delivering. A transcription that keeps delivering segments closes every deadline on time, even when segments never reach MongoDB, events fail to publish to NATS, or the provider is slow to finalize speech. Prometheus covers those with three metric alerts:

  • MongoDB segment writes failing above 5% for 5 minutes.
  • NATS event publishes failing above 5% for 5 minutes.
  • 95th-percentile audio lag above 5 seconds, normal being 150 to 340 milliseconds. Audio lag is the audio sent to the provider but not yet finalized when a result arrives.

Volume floors (3 errors, or 10 samples for the lag alert) keep one transient failure from paging. I dropped a fourth alert, media flowing with no results: without a new gauge, a muted call and a stalled provider look the same. Locally, each alert reached Alertmanager: the error alerts when I forced write and publish failures, the lag alert with test values.

Replayed over 14 days of production history, none would have gone off, but that window held about 27 segments, too few to show the alerts would catch a failure.

Local acceptance

Four acceptance tests passed locally: Prometheus rules validate with promtool, CallTranscriberDown goes off when the call-transcriber container stops, Alertmanager delivers a notification, and Sentry captures a frontend error.

Coverage and blind spots

Each watcher covers some failures and has a blind spot:

FailureCovered byBlind spot
Counters zeroed by a restartDaily report, which counts MongoDB rowsReads the last 24 hours, not now
Browser error that throwsSentryErrors that never throw
Browser failure with no exceptionSentry, via reportSignalingErrorOnly the app socket’s failures
Recording or transcript that never finishesAlerter deadlinesStreams that degrade but keep delivering
Transcription that degrades but keeps deliveringMetric alerts in PrometheusNeeds enough segments, and the thresholds are estimates

When a failure fell between two watchers, I added a rule to an existing watcher, not a fourth tool.

Open items

  • The thresholds (120 seconds, 4 minutes, 25 minutes, 5 minutes and the 2-hour give_up) are estimates chosen in advance, not values measured on incidents.
  • The first alert I did not cause was a false positive, and I read its cause from logs and code without reproducing it. One client toggled transcription nine times in three seconds, the transcriber reported the session ended twice, and the second end reopened a deadline that no event could close: the repeat transcript.processed reused the first event’s message ID, and JetStream’s deduplication window dropped it. The 2-hour give_up then stopped that alert’s reminders, a live test of the cap.
  • This is monitoring, not full observability: OpenTelemetry metrics feed Prometheus, but traces are off, so one request cannot be followed across services.