Skip to content

Clumsies Observability Design ​

This design defines the metrics, logs, local diagnostics, dashboards and alerts for one Clumsies installation. It serves developers, installation operators and performance reviewers. Use the operations runbook for incident procedures and the local HTTP load report for measurement evidence.

Purpose and scope ​

Observability supports four decisions: how quickly work enters and completes, how long completion takes, which failures affect users, and where resources or execution stages begin to wait. The Google SRE signals organize this evidence as throughput, latency, errors and saturation. Overview establishes impact; detailed views identify sites or operations; correlated events and stage timings test the cause.

ScopeObserved objectsDecision supported
Central performanceCaddy, Server handlers, pool, PostgreSQL, host and containersRequest performance and dependency/resource state within the installation
OperationsCollection, logs, notifications, backups, restore, certificates and release recordsEvidence confidence and recovery readiness
Local performancemacOS requests, daemon sync, Commit installation, indexing, retrieval and modelsCompletion and stage timings on one client
Product activityRetained records, lifecycle states, conflicts and unread receiptsProduct state and changes in retained records

Throughput is completed work per unit time. Capacity is the load that sustains latency and error objectives on specified hardware, data and request mixes; evaluating capacity requires a separate load test.

Collection architecture ​

DataCollection and retentionUse
Central requests and resourcesDefault 30-second scrape; 90-day retention; rolling five-minute request chartsCompare performance and resources in the same window
Database and operational snapshotsHost collector every five minutesProduct records, active queries, task results and success times
Container logsAlloy to Loki; 14-day retentionIndividual requests and entrance/backend correlation
Local performanceObservations accumulated until process exitStarts, current concurrency and outcome-specific distributions
Retrieval RunExisting local recording and cleanup rulesRetrieval process and quality evidence

An installation SSH tunnel provides access to central services. Local summaries and Retrieval Runs remain on the client; IDs connect the evidence manually. Current correlation uses request IDs. Full distributed tracing requires a separate trace-context contract.

Prometheus labels are bounded component, operation, method, route template, result and stage values. Loki stream labels are Compose project, service and container. Request, Run and business object IDs and original paths remain log fields; versions use dedicated information metrics/logs; queries, payloads and credentials follow the existing redaction rules. See Prometheus label guidance.

Metric contracts ​

Throughput and lifecycle ​

Entrance requests, Server handlers, logical client operations, sync attempts, index builds and retrieval calls have separate counts. Correlation IDs relate these layers; requests and retries keep their own counting boundaries.

MetricDimensionsCount or snapshot boundary
caddy_http_request_duration_seconds_counthost, code; handler="subroute"Requests completed by one site-handling layer
clumsies_http_requests_totalroute, method, statusHandler returns a Response; actual codes 100–599, otherwise other
clumsies_http_business_requests_started_totalroute, methodAPI request enters middleware
clumsies_http_business_requests_terminated_totalroute, method, outcomeHandler ends as response or cancelled_or_aborted
clumsies_http_business_requests_in_flightroute, methodAPI handlers executing at scrape time
clumsies_db_pool_acquires_totaloperation, outcomereview_create/review_merge attempts; acquired, timeout, error, cancelled_or_aborted

The API request scope excludes /metrics and /api/v1/admin/health, retains unmatched requests and includes HTTP requests from background polling and retries. Response throughput counts handlers returning a Response; starts, interruptions and in-flight work are shown separately. Client logical operations use their own completion events: reading a revision and submitting an update produces two HTTP requests, counted as one update operation in the load report. Caddy entrance metrics include synthetic probes and exclude automatic HTTP-to-HTTPS redirects. Daily Server queries require the current method label. Apply rate/increase to original counter series before aggregation to preserve restart detection. Increase extrapolates over a window and may be fractional.

Database and product activity use gauges. Last-hour counts include retained rows with now()-60min ≤ created_at ≤ now(); deletion reduces the count. Open Draft net change is a six-hour fitted inventory slope, displayed as Drafts/hour.

Latency and results ​

ObjectStart and endClassification and coverage
Caddy entranceEntrance handling to completion of the site layerhost, code; overview p50/p95 and detailed p99
Server handlerMiddleware entry to returned Responseroute, method, status_class; body transfer follows this boundary
Connection acquisitionpool.acquire start to connection, error or interruptionReview creation/merge; includes waiting, validation and opening a connection; BEGIN and transaction execution are separate
Client HTTPCall start to complete response and decodingLocal observation
Client operationOperation start to its defined available resultSeparate local save, Server ACK, Ref installation and searchability
Daemon activateParameter validation to daemon returnIncludes query and history acknowledgment wait; accepted persistence may continue in the background; XPC transfer/client decoding are separate
Background workAttempt start to result; original pending time to convergenceAttempt count and backlog age are retained separately

