Introducing a new way to review your PRs.

Read the announcement

rajnandan1 / kener

Stunning status pages, batteries included!

View on GitHub

19 documents · Updated Nov 23, 2026

docs / monitoring-history

Monitoring data and history

Monitoring history turns each monitor check into a time-stamped record that supports alert decisions, uptime measures, latency views, and public status pages. The system keeps the observed result, the status shown to users, and the source of the result together so management users and public consumers can use the same history for different purposes. See the monitoring platform overview and the related monitor execution page for the check lifecycle.

Monitoring records

The monitoring record is the shared unit of history for a monitor. It is aligned to a minute and identifies the monitor, the status, the latency, the result source, and any diagnostic message.

FieldMeaning
monitor_tagThe monitor that produced the record.
timestampThe UTC minute represented by the record.
statusThe status used by summaries and views. Common values are UP, DOWN, DEGRADED, and MAINTENANCE.
raw_statusThe status observed by the check before status damping or an event overlay changes the displayed status.
latencyThe measured response time in milliseconds. It can be absent when no useful measurement exists.
typeThe source or role of the record, such as a scheduled check, timeout, error, manual value, default value, incident, or maintenance.
error_messageOptional text that explains a failed or held result.

The monitor and minute form the record identity. A later write for the same monitor and minute updates that record instead of creating a second point. This keeps repeated jobs and manual corrections from producing duplicate history.

References: src/…/db.ts• L5-24 src/…/monitoring.ts• L42-65 migrations/20250111153517_init.ts• L4-12

Result recording flow

Monitor execution produces a result, while a separate recording stage commits that result and updates the fast path used for current status. This separation lets checks run through a queue without making every consumer read a newly completed check directly.

The flow preserves both what the check saw and what the platform decides to show:

flowchart LR
    A[Monitor check] --> B[Observed result]
    B --> C[Status decision]
    C --> D[Minute history record]
    D --> E[Latest-value cache]
    D --> F[Aggregates and alerts]
    D --> G[Management and public views]

Scheduled checks record their observed status in raw_status. A confirmation threshold can hold the displayed status on the current confirmed side until enough checks support a change. An incident or maintenance event can then overlay the displayed status for that minute. The recorded latency remains the measured check latency when an overlay supplies the status, so the history still supports diagnosis.

The configured monitor type shapes the observed result before it enters this flow. API checks can use a custom evaluation rule to return status and latency. Prometheus checks distinguish no data from an unreachable service and can map metric values to DOWN or DEGRADED. Docker checks can observe either the daemon or a named container, with container state and health determining the result.

Confirmation threshold history uses scheduled-check observations as evidence. Manual and default rows do not advance the count. Incident and maintenance rows freeze it, while NO_DATA rows remain neutral. When a change is confirmed, held rows are updated from raw_status so the historical display matches the confirmed result.

Manual and default values are also records, but their type tells readers that they are not ordinary scheduled observations. Missing rows are not the same as an explicit NO_DATA result: consumers can use the absence of a row to show a gap, while NO_DATA describes a result that was recorded but did not provide a usable status.

References: src/…/monitoring.ts• L341-439 src/…/monitorExecuteQueue.ts• L123-243 src/…/monitorResponseQueue.ts• L30-60 src/…/monitor.ts• L6-16 src/…/MonitorTypeCard.svelte• L102-124 src/…/monitor-api.svelte• L133-150 src/…/monitor-prometheus.svelte• L124-163 src/…/monitor-docker.svelte• L157-209

Historical queries

The history service supports both exact records and summaries over a time range. It serves current status, detailed logs, charts, daily status bars, and multi-monitor views without requiring each consumer to define its own counting rules.

Query needResult shapeMain consumer
Latest statusOne newest record for a monitor or a set of active monitorsCurrent status summaries and group views
Exact minuteOne record at a minute-aligned timestampData API point reads and corrections
Raw rangeOrdered records between start and end timesData API and day detail views
Paginated recordsNewest records with monitor, status, and time filtersManagement log pages
Interval summaryCounts for each status plus average, minimum, and maximum latencyStatus bars, uptime, and trend views
Recent-row summaryCounts and latency across the most recent recordsThreshold checks and uptime conditions

