A year of history, one chart, and a read API with personal tokens
History: server load, memory and disks are also kept as hourly (four months) and daily (over two years) averages with lowest and highest; endpoint answers as hourly (four months) beside the daily figures. Charts ask for 24 hours to a year and are drawn from whichever is fine enough. A disk that two weeks call flat is looked at again over ninety days for the forecast. Built once from what is kept. One chart: TimeChart replaces the sparkline and the multi-line chart: hover and arrow-key readout, a lowest/highest band, gaps shown as gaps, the same ranges everywhere and the choice remembered. Used for server trends, comparing servers, a check's availability and answer times (Endpoints > History) and a server's availability. Read API: /api/v1 (servers, metrics, alerts, incidents, inventory, network, endpoints and their history, maintenance) with personal read-only tokens made under the user menu: shown once, hashed, 30/90/365 days or none, ten at most, removed with their owner. GET only. Documented in API.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e26e77340
commit
68b41b5586
47 files changed
+12360
-247
No files matched your search
+32
-2
@@ -305,7 +305,8 @@ export interface ServerMetricSeries {
|
||||
metric: string;
|
||||
kind: "cpu" | "mem" | "disk";
|
||||
label: string;
|
||||
points: { t: string; v: number }[];
|
||||
/** `lo` and `hi` are there when a point stands for an hour or a day: the lowest and highest figure in it. */
|
||||
points: { t: string; v: number; lo?: number; hi?: number }[];
|
||||
latest: number | null;
|
||||
/** Disks only: the rate of change in points a day, and the days until full when it is rising. */
|
||||
trend: { perDay: number; fit: number; spanDays: number; daysToFull: number | null } | null;
|
||||
@@ -907,6 +908,29 @@ export interface EndpointCheck {
|
||||
server: { id: number; name: string } | null;
|
||||
stats?: EndpointStats;
|
||||
}
|
||||
/** How one check has done over a stretch (GET /api/endpoints/:id/history). */
|
||||
export interface EndpointHistory {
|
||||
check: { id: number; name: string };
|
||||
days: number;
|
||||
/** Which figures it is drawn from: each answer (a day or two), the hourly figures, or the daily ones. */
|
||||
source: "results" | "hourly" | "daily";
|
||||
points: { t: string; availability: number | null; avgMs: number | null; maxMs: number | null; checks: number }[];
|
||||
availability: number | null;
|
||||
avgMs: number | null;
|
||||
checks: number;
|
||||
}
|
||||
|
||||
/** One of a person's own read-only API tokens; the secret is only ever shown when it is made. */
|
||||
export interface ApiToken {
|
||||
id: number;
|
||||
label: string;
|
||||
tokenPrefix: string;
|
||||
createdAt: string;
|
||||
lastUsedAt: string | null;
|
||||
expiresAt: string | null;
|
||||
expired: boolean;
|
||||
}
|
||||
|
||||
export interface EndpointInput {
|
||||
name: string;
|
||||
kind: EndpointKind;
|
||||
@@ -2155,7 +2179,12 @@ export const api = {
|
||||
markChangesSeen: () => request<{ lastLookedAt: string }>("/api/me/changes/seen", { method: "POST" }),
|
||||
}),
|
||||
uptime: {
|
||||
get: () => request<UptimeReport>("/api/uptime"),
|
||||
get: (days?: number) => request<UptimeReport>(days ? `/api/uptime?days=${days}` : "/api/uptime"),
|
||||
},
|
||||
apiTokens: {
|
||||
list: () => request<{ tokens: ApiToken[]; max: number; expiryChoices: number[] }>("/api/me/tokens"),
|
||||
create: (data: { label: string; expiresInDays: number | null }) => request<{ token: ApiToken; secret: string }>("/api/me/tokens", { method: "POST", body: JSON.stringify(data) }),
|
||||
remove: (id: number) => request<void>(`/api/me/tokens/${id}`, { method: "DELETE" }),
|
||||
},
|
||||
metricsTokens: {
|
||||
list: () => request<{ tokens: MetricsToken[] }>("/api/metrics-tokens"),
|
||||
@@ -2204,6 +2233,7 @@ export const api = {
|
||||
update: (id: number, data: EndpointInput) => request<{ check: EndpointCheck }>(`/api/endpoints/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||||
remove: (id: number) => request<void>(`/api/endpoints/${id}`, { method: "DELETE" }),
|
||||
check: (id: number) => request<{ result: { ok: boolean; ms: number | null; message: string } }>(`/api/endpoints/${id}/check`, { method: "POST" }),
|
||||
history: (id: number, days: number) => request<EndpointHistory>(`/api/endpoints/${id}/history?days=${days}`),
|
||||
suggestions: () => request<{ suggestions: EndpointSuggestion[]; dismissed: EndpointSuggestion[] }>("/api/endpoints/suggestions"),
|
||||
addSuggestions: (keys: string[]) => request<{ added: { id: number; name: string }[] }>("/api/endpoints/suggestions/add", { method: "POST", body: JSON.stringify({ keys }) }),
|
||||
dismissSuggestions: (keys: string[]) => request<{ suggestions: EndpointSuggestion[]; dismissed: EndpointSuggestion[] }>("/api/endpoints/suggestions/dismiss", { method: "POST", body: JSON.stringify({ keys }) }),
|
||||
|
||||
Reference in new issue
Block a user