HTTP histograms use route, method and status_class throughout. Success is 2xx/3xx; detailed error views use 4xx/5xx/other. Each distribution is accompanied by a sample count in the same scope. Rolling five-minute quantiles apply rate, aggregate by le and selected request dimensions, then histogram_quantile. Aggregate histogram buckets across instances before calculating quantiles. Server finite bounds are 5, 10, 25, 50, 100, 250, 500 milliseconds and 1, 2.5, 5, 10, 30 seconds; tails above the finite bounds remain subject to histogram estimation. See histogram semantics.

Operations use a monotonic duration clock; durable pending times use UTC. Same-event timers retain their own boundaries across machines. Cross-layer diagnosis compares records from the same request. The runbook defines the relationships between overlapping stages and different timing boundaries.

Errors and saturation ​

Preserve 5xx, dependency timeouts, transport failures and cancellation separately. Interpret 401, 403, 404, 409 and 429 against the operation contract; model preparation, intentional cancellation, expected conflicts and empty retrieval results have their own categories. An error ratio uses the same request scope and window for numerator and denominator, with the failure count alongside it.

ObjectEvidence read togetherScope
Server poolused, idle, open, max; acquire duration, result and concurrencyPool gauges are concurrent snapshots; acquire covers review creation and merge
PostgreSQLpg_up, connection count/limit, active queries, locks and transactionsHost SQL excludes the collector and idle transactions
CPUHost percentage and container cores0.5 CPU seconds/second means 0.5 core
MemoryAvailable memory, working set, configured limits, OOM and swapThe 2 GiB reminder is an absolute working-set threshold
DiskRoot and persistent-data mount space, I/OInspect storage capacity and I/O latency separately
Local models/indexExecution, waits, workers and unresolved workLocal stage evidence

Local diagnostics ​

Health.performance aggregates fixed operation names into started, in_flight and per-result count, total_us and cumulative buckets. bucket_upper_bounds_ms defines finite bounds; count is the +Inf bucket. process_id, collection_started_at, snapshot_at and monotonic collection_elapsed_ms identify the process and collection interval. Process restart resets the counters.

For an interval, take two snapshots with the same process_id and collection_started_at. Subtract counts, duration sums and cumulative buckets, using the collection_elapsed_ms difference for rates; read in_flight from the current snapshot. Restart the sampling interval after a restart or counter regression. Local diagnostics export performance.json when available and record unavailability otherwise; the file remains on the client.

WorkLocal evidence
Sync cycleconverged, partial, failed, skipped; sync-lock wait and execution separately
DraftAttempts, Server ACK and local synced commit; oldest_pending_operation_at covers accessible queued/syncing/retrying work, oldest_failed_operation_at covers failed work; both use original enqueue time
CommitProject-scoped commit_sync.last_checked_success_at advances on trusted checks, including no change; Ref installation is separate. Unscoped status and Draft checked fields are None
IndexBuild, publication, superseded and maintenance; pending_since survives target changes/retries and clears on convergence; published_at advances after atomic publication
RetrievalActivate return time, Run, lock wait, model gate, blocking queue, execution and history persistence; Run.total_us runs from the post-validation start to query completion, with history measured separately

Retrieval establishes a shared 60-second deadline after parameter validation; query and normal history acknowledgment wait use the remaining budget. A background writer owns accepted recording work and holds the history lock from acquisition through actual completion. When acknowledgment waiting expires, the call can return while persistence continues; the Run may remain running until commit. Persistence failures are recorded separately, so the technical response and historical terminal state are checked independently. history_lock_wait and history_persistence observe actual background stages; activate observes call return. Initial Run creation, timeout terminalization and failure recording retain their own waits; use activate snapshots for complete daemon time.

Index pending_since marks the first unresolved target after convergence, survives retries/target changes and clears when the current target converges. New backlog retains earlier published_at. Model-gate waits, blocking queue and actual execution have separate boundaries; a cancelled caller may leave blocking work executing, with resource ownership retained through its completion. See local runtime and retrieval/evaluation for local data contracts.

Evidence confidence ​

StateEvaluation and display
ActiveReachable source, valid fields/time; show throughput, distributions and samples
IdleTrusted source without events; zero throughput and no latency samples
FailedScrape, SQL or task failure; retain attempt result and last successful record
MissingExpected target or required field absent; unknown
StaleHost/database age exceeds 900 seconds; current snapshot/task interpretation is unknown
Invalid timePast-event time is later than the observer clock; show -2 and retain raw time
Unexecuted/uncoveredA stage has no observation; show the corresponding state
Unknown ageDurable work lacks a trustworthy start; retain unknown