Range summaries group data into fixed time buckets. The system can group one monitor or several monitors, and it fills empty daily buckets when building a status bar so a missing day remains visible as a no-data day rather than shifting the calendar.

Current-status reads for active monitor groups return one newest record for each unique requested monitor. A monitor with no stored record is omitted, so consumers do not mistake an absent result for a current status.

The public v4 data API normalizes requested timestamps to minute boundaries. A range read uses a start-inclusive and end-exclusive interval. A point read returns the record for one minute. Public data responses expose the monitor tag, timestamp, status, latency, and source type; internal management logs also show error text.

References: src/…/monitoring.ts• L60-169 src/…/monitoring.ts• L180-198 src/…/monitoring.ts• L513-663 src/…/+server.ts• L16-72 src/…/+server.ts• L15-64

Uptime and latency measures

Uptime and latency are derived from stored history rather than stored as a separate final value. This lets the same records produce a monitor view, a badge, or a management report for a chosen period.

Uptime uses counts of UP, DOWN, DEGRADED, and MAINTENANCE records. Each monitor can define a numerator and denominator formula using those status counts. The result is the numerator divided by the denominator and expressed as a percentage. A formula can therefore treat maintenance or degraded service according to the monitor's policy instead of forcing one global meaning on every monitor.

Range aggregation keeps those status counts with average, minimum, and maximum latency for each time bucket. Grouped queries can return the same measures for several monitors, which allows management and public views to compare monitors without changing the meaning of a stored record.

Latency summaries use valid positive latency values. They expose average, minimum, and maximum values for the selected period. A zero or missing latency does not add useful evidence to a latency trend, so chart and day-detail views leave it out of their latency series. When no valid value exists, the view returns an empty or unavailable metric instead of implying a measured zero.

References: src/…/tool.ts• L473-535 src/…/monitoring.ts• L180-198 src/…/monitoring.ts• L513-704 src/…/get.ts• L47-108 src/…/UptimeSettingsCard.svelte• L25-86 src/…/+page.svelte• L359-376

Historical views

Public and management views use different levels of detail from the same history. Public pages favor a compact status calendar and a small set of period metrics, while management pages provide records and diagnostics for review.

The public monitor bar returns the current status, uptime, daily status counts, and average, minimum, and maximum latency for a selected day range. A single-monitor request accepts a bounded day range and a minute-aligned end point. Invalid or unsafe numeric query values fall back to safe defaults instead of being used as time or loop bounds. The public monitor page can open a day to show minute-by-minute status or a downsampled latency trend. Longer latency ranges are reduced to a bounded number of chart points so peaks and valleys remain visible without returning every stored row.

Public pages can also request monitor bars in one batch. The batch request removes duplicate tags, limits the request to 100 tags, applies the hidden-monitor access rule, and returns a separate missingTags list for tags that do not resolve to visible active monitors. It uses grouped history and latest-value reads, then builds the same per-monitor payload as a single-monitor request.

Management users can view the ten newest logs on a monitor page or search the full monitoring log. The recent-log view can refresh in place and links to the full view. The full view supports monitor, status, and time filters, pagination, and deletion of selected history. This view is the main place to inspect the source type and error message behind a status shown on a public page.

The management monitor page also brings configuration, uptime calculation, status-history window, recent logs, and data changes into one monitor view. The status-history window controls the period requested by public views for that monitor. It does not alter the stored records.

The management log page defaults to the last 24 hours and limits a search range to 30 days. It shows each record's monitor tag, local timestamp, displayed status, latency, source type, and error message. A confirmed delete applies to the selected monitor, status, and time range.

The display window is separate from data retention. A page has desktop and mobile defaults, and a monitor can override them with a whole-day value. These settings change how much history a public page requests; they do not create, delete, or change the stored records.

References: src/…/get.ts• L10-60 src/…/shared.ts• L25-129 src/…/get.ts• L17-122 src/…/get.test.ts• L31-62 src/…/post.ts• L28-98 src/…/post.ts• L98-171 src/…/+page.svelte• L60-119 src/…/+page.svelte• L193-237 src/…/+page.svelte• L351-477 src/…/MonitorRecentLogs.svelte• L35-103 src/…/StatusHistoryDaysCard.svelte• L27-85 src/…/+page.svelte• L337-415

