Monitoring platform
Kener turns monitor configurations into current service status and time-based health views. A monitor defines what to check and when to check it. The platform runs that check, records the result, and gives management and public status views a shared source of truth.
Domain model
A monitor is the named unit of service health. Its tag identifies it across schedules, stored samples, status pages, group members, and related operational events. Its type and type data define the target check, while its active state and visibility control whether it runs and where people can see it. src/…/db.ts• L65-102
The domain supports both direct checks and derived status. Direct monitors test an external target, query a metric system, inspect a container or daemon service, or receive a heartbeat. Group monitors combine the latest results of other monitors. A no-op monitor represents a status that an operator or another system supplies instead of a target check. The type list is shared by configuration and dispatch so the platform has one view of supported monitor kinds. Prometheus monitors use an instant PromQL query with optional rules for DOWN and DEGRADED results. They keep an empty query result distinct from an unreachable, invalid, or malformed Prometheus response. src/…/monitor.ts• L3-21 src/…/monitor.ts• L99-132 src/…/MonitorTypeCard.svelte• L120-134 src/…/monitor-prometheus.svelte• L14-25
The monitor write contract uses the same supported type list as the runtime. This keeps a monitor type that the management API accepts aligned with a type that the platform can schedule and execute. src/…/requestBody.test.ts• L66-70
Monitoring lifecycle
The lifecycle moves one configured monitor through scheduling, execution, storage, and presentation. Each scheduled run uses the start of a UTC minute as its sample time, which lets current status and history use the same time boundary. src/…/cron-minute.ts• L15-27
The following flow shows the boundary between the workers that produce a result, the data layer that keeps it, and the consumers that present it.
flowchart LR
A[Configured monitor] --> B[Monitor schedule]
B --> C[Execution job]
C --> D[Observed result]
D --> E[Status rules and event overlays]
E --> F[Response job]
F --> G[Monitoring history]
G --> H[Current-status cache]
G --> I[Alert evaluation]
G --> J[Public and management views]
H --> J
The schedule starts work only for monitors that have a usable schedule. The execution boundary maps the configured monitor type to one service check. It then adds status rules such as default status, confirmation, incidents, and maintenance. The response worker persists the final sample, refreshes the fast current-status value, and starts alert evaluation. A malformed API or Prometheus configuration becomes an error result rather than leaving a missing time slot. src/…/monitorSchedulers.ts• L19-70 src/…/service.ts• L30-85 src/…/monitorExecuteQueue.ts• L123-243 src/…/monitorResponseQueue.ts• L30-60 src/…/apiCall.ts• L26-35 src/…/prometheusCall.ts• L63-71
Execution boundary
Execution owns contact with the target and the decision about the result for one sample. It does not own public page layout or long-term history views. The execution details for API, TCP, SSL, SQL, ping, DNS, gRPC, heartbeat, group, game, Prometheus, no-op, and Docker monitors are in Monitor execution and service checks.
The execution result carries the status, latency, result type, and optional error detail. It can also carry the raw observed status when confirmation is enabled. This separates what the check saw from what Kener commits as the status shown to downstream systems. Each configured type must have both a shared data shape and a service selection path. API, ping, TCP, and game checks can apply a monitor-defined evaluation to target data. A missing, failed, or invalid evaluation returns an error result instead of escaping the execution boundary. src/…/monitor.ts• L6-16 src/…/monitor.ts• L104-151 src/…/service.ts• L30-85 src/…/monitorExecuteQueue.ts• L135-164 src/…/apiCall.ts• L26-35 src/…/apiCall.ts• L130-162 src/…/pingCall.ts• L14-55 src/…/tcpCall.ts• L14-63 src/…/gamedigCall.ts• L15-62 src/…/prometheusCall.ts• L107-148
Monitor evaluations run in a restricted evaluation boundary. They receive the observation from the check and return a permitted status with optional latency. The boundary runs each evaluation in a short-lived, isolated process with limits on host access, memory, run time, concurrent work, result size, and error size. It provides only the small set of guest features that monitor rules need. Invalid or unsafe evaluation becomes an error result. This lets monitor-specific rules change the meaning of an observation without giving monitor code access to server resources. src/…/evalSandbox.ts• L6-11 src/…/evalSandbox.ts• L136-177 src/…/evalSandbox.ts• L180-221 src/…/evalSandbox.test.ts• L230-328
The evaluation contract accepts UP, DOWN, DEGRADED, or MAINTENANCE, with an optional numeric latency. It rejects missing or invalid status values and removes unrelated result fields. The sandbox also supports the shared HTML parsing and base64 features used by monitor rules while keeping each evaluation's global state separate. src/…/evalSandbox.ts• L85-96 src/…/evalSandbox.ts• L184-211 src/…/evalSandbox.test.ts• L73-189
Incidents and maintenance are status overlays. They can replace the displayed status for the sample, while the underlying check latency and raw status remain available. An overlay also freezes confirmation counting for its time boundary, so an operational event does not create a false status change. src/…/monitorExecuteQueue.ts• L129-147 src/…/monitorExecuteQueue.ts• L199-237
Persistence boundary
Persistence owns the durable sample record and the queries that turn samples into current status, uptime, latency, and history. A sample is keyed by monitor tag and timestamp. Repeating the same write updates that time slot instead of creating a second sample. src/…/db.ts• L5-24 src/…/monitoring.ts• L41-58
The persistence layer stores both the committed status and the optional raw_status. It also stores latency, result type, and error detail. This allows later confirmation, alert checks, diagnosis, and history views to use the same record without asking the execution worker to run again. src/…/monitoring.ts• L42-57
History readers serve different time scales. They can read the latest sample, a time range, paginated raw records, or interval counts with average, minimum, and maximum latency. Retention removes samples older than the configured period. The storage model and history views are described in Monitoring data and history. src/…/monitoring.ts• L60-109 src/…/monitoring.ts• L181-199 src/…/monitoring.ts• L266-270
Presentation boundary
Presentation reads monitor metadata and stored monitoring data. It does not perform the health check. Management users can configure the monitor, active state, visibility, type-specific settings, uptime rules, history range, and page membership. The type editor validates the selected settings before it sends them to the management API. It can also run an on-demand test so an operator can inspect a status and latency before relying on the schedule. src/…/+page.svelte• L26-35 src/…/+page.svelte• L89-159 src/…/MonitorTypeCard.svelte• L134-151 src/…/MonitorTypeCard.svelte• L301-351
The management API checks the request shape against the published API contract before it reaches the domain rules. It rejects invalid JSON and invalid types, required fields, enum values, nested items, and supported monitor variants. Value rules such as patterns and numeric limits remain with the handlers so masked secrets can be sent back unchanged. src/…/requestBody.ts• L37-83
The monitor editor presents type-specific settings through one shared configuration boundary. A Docker monitor can check a Docker daemon or a named container through a Unix socket, plain TCP, or TLS. The editor can browse containers before saving by using the current connection fields, while the scheduled check later uses the saved monitor data. src/…/MonitorTypeCard.svelte• L355-411 src/…/monitor-docker.svelte• L24-90 src/…/monitor-docker.svelte• L164-216
Docker connection defaults help new monitors match the process environment without changing saved monitors. The management page exposes only the Docker defaults needed by the form, and the form clears TLS material when an operator leaves TLS mode. This keeps connection setup separate from the monitor result while reducing the risk of stale or secret-bearing fields being saved. src/…/+page.server.ts• L1-4 src/…/docker.ts• L114-139 src/…/monitor-docker.svelte• L35-45 src/…/monitor-docker.svelte• L58-69
Type settings express the evidence that each monitor can use for its result. Prometheus settings include the query endpoint, PromQL expression, optional DOWN and DEGRADED rules, separate no-data and request-error outcomes, request headers, timeout, and certificate policy. SSL settings include the target, certificate trust policy, expiry thresholds, and optional server name. API settings include the request target and method, request data, timeout, redirects, and result evaluation. src/…/monitor-prometheus.svelte• L17-25 src/…/monitor-prometheus.svelte• L62-177 src/…/monitor-ssl.svelte• L10-17 src/…/monitor-ssl.svelte• L32-100 src/…/monitor-api.svelte• L19-29
The editor warns when secret references could travel through an API or Prometheus request over plain HTTP. This warning covers credential-bearing request fields and proxy URLs. It does not change the stored observation; it helps an operator avoid exposing a secret before the monitor runs. src/…/monitor-api.svelte• L41-48 src/…/monitor-prometheus.svelte• L41-47 src/…/secrets-over-http.svelte.test.ts• L12-30
API and Prometheus monitors can use a monitor-specific proxy. If no monitor proxy is set, their network agents use the process proxy environment. Docker monitors use the process proxy environment only. Secret references resolve at the server-side execution boundary, so the browser does not need the resolved proxy or Docker credentials. src/…/proxy.ts• L45-69 src/…/apiCall.ts• L51-85 src/…/prometheusCall.ts• L75-105 src/…/docker.ts• L78-111
Public views expose only active monitors that are not hidden. A public monitor page combines the latest stored status with monitor details and a history response. A public status page instead gathers the latest samples for its selected monitors and derives one page-level summary. src/…/+page.server.ts• L18-36 src/…/dashboardController.ts• L301-391
The monitor history view requests a selected day range and receives uptime, status counts, and latency values. It fills missing days for a stable calendar shape, then renders a status bar and latency trend. This keeps time-range calculation on the server and display choices in the client. src/…/get.ts• L17-53 src/…/shared.ts• L23-101 src/…/MonitorOverview.svelte• L89-116
Status model
The status value describes the health outcome that users and downstream rules consume. The result type and raw status provide context about how that outcome was produced. src/…/monitor.ts• L3-5 src/…/monitor.ts• L6-16
| Status | Meaning in the platform |
|---|---|
UP | The monitor meets its healthy rule. |
DEGRADED | The target responds but falls outside the healthy range or has partial health. |
DOWN | The check fails or the target does not meet its required rule. |
MAINTENANCE | A maintenance event supplies the visible status. |
NO_DATA | Kener has no usable status for the monitor or run. |
Confirmation treats UP as the healthy side and DOWN plus DEGRADED as the unhealthy side. A new opposite observation can remain held until enough scheduled checks confirm it. NO_DATA stays neutral. This rule changes the visible status without discarding the observed evidence. src/…/confirmationThreshold.ts• L4-10 src/…/confirmationThreshold.ts• L65-106
Custom monitor evaluations can return UP, DOWN, DEGRADED, or MAINTENANCE. They cannot create NO_DATA; that value remains a platform-level outcome for a missing or unusable observation. src/…/evalSandbox.ts• L10 src/…/evalSandbox.ts• L142-160
Related pages
Use Monitor execution and service checks for target-specific checks, result evaluation, confirmation, and overlays. Use Monitoring data and history for stored samples, aggregation, retention, and history consumers.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the supported monitor type list aligned with the execution dispatcher and each type's configuration shape.
- Keep the published request schema aligned with the monitor type list and the management handlers' value checks.
- Preserve the monitor tag and UTC minute timestamp contract across scheduling, execution jobs, response jobs, and stored samples.
- Keep
status,raw_status, latency, result type, and error detail together when changing the execution-to-storage handoff. - If a new sample type is added, decide whether it participates in current status, confirmation counting, alert evaluation, and history totals.
- Treat incident and maintenance overlays as a boundary for both displayed status and confirmation state.
- Keep active and hidden filtering aligned between management selection, public monitor routes, and status page summaries.
- When changing uptime formulas or history range settings, keep the server response shape aligned with the calendar and latency views.
- Keep Prometheus no-data and request-error outcomes separate when changing query result handling or monitor type settings. A successful empty result and a failed or malformed response have different meanings.
- Keep each type editor's settings and validation aligned with the execution contract, including Docker connection and check settings.
- Preserve an SSL
DOWNthreshold of0as an explicit value. Do not treat it as an unset value when loading or saving a monitor. - Keep Docker environment defaults limited to new-monitor initialization. Do not let them overwrite a saved connection.
- Keep Docker TLS certificates and keys as a matched pair, and clear TLS fields when a monitor changes to a non-TLS connection.
- Keep secret-bearing API, Prometheus, and Docker fields covered by the relevant transport-safety boundary when request or connection settings change.
- Keep secret references resolved only at the server-side execution boundary. Do not send Docker credentials or private keys to the browser as environment data.
- Keep monitor-specific proxy selection separate from process proxy selection for API and Prometheus checks. Do not add a per-monitor proxy path to Docker without defining its security boundary.
- Keep the custom evaluation contract aligned across API, ping, TCP, and game checks. Preserve the allowed status values and the rule that invalid evaluation returns an error result.
- Keep evaluation isolation and resource limits in place when changing monitor-defined rules. Do not give evaluation code a path to host resources or allow it to block a monitoring worker.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A monitor is inactive or has no usable schedule | No recurring execution job produces new observations. | Check the monitor active state and cron configuration before diagnosing missing history. |
| A management request has invalid JSON or does not match the request schema | The monitor change is rejected before domain validation and no configuration update occurs. | Keep the published schema aligned with the request handler and return the field-specific BAD_REQUEST response. |
| The execution-to-response handoff fails | The sample is not durable, and current status and alert evaluation do not advance. | Monitor response queue and database write failures. |
| A monitor is hidden or absent from a page | Its status is not shown in the related public status view, even if samples exist. | Check both monitor visibility and page membership. |
| A check returns an opposite status below its confirmation threshold | The public status stays on the prior side while raw evidence records the change. | Inspect raw_status and the held-status detail before treating it as stale data. |
| An incident or maintenance overlaps a check | The overlay becomes the visible sample status and confirmation counting pauses at that boundary. | Review the sample type and the underlying raw status together. |
| A Prometheus query returns no data or cannot be reached | The monitor records the configured no-data or request-error outcome. Treating both cases as the same can hide a lost Prometheus service or an empty metric result. | Check the Prometheus result condition and the two separate status settings. |
| A malformed API or Prometheus monitor is allowed to throw before returning a result | The scheduled run can leave a gap in the timeline instead of recording an error sample. | Keep constructors defensive and map malformed configuration to an error result. |
| A monitor has no usable samples | Current status and history views show NO_DATA or empty time points instead of claiming service health. | Produce a valid check or heartbeat before relying on uptime values. |
An SSL DOWN threshold of 0 is treated as missing | The saved certificate policy can change when the editor reopens. | Preserve zero as a valid threshold and keep it distinct from an absent value. |
| A Docker socket is missing or not accessible | Docker checks fail before they can report daemon or container health. | Verify the socket mount and process permissions, or use a reachable TCP or TLS daemon. |
| Docker client certificate and key are not both supplied | A TLS connection fails during setup instead of producing a container or daemon result. | Keep the client certificate and key together, or use a TLS proxy that does not require them. |
| A Docker monitor uses plain TCP outside a trusted network | Docker control access can be exposed without transport encryption. | Prefer a Unix socket or TLS, and keep plain TCP inside a trusted network. |
| A secret reference is sent through a plain-HTTP target or proxy | The secret can travel without transport encryption. | Use HTTPS or a trusted private network after reviewing the editor warning. |
| A monitor-specific API or Prometheus proxy is invalid or unreachable | The check records a transport error rather than the target's health. | Verify the proxy URL and keep proxy secrets resolved only on the server. |
| A monitor evaluation is invalid, reaches host resources, or does not finish | The check records an error result instead of the configured rule's status. An unsafe or unbounded evaluation must not affect the monitoring worker. | Keep evaluation code inside the restricted boundary and preserve its time, memory, result, and status limits. |
Key files
| File | Why to read it |
|---|---|
| src/…/monitor.ts | Defines shared monitor types and public status values. |
| src/…/db.ts | Defines configured monitor, monitoring sample, and history summary shapes. |
| src/…/monitorSchedulers.ts | Shows how recurring monitor work is scheduled. |
| src/…/monitorExecuteQueue.ts | Shows the boundary from observed check to final result. |
| src/…/service.ts | Shows how a monitor type selects its execution service. |
| src/…/apiCall.ts | Shows how API checks turn target responses and transport errors into monitor results. |
| src/…/evalSandbox.ts | Shows the boundary for monitor-defined result evaluation and its safety limits. |
| src/…/evalSandbox.test.ts | Shows the supported evaluation features and limits. |
| src/…/monitorEval.test.ts | Shows the shared evaluation contract across API, ping, TCP, and game monitors. |
| src/…/prometheusCall.ts | Shows how Prometheus results, no-data, and request errors become monitor results. |
| src/…/proxy.ts | Shows the boundary between monitor-specific and process proxy settings. |
| src/…/monitorResponseQueue.ts | Shows the handoff from final result to storage, cache, and alerts. |
| src/…/monitors.ts | Shows the monitor configuration read and write boundary. |
| src/…/monitoring.ts | Shows durable monitoring samples and history queries. |
| src/…/monitorsController.ts | Shows the domain operations that connect configuration, samples, and derived views. |
| src/…/dashboardController.ts | Shows how stored monitor results become status page summaries. |
| src/…/shared.ts | Shows how stored samples become uptime and latency history data. |
| src/…/+page.server.ts | Shows the public monitor data boundary and visibility rules. |
| src/…/MonitorOverview.svelte | Shows how history data becomes the public status and latency view. |
| src/…/requestBody.ts | Defines the request-shape boundary for management API writes. |
| src/…/requestBody.test.ts | Protects request validation and alignment between the API schema and supported monitor types. |
| src/…/+page.server.ts | Supplies safe Docker defaults to the monitor editor. |
| src/…/+page.svelte | Coordinates monitor loading, page visibility, configuration, and operational settings. |
| src/…/MonitorTypeCard.svelte | Shows how management selects, validates, tests, and saves a monitor type. |
| src/…/monitor-docker.svelte | Shows the management model for Docker daemon and container checks. |
| src/…/docker.ts | Shows the server boundary for Docker connections, defaults, and secret resolution. |
| src/…/page.server.test.ts | Protects the Docker default boundary and prevents unrelated environment values from reaching the page. |
| src/…/monitor-docker.svelte.test.ts | Protects Docker form defaults, connection changes, TLS cleanup, and daemon or container modes. |
| src/…/monitor-api.svelte | Shows the request settings and transport-safety warning for API monitors. |
| src/…/monitor-prometheus.svelte | Shows the management model for Prometheus query and result settings. |
| src/…/monitor-ssl.svelte | Shows the management model for certificate trust and expiry status. |
| src/…/monitor-ssl.svelte.test.ts | Protects the contract for SSL defaults and an explicit zero DOWN threshold. |
| src/…/secrets-over-http.svelte.test.ts | Protects the warning boundary for secret references in API and Prometheus requests. |