Operational metrics
Authenticated Prometheus metrics for observed HTTP traffic, admission and process health.
GET /api/monitoring/metrics exports Prometheus text format. Scrape with an admin-scoped API key in Authorization: Bearer <key>, a dashboard session, or a CLI token. Unlike the dashboard, this endpoint never permits an unauthenticated loopback request when login is disabled. Protect the scrape connection with TLS or a trusted network. Do not put credentials in scrape URLs.
Configure the scraper to request /api/monitoring/metrics over that protected connection and send its admin key as a bearer credential from a private secret file. The usual inference key without admin scope does not grant scrape access. Do not include the secret in target labels or query parameters. A failed collection returns HTTP 503 with a fixed message; fix collection before treating a missing series as zero.
HTTP traffic and latency
durindoor_http_requests_total counts starts at instrumented HTTP handlers. durindoor_http_active_requests counts those without an observed terminal outcome. durindoor_http_requests_completed_total{outcome="…"} records one of five fixed transport outcomes: completed (clean body EOF), http_error (HTTP status at least 400 with clean EOF), stream_error (body transport error), cancelled (request abort or reader cancellation), or handler_error (an exception escaping the observed handler or a non-Response result). The existing correlation wrapper converts handler exceptions to HTTP 500, which counts as http_error once consumed. Bodyless responses and HEAD requests finish at handler return. For an implicit HEAD handled by GET, accounting leaves the returned body untouched: the framework may discard it without reading or cancelling it.
durindoor_http_errors_total sums HTTP, stream and escaping-handler failures; it excludes cancellations. An HTTP 200 body containing a provider error event still has a clean HTTP transport. These metrics do not establish semantic provider success, billable operations or upstream attempt counts. Explicit public route wrappers start observations; shared handler correlation alone does not. Internal default-batch rows add no HTTP observations, while batch creation, listing, retrieval and cancellation HTTP operations do. Retries and nested handlers for one observed Request do not add client requests. Legacy completions binds its derived Request through the existing trusted-identity copy; Gemini binds its derived Request explicitly. Only an active outer observation can be inherited; matching ID strings alone do not merge separate requests. Distinct explicit HTTP observations remain independent even when nested.
durindoor_http_request_duration_seconds is a cumulative histogram from handler entry until terminal observation, including downstream body consumption. Fixed finite bucket bounds are 0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60 and 300 seconds, plus +Inf. _count and _sum include observed terminal durations. An unread, uncancelled non-HEAD body remains active and has no terminal duration. Scraping never consumes response bodies. A reused Request object is one observation, including repeated calls after completion; independent client requests must have distinct Request objects. Gemini and legacy completion bridges observe the final client response, including the interval after an internal response has been consumed for conversion. Observation does not change their existing propagation of request abort signals.
Coverage includes explicitly wrapped chat, completions, Messages, Responses, embeddings, media, search, fetch, rerank, moderation, token-count, files, batches, model-detail and catch-all HTTP exports. Gemini v1beta POST includes its chat bridge, parse failures and native TTS branch. Native HTTP operations and public realtime credential/session HTTP operations are also observed. OPTIONS is excluded. These are observed handler totals, not all traffic reaching the server. Root model listing (including the /v1 alias), models/info, plugin manifest, image-artifact downloads, the management translator/send diagnostic, internal realtime auth/control calls, WebSocket upgrades/sessions/turns and middleware denials before a handler are excluded. Those lifecycle gaps remain tracked under #1129.
Admission and provider observations
durindoor_active_requests retains the existing dashboard tracker's in-flight count, whose current producer is the chat attempt path. It differs from durindoor_http_active_requests, which observes client HTTP responses through body termination. Neither includes queued work as a separate addition to active work. durindoor_admission_queued_requests counts waiting entries across the process's admission gates; each waiter occupies one gate at a time. Unlimited paths bypass those gates.
durindoor_admission_failures_total{reason="timeout|aborted"} counts actual gate rejections. An already aborted acquisition counts once even on an otherwise unlimited path, matching the gate's existing rejection behavior. Multi-tier preflight and post-grant abort checks count their own rejection once; hierarchical rollback and release do not add failures. Payload-admission rejections occur before concurrency tiers and are not included in this counter. These are concurrency-admission failures, not every authentication, quota, policy or provider rejection.
durindoor_client_admission_failures_total{reason="auth_missing|auth_invalid|policy|client_limit"} counts a selected local denial only when the observed client Response reaches clean EOF, or at handler return for HEAD/bodyless Responses. auth_missing and auth_invalid come from actual denial returns after credential selection. policy covers invalid policy, model allowlist/access denials and configured native background/batch or direct-session eligibility restrictions, including malformed policy. These eligibility restrictions can reject an unspent configured cap; they do not report exhausted allowance. client_limit covers the existing per-key window/RPM/TPM, daily-token and lifetime token/cost allowance denials. A policy candidate rejected during a recovered vision reroute adds nothing. Fusion local policy markers retain the annotation when nested model/account scope denials become a final opaque 403; recovered or discarded candidates add nothing. Status 401/403/429 from an upstream response adds nothing without a local producer annotation.
The annotation is private weak metadata. Correlation rebuilds retain it without changing response headers or payloads. After early keepalive commits HTTP 200, only a selected annotated denial whose error frame was successfully enqueued can transfer that annotation to the final stream. Counting still waits for outer EOF. Reader cancellation, request abort, body transport failure and failure to read the selected denial body add no client-admission failure. An unread non-HEAD body stays pending; this counter does not prove that a client received or interpreted a denial frame.
Denial producers cover shared chat, embeddings, image generation/edit, TTS/STT, music, video, rerank, search, fetch, moderation, token-count and systemone handlers, native provider handling and Gemini native TTS auth. Public realtime credential/session HTTP routes reuse native auth and policy annotations. Files/Batches final auth denials retain their existing wire text while distinguishing missing and invalid accepted credentials internally. The legacy completions bridge retains the same weak selection through streaming and JSON conversion, including denials selected after keepalive commits HTTP 200. The Ollama-compatible chat route retains the selected reason through its existing NDJSON conversion. Daily-token denials in chat and native usage use client_limit; a discarded or post-commit allowance check cannot mark a successful response. Internal batch rows use shared handlers without an HTTP observation and add no client denials; batch HTTP operations remain separate observations. Collection Files/Batches HEAD remains an unauthenticated 200, and OPTIONS remains excluded.
Foreign-owner and missing Files/Batches resources still share opaque 404 responses; neither is inferred to be a policy denial. Filtered lists, malformed requests, pending-results 409 and batch output-row errors add no admission count. Missing producers include native resource-owner/billing/epoch denials, middleware denials, provider unavailability and quota-capacity selection. Internal realtime auth/control calls serve WebSocket setup and rechecks, rather than public HTTP sessions. WebSocket admission needs a separate protocol contract. These gaps remain issue acceptance work. Zero in the four series describes the integrated producers only; issue #1129 remains open for the remaining integrations and validation.
durindoor_provider_health_snapshot_available is 1 only while the existing health monitor's numeric projection is fresh. Then durindoor_provider_connections{state="…"} reports configured connection counts in six fixed states: healthy, degraded, down, blocked, unconfigured, and unknown. The monitor already combines probes and recent successful activity. This is cached evidence about connections, not a promise that a provider/model can serve a new request or has remaining quota. The scrape never probes or refreshes health. A fresh empty inventory reports six zero counts. Missing, expired, invalidated or unusable snapshots set availability to 0 and omit the counts. An ordinary health refresh failure retains any still-fresh prior snapshot until its expiry; a forced refresh clears it first.
Runtime pressure and stall recorder
durindoor_process_uptime_seconds and durindoor_process_resident_memory_bytes describe the serving Node process. durindoor_event_loop_delay_p99_seconds retains the existing process-lifetime p99 histogram at 20 ms resolution, including the sampling interval. It starts when the metrics route is evaluated or the explicit runtime recorder starts, whichever happens first. Scrapes never reset it. An unusable p99 reading is omitted.
The Node startup hook starts the recorder asynchronously and fails open with a fixed warning if initialization fails. durindoor_runtime_recorder_started is 0 until initialization completes. Stall counters are omitted in that state; zero would falsely imply observation since boot. Repeated bootstrap calls reuse the process-global recorder. The recorder API uses one unref'd one-second timer and counts monotonic excess drift strictly above five seconds. Once started, durindoor_runtime_recorder_start_uptime_seconds identifies its observation start; durindoor_event_loop_stalls_total and durindoor_event_loop_stall_max_seconds describe that period. The latest stall's HTTP active count, cumulative admission failure count and usable RSS appear as durindoor_event_loop_last_stall_active_requests, durindoor_event_loop_last_stall_admission_failures and durindoor_event_loop_last_stall_resident_memory_bytes. Missing RSS is omitted. These simultaneous measurements support correlation, not a claim that pressure caused a rejection.
The recorder keeps at most 16 numeric stall/admission events in memory. Once started, durindoor_runtime_sampler_reading_available is 0 until its first usable drift reading and whenever the latest reading is unusable; it becomes 1 on recovery. Stall counters cover usable observations and cannot establish absence of stalls during sampling gaps. Unusable runtime readings emit at most one fixed warning per process and retain unknown values. A late timer cannot distinguish event-loop blocking from OS suspension. The recorder adds no per-request timer and never resets or replaces the shared p99 sampler. Native process-exit validation and measured overhead remain required under #1129.
Labels, lifetime and overhead
Label values are fixed: five HTTP outcomes, 13 histogram bucket bounds including +Inf, two concurrency-admission reasons, four client-admission reasons and six health states. Every other series has zero labels. No metric or diagnostic contains request IDs, model/account/key names, credentials, session text, prompts, URLs or raw errors. Operator target labels should identify the process or instance without embedding those values.
Aggregates belong to one serving process and survive server module reloads. Process restart discards counters, active observations, health projection and sampler history; they are not durable billing or cluster totals. Scrapes and usage-history reset do not clear them. An already running recorder retains its callback across module reloads until process restart. Aggregate per-instance rates in the scraper using counter-reset handling.
HTTP observation uses one weak association per live Request, an asynchronous outer-handler context and one abort listener removed at terminal observation. It reads no payload fields and forwards chunks only on downstream demand. Each terminal updates the fixed histogram; the health export reads six cached integers. The optional runtime recorder adds one unref'd timer and a fixed-capacity event history. No new database writes or scrape-triggered provider calls are added. Runtime overhead and the complete lifecycle coverage still require authorized validation before issue #1129 can close.
Client-admission instrumentation adds four process-local counters and weak Response associations. Delayed keepalive uses one bounded selection cell per output Response. Those additions survive module reloads and reset at process restart with the other metrics. They add no timer, listener, identifier dimension or state used by admission decisions. Existing stall/admission event snapshots still report concurrency-gate rejections only; they do not include the separate client-denial counters.