Consumer interfaces

The history layer surfaces one current value and several historical forms to downstream consumers. Public status pages and embeds use compact monitor-bar payloads, while the v4 API provides record-level access for external tools.

ConsumerWhat it receives
Public status pageCurrent status, daily status history, uptime, and latency metrics for each visible monitor.
Public monitor groupsThe same monitor-bar payload for many visible monitors, plus tags that were not found.
Public embed and badgesA bounded period of status, uptime, or latency data suitable for a small visual result.
Management monitor pageThe latest result and a short recent-log view with type and error context.
Management monitoring-data pageA filtered and paginated record list for review and data cleanup.
v4 data APIMinute-aligned range and point reads, plus controlled manual updates for authorized consumers.
Alert and threshold logicRecent records with the status and latency needed to decide whether a state change is confirmed.

The latest-value path is optimized for current status, while historical summaries read the time range needed for the view. Single and grouped monitor-bar requests share the same payload builder, so one monitor and a batch of monitors expose the same status and metric meaning. Grouped requests also reduce repeated history work and report unresolved tags instead of silently assigning them a status.

References: src/…/+page.server.ts• L56-69 src/…/get.ts• L37-60 src/…/get.ts• L26-122 src/…/shared.ts• L70-129 src/…/monitorsController.ts• L286-324 src/…/monitorsController.ts• L468-499

Data retention

Retention controls how long detailed monitoring records remain available. A daily cleanup task reads the site retention policy and removes records older than the configured number of days when retention is enabled.

The default policy keeps 90 days of monitoring data. The cleanup uses a minimum of one day and runs at midnight UTC. Retention is a storage limit, not a promise that every public chart shows the full retained period; public views apply their own display and query limits.

On PostgreSQL, the monitoring table also receives more active vacuum and statistics upkeep after retention deletes. This reduces the build-up of deleted rows and keeps history reads responsive as the table turns over. Other supported database engines use their own row-reclaim behavior.

References: src/…/dailyCleanup.ts• L17-65 src/…/dailyCleanup.ts• L85-115 src/…/monitoring.ts• L265-269 src/…/global-constants.ts• L81-86 migrations/20260831120000_monitoring_data_autovacuum.ts• L3-21

Change checklist

When these files or sections are changed, remember to consider these:

  • When the monitoring record shape changes, update the queue payload, database types, management log fields, and public API data-transfer fields together.
  • When a monitor type adds or changes its status mapping, review raw-versus-displayed status handling, no-data and error meanings, latency production, confirmation sample rules, and interval counts.
  • When status meaning changes, review raw-versus-displayed status handling, confirmation sample rules, incident and maintenance overlays, interval counts, and current-status summaries.
  • When uptime rules change, check monitor settings, formula validation, daily views, monitor bars, badges, and alert conditions for the same status-count policy.
  • When time bounds change, preserve minute alignment and the difference between range reads that exclude the end and point reads that include one minute.
  • When monitor-bar query parsing changes, preserve the day bounds, safe-integer fallback, end-time fallback, tag de-duplication, and batch tag limit.
  • When grouped monitor-bar reads change, keep the single-monitor and batch payloads aligned, preserve hidden-monitor access rules, and return unresolved tags explicitly.
  • When history windows change, compare display settings with the separate retention policy so a page does not request data that cleanup has removed.
  • When grouped current-status reads change, preserve one newest result per unique monitor and the omission of monitors with no stored result.
  • When retention cleanup changes, review database-specific table maintenance so deletes do not cause later history reads to degrade.

Important failure modes

