UptimeMonitors
The admin side of uptime - a table of monitors with status, a recent-checks bar, a 24h, 7d or 30d uptime badge, response time and last check, pause, resume, check now, edit and delete, plus incidents with their updates.
Code
import { UptimeMonitors, type UptimeMonitor } from "@fadymondy/nasaq/web";declare const monitors: UptimeMonitor[];declare const api: { pause(id: string): Promise<void>; checkNow(id: string): Promise<void> };export const Uptime = () => ( <UptimeMonitors monitors={monitors} onPause={(id) => api.pause(id)} onCheckNow={(id) => api.checkNow(id)} />);Monitoring · beta
Live examples and controls: UptimeMonitors in the lab.
Install
npx shadcn@latest add https://docs.nasaqui.com/r/uptime-monitors.jsonMonitor sites and services. The table shows each monitor's status, a strip of recent checks, the uptime for the chosen period (switch between 24 hours, 7 days and 30 days above the table), the response time and the last check. Row actions (also on right-click): check now, pause, resume, edit and delete. Below it, incidents are listed with their status, impact, how long they lasted and an update timeline. The parts are exported too: UptimeBar, UptimeBadge and IncidentList are reused by the public status page. It has no backend: your callbacks act and you pass the new monitors back.
When to use
- An admin page for monitoring.
UptimeBarandUptimeBadgeanywhere a service's health is shown.
When not to use
- The public page customers see: use
StatusPage. - Metrics over time (latency curves): use
TimeSeriesPanel.
Import
import { UptimeMonitors } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"Quick start
import { UptimeMonitors, type UptimeMonitor } from "@fadymondy/nasaq/web";
declare const monitors: UptimeMonitor[];
declare const api: { pause(id: string): Promise<void>; checkNow(id: string): Promise<void> };
export const Uptime = () => (
<UptimeMonitors
monitors={monitors}
onPause={(id) => api.pause(id)}
onCheckNow={(id) => api.checkNow(id)}
/>
);Anatomy
UptimeMonitors data-slot="uptime-monitors"
├─ header title, overall status Badge
├─ toolbar search, period ToggleGroup (24h, 7d, 30d), Add monitor
├─ DataTable monitor, Status, UptimeBar, UptimeBadge, response, last check; row menu
├─ incidents IncidentList (Timeline of updates)
├─ monitor Dialog name, address, type, interval
└─ AlertDialog delete confirm
UptimeBar data-slot="uptime-bar" one segment per check, oldest first
UptimeBadge data-slot="uptime-badge" percent, coloured by health
IncidentList data-slot="incident-list" newest firstAPI
UptimeMonitors: every Card prop except children, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
monitors | readonly UptimeMonitor[] | required | { id, name, target, kind, status, uptime: { "24h"?, "7d"?, "30d"? }, checks?, responseMs?, lastCheckAt?, intervalSec? }. Status: up, degraded, down, paused, unknown. |
incidents | readonly Incident[] | [] | { id, title, status, impact, startedAt, resolvedAt?, services?, updates? }. |
defaultPeriod | "24h" | "7d" | "30d" | "30d" | Which uptime the badge shows first. |
loading | boolean | false | Skeleton state. |
onSave | (input: MonitorInput, id?) => Promise<void | { error? }> | Shows Add monitor and Edit. | |
onDelete, onPause, onResume, onCheckNow | (id) => Promise<...> | Each shows its row action. | |
labels | Partial<UptimeMonitorsLabels> | Override any string. |
UptimeBar: checks ("up" \| "degraded" \| "down" \| "none"), label. UptimeBadge: percent, period. IncidentList: incidents, showUpdates.
Helpers (pure, tested): computeUptime, formatUptime (truncates: never shows a false 100%), uptimeTone (99.9 and up is green, 99 and up amber, below red), overallStatus, incidentMinutes, formatIncidentDuration, isOpenIncident, responseLabel.
Examples
Just the bar and badge
import { UptimeBadge, UptimeBar } from "@fadymondy/nasaq/web";
export const Health = () => (
<>
<UptimeBar checks={["up", "up", "degraded", "down", "up"]} />
<UptimeBadge percent={99.95} period="30d" />
</>
);Accessibility
- The bar is an image with a text summary; each segment has a title. The uptime badge always carries the figure, never colour alone.
- The period switch is a labelled
ToggleGroup. Row actions are also a button in the row. - Errors from callbacks appear in an
Alert.
RTL & i18n
- English and Arabic strings follow the Nasaq locale. The bar runs right to left (oldest on the right). Percentages, addresses and times of response stay left to right.
Styling & tokens
- Built on
DataTable,Card,Badge,Status,Timeline,ToggleGroupand--nq-*tokens. Target[data-slot="uptime-monitors"].
Do / Don't
- Do count degraded as up for the percentage: the service answered.
- Do pass
nonefor periods with no data instead ofup. - Don't round 99.996 up to 100%: use
formatUptime. - Don't hide open incidents behind a filter.
Related
Lab
https://docs.nasaqui.com/?path=/docs/components-monitoring-uptime-monitors--docs
TimeSeriesPanel
A chart card for one metric at a time, with a previous-period comparison line, a metric switcher and threshold lines. Also exports PeriodToggle.
WebVitalGauge
A gauge for one Core Web Vital (LCP, INP, CLS, FCP, TTFB) with Google's good, needs-improvement and poor bands, the p75 value and the distribution of page loads.