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.
| Field | Meaning |
|---|---|
monitor_tag | The monitor that produced the record. |
timestamp | The UTC minute represented by the record. |
status | The status used by summaries and views. Common values are UP, DOWN, DEGRADED, and MAINTENANCE. |
raw_status | The status observed by the check before status damping or an event overlay changes the displayed status. |
latency | The measured response time in milliseconds. It can be absent when no useful measurement exists. |
type | The source or role of the record, such as a scheduled check, timeout, error, manual value, default value, incident, or maintenance. |
error_message | Optional 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 need | Result shape | Main consumer |
|---|---|---|
| Latest status | One newest record for a monitor or a set of active monitors | Current status summaries and group views |
| Exact minute | One record at a minute-aligned timestamp | Data API point reads and corrections |
| Raw range | Ordered records between start and end times | Data API and day detail views |
| Paginated records | Newest records with monitor, status, and time filters | Management log pages |
| Interval summary | Counts for each status plus average, minimum, and maximum latency | Status bars, uptime, and trend views |
| Recent-row summary | Counts and latency across the most recent records | Threshold 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.
| Consumer | What it receives |
|---|---|
| Public status page | Current status, daily status history, uptime, and latency metrics for each visible monitor. |
| Public monitor groups | The same monitor-bar payload for many visible monitors, plus tags that were not found. |
| Public embed and badges | A bounded period of status, uptime, or latency data suitable for a small visual result. |
| Management monitor page | The latest result and a short recent-log view with type and error context. |
| Management monitoring-data page | A filtered and paginated record list for review and data cleanup. |
| v4 data API | Minute-aligned range and point reads, plus controlled manual updates for authorized consumers. |
| Alert and threshold logic | Recent 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
| Trigger | Consequence | Guard |
|---|---|---|
| A check is delayed or repeated for the same minute | A retry can replace the minute's record, rather than add a second observation | Keep the monitor-and-minute identity and make writes safe to repeat. |
| A confirmation threshold holds a failing observation | raw_status shows the failure while status still shows the confirmed side | Treat raw status as observed evidence and status as the value used for display and summaries. |
| An incident or maintenance overlay covers a check | The displayed status can differ from the check result and latency | Keep 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 incorrectly | A threshold can advance or reset during a period that should be frozen or neutral | Keep scheduled observations as evidence, freeze on incident and maintenance rows, and exclude neutral rows. |
| A Prometheus query returns no data or cannot be reached | The history can report the same broad service state for two different causes if the configured statuses do not preserve the distinction | Keep no-data and unreachable outcomes distinct in monitor configuration and history diagnostics. |
| A Docker daemon or container check uses an invalid or unsafe connection | The monitor cannot produce a result or can expose host control through an unprotected Docker socket | Validate 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 day | A chart or calendar can show a false continuous period or shift its dates | Fill the requested time grid with NO_DATA or an empty bucket. |
| A formula has an invalid variable or denominator | Uptime can fall back to the default formula or have no meaningful percentage | Validate formulas and treat a zero or empty result as unavailable. |
| A batch monitor-bar request has duplicate, hidden, missing, or more than 100 tags | The response can contain repeated work, expose a monitor the caller cannot see, omit the reason for an absent monitor, or fail the request | Normalize and de-duplicate tags, enforce the request limit, apply visibility checks, and return missingTags. |
| A monitor-bar query contains malformed or unsafe numeric text | A time range or loop bound can become invalid or unexpectedly large | Accept whole safe integers only and use bounded defaults for invalid values. |
| A current-status group contains repeated tags or tags with no history | A consumer can receive duplicate monitor results or infer a status for a monitor with no record | Deduplicate requested tags and omit monitors with no newest row. |
| Retention deletes rows faster than PostgreSQL table upkeep reclaims and analyzes them | History reads slow as dead rows and stale planner data build up | Apply the monitoring-table autovacuum settings and refresh its statistics. |
| Cleanup runs before a requested history range | Old points no longer appear in logs, charts, or API responses | Keep display ranges within the configured retention period when full history is required. |
Key files
| File | Why to read it |
|---|---|
| src/…/monitoring.ts | Defines the record writes, latest-value reads, raw range reads, interval summaries, confirmation samples, and retention delete. |
| src/…/monitorExecuteQueue.ts | Shows how an executed result becomes a displayed record when defaults, confirmation, incidents, or maintenance apply. |
| src/…/monitorResponseQueue.ts | Shows the commit boundary that writes history and updates current-value and alert consumers. |
| src/…/tool.ts | Defines how status counts become uptime and latency metrics. |
| src/…/get.ts | Defines the single-monitor public history request and its bounded time inputs. |
| src/…/shared.ts | Builds the daily public history and period metric payload used by single and grouped status-page views. |
| src/…/get.ts | Defines the grouped public history request, visibility filtering, missing-tag reporting, and batch limits. |
| src/…/get.test.ts | Protects the grouped request's time parsing and bounded history query contract. |
| src/…/post.ts | Provides minute-level status detail for one selected day. |
| src/…/post.ts | Provides day latency statistics and a bounded chart series. |
| src/…/+server.ts | Defines the public range read and authorized range update contract. |
| src/…/+server.ts | Defines the public exact-minute read and update contract. |
| src/…/+page.svelte | Connects monitor configuration, uptime settings, status-history windows, recent logs, and data actions in the management view. |
| src/…/MonitorTypeCard.svelte | Shows how monitor types are selected, validated, tested, and saved before checks create history. |
| src/…/monitor-api.svelte | Shows the API result inputs that affect returned status and latency. |
| src/…/monitor-prometheus.svelte | Shows the metric, no-data, and unreachable-result choices that affect history. |
| src/…/monitor-docker.svelte | Shows the Docker daemon and container health choices that affect observed status. |
| src/…/+page.svelte | Shows how management users filter, page through, inspect, and remove stored records. |
| src/…/MonitorRecentLogs.svelte | Shows the short, refreshable history view on a monitor's management page. |
| src/…/dailyCleanup.ts | Defines the daily retention policy read and cleanup schedule. |
| migrations/20260831120000_monitoring_data_autovacuum.ts | Defines the PostgreSQL table upkeep that supports repeated retention deletes. |