clumsies_observability_expected_target is derived from discovery catalogs. target_health reports 1/up, 0/failed scrape, -1/missing for each expected job/instance. A usable database snapshot requires SQL success=1 and both host/database ages within 0 ≤ age ≤ 900 seconds. Snapshot status is -1/stale or missing, 0/failed, 1/valid and -2/invalid future time. Currentness requires nonnegative age.

SQL failure removes database samples. Actual textfile collection time determines freshness. Backup, restore and release success times remain neutral historical facts, separate from current confidence. A new trusted success can repair a future cache; a still-future receipt/archive remains invalid. Task states are success, failed, never, missing and running. A known startup failure may lack an exit time; a present future exit is invalid. Certificate expiry is a future deadline and uses remaining validity.

Dashboards and navigation ​

Four dashboards provide impact, entrance, API and operational views. English and Chinese use the same queries. See Grafana dashboard practices.

DashboardContentNavigation
OverviewAlerts/confidence; API request throughput, samples, success latency; 5xx, API request concurrency/pool; four-site entrance signalsSite to entrance, requests to API, collection/resources to Infrastructure
Entrance and WebsitesSite filter, requests/s, response codes, latency/samples, slow requests and access logsRequest correlation to API A7
Business APIRoute/method, throughput/classified latency, busy/slow routes, lifecycle and correlation; collapsed product activityApp entrance to W5; dependencies to Infrastructure
Infrastructure and OperationsExpected targets, snapshots, database, resources, backup/restore, certificates, logs, notifications, Server version and releasePrometheus, Alertmanager and the runbook

Cross-page links preserve time and applicable site, route, method and request_id. API A7 is the shared Caddy/Server correlation view and the only manual request-ID input, matching the complete ID across both layers. Dashboard navigation changes views; panels present measurements.

Summary cards show a single metric, with the object in the title and the result in the body. Scraping status, snapshot status, collection age, success time and record validity use separate cards; comparable percentiles, sites and routes share time-series charts. Times and elapsed durations retain their respective units. API requests/s, log entries/s, acquisitions/s, CPU cores and days identify their actual counting object or unit.

Local server_request_id directly identifies entrance/Server records. client_request_id identifies Server records first; their internal request_id locates the entrance. One client identity can span attempts. retrieval_run_started links request_id to run_id. Eight product gauges remain in the collapsed API section with snapshot state/age.

Service objectives and alerts ​

The installation retains its deployment objectives. Collection correctness, operations and objective compliance have separate acceptance criteria.

ObjectiveTargetMeasurement requirements
Public availability99.5% over 30 daysApp HTTP 200 and JSON status=ok; HTTPS module for static sites; report probe coverage/missing events
Write freshness99% of eligible changes reach Server within 5 minutesFirst durable enqueue through verified corresponding persistent Server ACK; full SLI remains to implement
DurabilityRPO ≤ 26 hours; RTO ≤ 1 hourRestorable copy/backup age; independent elapsed time from recovery start to available service
App entrance latencyp95 < 1 secondCaddy App entrance; request scope/objective window remain to define
Server errors< 1%Per-site 5xx in the same entrance request population; API route/method localizes causes

The write SLI assigns events to the first-enqueue window. Eligible logical operations reaching the 300-second decision point form the denominator; verified ACKs within 300 seconds form the numerator. Unexpired pending work and window lag are reported separately. Retries retain the same operation, and late success retains its original decision. Eligibility defines merged, cancelled and local-only work in advance. Client reception is a verifiable upper bound on confirmation time.

Alerts cover actionable faults, capacity risks and collection-chain failures. At low traffic, read counts, ratios and operation impact together. Product inventories describe work state.

Rule groupCondition and durationInvestigation
AvailabilityProbe failure for 2 minutes; scrape failure/missing target for 5 minutes; certificate below 14 days for 1 hourSite, target, certificate
Entrance errorsPer-site rolling five-minute 5xx >1% for 5 minutesEntrance logs/API
CapacityFilesystem available <15%, host available memory <10%, PostgreSQL connections >80%, each for 10 minutesResources/database
Fixed memory reminderContainer working set >2 GiB for 10 minutesContainer trend/actual limit
Databasepg_up=0 for 2 minutes; active query >60 seconds in valid snapshots for 5 minutesDatabase, locks/transactions
CollectionMissing/failed/stale/invalid host/database snapshot for 5 minutesService/timer, textfile, SQL
Time validityOperationalTimestampInvalid: reachable node with a host/DB/backup/restore/release/unit-exit timestamp >Prometheus time for 5 minutes, warningClock/original record
Logs/notificationSend retries for 5 minutes; drops or notification failure within 5 minutesAlloy/Loki/Alertmanager
Backup/restoreBackup missing/invalid/older than 26 hours for 30 minutes; drill missing/invalid/older than 8 days for 1 hour; failed/unavailable task for 5 minutesService/timer, result, success record