TriggerConsequenceGuard
A check is delayed or repeated for the same minuteA retry can replace the minute's record, rather than add a second observationKeep the monitor-and-minute identity and make writes safe to repeat.
A confirmation threshold holds a failing observationraw_status shows the failure while status still shows the confirmed sideTreat raw status as observed evidence and status as the value used for display and summaries.
An incident or maintenance overlay covers a checkThe displayed status can differ from the check result and latencyKeep the source type and preserve the measured latency and raw status.
A confirmation sample rule counts an overlay, manual value, default fill, or NO_DATA row incorrectlyA threshold can advance or reset during a period that should be frozen or neutralKeep scheduled observations as evidence, freeze on incident and maintenance rows, and exclude neutral rows.
A Prometheus query returns no data or cannot be reachedThe history can report the same broad service state for two different causes if the configured statuses do not preserve the distinctionKeep no-data and unreachable outcomes distinct in monitor configuration and history diagnostics.
A Docker daemon or container check uses an invalid or unsafe connectionThe monitor cannot produce a result or can expose host control through an unprotected Docker socketValidate the connection settings and prefer a read-only socket proxy or TLS on trusted connections.
A range has no stored row for a minute or dayA chart or calendar can show a false continuous period or shift its datesFill the requested time grid with NO_DATA or an empty bucket.
A formula has an invalid variable or denominatorUptime can fall back to the default formula or have no meaningful percentageValidate formulas and treat a zero or empty result as unavailable.
A batch monitor-bar request has duplicate, hidden, missing, or more than 100 tagsThe response can contain repeated work, expose a monitor the caller cannot see, omit the reason for an absent monitor, or fail the requestNormalize and de-duplicate tags, enforce the request limit, apply visibility checks, and return missingTags.
A monitor-bar query contains malformed or unsafe numeric textA time range or loop bound can become invalid or unexpectedly largeAccept whole safe integers only and use bounded defaults for invalid values.
A current-status group contains repeated tags or tags with no historyA consumer can receive duplicate monitor results or infer a status for a monitor with no recordDeduplicate requested tags and omit monitors with no newest row.
Retention deletes rows faster than PostgreSQL table upkeep reclaims and analyzes themHistory reads slow as dead rows and stale planner data build upApply the monitoring-table autovacuum settings and refresh its statistics.
Cleanup runs before a requested history rangeOld points no longer appear in logs, charts, or API responsesKeep display ranges within the configured retention period when full history is required.

Key files

FileWhy to read it
src/…/monitoring.tsDefines the record writes, latest-value reads, raw range reads, interval summaries, confirmation samples, and retention delete.
src/…/monitorExecuteQueue.tsShows how an executed result becomes a displayed record when defaults, confirmation, incidents, or maintenance apply.
src/…/monitorResponseQueue.tsShows the commit boundary that writes history and updates current-value and alert consumers.
src/…/tool.tsDefines how status counts become uptime and latency metrics.
src/…/get.tsDefines the single-monitor public history request and its bounded time inputs.
src/…/shared.tsBuilds the daily public history and period metric payload used by single and grouped status-page views.
src/…/get.tsDefines the grouped public history request, visibility filtering, missing-tag reporting, and batch limits.
src/…/get.test.tsProtects the grouped request's time parsing and bounded history query contract.
src/…/post.tsProvides minute-level status detail for one selected day.
src/…/post.tsProvides day latency statistics and a bounded chart series.
src/…/+server.tsDefines the public range read and authorized range update contract.
src/…/+server.tsDefines the public exact-minute read and update contract.
src/…/+page.svelteConnects monitor configuration, uptime settings, status-history windows, recent logs, and data actions in the management view.
src/…/MonitorTypeCard.svelteShows how monitor types are selected, validated, tested, and saved before checks create history.
src/…/monitor-api.svelteShows the API result inputs that affect returned status and latency.
src/…/monitor-prometheus.svelteShows the metric, no-data, and unreachable-result choices that affect history.
src/…/monitor-docker.svelteShows the Docker daemon and container health choices that affect observed status.
src/…/+page.svelteShows how management users filter, page through, inspect, and remove stored records.
src/…/MonitorRecentLogs.svelteShows the short, refreshable history view on a monitor's management page.
src/…/dailyCleanup.tsDefines the daily retention policy read and cleanup schedule.
migrations/20260831120000_monitoring_data_autovacuum.tsDefines the PostgreSQL table upkeep that supports repeated retention deletes.