Normal email waits 30 seconds initially, groups changes every 5 minutes, repeats persistent faults every 4 hours and sends recovery. Warning/critical share a receiver. Watchdog remains firing, waits 10 seconds initially and repeats every 24 hours; an actual inbox receipt verifies delivery. Notifications identify the affected object, window, result/sample, detail link and first action.

Acceptance and remaining measurement work ​

ScopeAcceptance
Views/navigationEight equivalent EN/ZH dashboards, mapped original metrics, preserved time/filters
HTTP classesMethod isolation, separate outcome distributions/samples, 504/599 classified 5xx
LifecycleMatching started/response/cancelled/in-flight scopes; balanced cancellation
AcquisitionIsolated review-create/merge scope with acquisition, timeout, failure, interruption and concurrency
ConfidenceStopped timer, SQL failure, missing target, future time and cache recovery visible
OperationsDistinct never/failed/missing/running; latest failure coexists with last success
Request evidenceEntrance/handler/body boundaries, exact IDs and effective redaction
Local diagnosticsProcess intervals, sync ACK/local commit, index publication, activate return/background persistence and stage execution states

Configuration/behavior checks use deploy/observability/test.py, test-delivery.py, Server metrics/telemetry and local behavior tests. Failure injection/load tests run in isolation; production acceptance uses real traffic and readiness checks. Field or completion changes update queries, rules and fixtures together.

Remaining work includes write eligibility, durable first-ACK deduplication and expired unfinished denominators; latency/error objective windows and populations; operation response budgets; independent RTO timing; external host-loss observation and alert ownership/channels. Same-host monitoring covers installation components/probes; host loss and failure of the notification channel require an external observer.

Statistical interpretation pairs low-sample p99 with its count; idle windows have no latency. Entrance, handler, client and overlapping stages retain separate timing boundaries. Five-minute SQL snapshots describe the sampled state; product row counts describe retained activity. Retrieval quality uses human evaluation, while capacity reports include hardware, data, request mix and duration.

Appendix A: Historical data and upgrades ​

Daily dashboards use the current route/method/status_class HTTP schema. Historical route-only histograms contain mixed results and remain in Prometheus for queries under their original labels. Historical global in-flight includes health/metrics; current API request views use in-flight with operational routes excluded. Allow a complete five-minute window after upgrade before reading classified latency.

An older daemon without performance or a durable backlog start returns unavailable/unknown age. Client decoding remains compatible. Existing delivery/rollback manages upgrades, preserving success records and historical observations under their original contracts. Five-minute release snapshots identify the latest recorded success; historical revision mapping uses release records.

Appendix B: Original 40-panel destinations ​

O is original Overview, A Business API, W Website Traffic, I Infrastructure and P the collapsed API product section. Existing three UIDs remain; update bookmarks after cross-dashboard moves. Dashboard navigation replaces help-only panels.

SourceOriginal panelCurrent destination
O1Site availabilityO1, per site
O2Entrance requests/sO2 → W
O3Site 5xxO3, matching samples
O4Entrance p95O4 → W
O5Backup ageI16, success age; I29, success time
O6Certificate daysI19, per certificate
O7Root free spaceI14, persistent mounts
O8Host CPUI10, percentage
O9Host memoryI11, availability/pressure
O10Container CPUI12, cores
O11Container memoryI13, working set/limits
O12PostgreSQL connectionsI5, count/limit
O13Longest queryI9, valid snapshot
O14Scrape targetsI1, expected status; Overview summary
O15Log retries/dropsI20
O16Loki entries/sI21, source/transport state
A1Handler latencyA1, success classes; separate errors
A2Observed requestsA2, total/classified samples
A3Requests/s by statusA3
A4Requests >1sA4, investigation filter
A5Slow backendA5, route/method/ID
A6Slow App entranceAPI App entrance navigation → W5
A7Correlated requestA7, shared correlation
A8Server poolI4, scoped acquire timing
A9Busy routesA9, route/method details
A10Last-hour CommitsP / A10, retained-row gauge
A11Last-hour DraftsP / A11
A12Last-hour ReviewsP / A12
A13Draft lifecycleP / A13
A14Open Draft net changeP / A14, six-hour fit
A15Valid conflicting DraftsP / A15, candidate validity
A16Stored unread receiptsP / A16, including archived/inaccessible
A17Oldest open Draft creation ageP / A17, zero without open Drafts
W1Entrance latencyW1, p50/p95/p99 and count
W2Observed requestsW2, window extrapolation
W3Requests/s by statusW3
W4Requests >1sW4
W5Slow site requestsW5, path/bytes/upstream timing
W6Access logsW6
W7Correlated requestWebsite Request correlation navigation → A7