Today, Services and Hosts by site: the dashboard as a briefing #74
No files matched your search
@@ -327,12 +327,13 @@ hide a real outage.
|
||||
Built on the paged, server-side lists from #69. No page ever lists
|
||||
everything at once.
|
||||
|
||||
- **Dashboard:** one line per cluster: its version, state and a summary
|
||||
- **Clusters page:** one line per cluster: its version, state and a summary
|
||||
in its kind's terms: "31/32 nodes ready · 3,300 workloads" for
|
||||
Kubernetes, "2/2 controllers ready · 600 volumes · 71% used" for an
|
||||
array, "CPU 41% · system ASP 85% · 4 of 5 subsystems active" for an
|
||||
IBM i partition. The network map's cluster boxes use the same line.
|
||||
The "needs attention" list takes workloads too, capped as for hosts.
|
||||
The dashboard counts the clusters with a problem, and its "needs you"
|
||||
and "can wait" lists take workloads too, capped as for hosts.
|
||||
- **Clusters:** in sections by kind (Kubernetes, Virtualization, Storage,
|
||||
IBM i, Secrets), the ones that need a look first in each, with a jump
|
||||
list counting each kind and its problems. Filters for kind, "need a
|
||||
|
||||
+25
-3
@@ -728,8 +728,29 @@ restarts; admins can preview it and send it by hand on the Reports page.
|
||||
|
||||
### The dashboard's briefing
|
||||
|
||||
The same history feeds the dashboard. `GET /api/v1/overview` carries,
|
||||
besides the readings:
|
||||
The dashboard (Today) is written to be read, not scanned for numbers. It
|
||||
opens with a sentence on whether anything needs you and whether
|
||||
customers are affected (the services with `tier: public`), then:
|
||||
|
||||
- **Needs you:** critical and serious problems nobody has picked up, each
|
||||
with when it started, whether people were told and what it takes down.
|
||||
**I'm on it** is the acknowledgement: the repeats stop, and the problem
|
||||
moves to **Being handled** with who has it.
|
||||
- **Can wait:** warnings, one line each with why.
|
||||
- **Your services:** each service's state and its last 24 hours, one bar
|
||||
per half hour. The **Services** page lists them all by tier (what
|
||||
customers use, what runs it, where the data lives, the edge); picking one
|
||||
shows its parts in trouble, what it needs and what needs it.
|
||||
- **Since you last looked:** what opened and closed since your last visit.
|
||||
- **The fleet:** hosts reporting, containers, clusters and the busiest
|
||||
host, and what's worth watching: disks filling up, hosts busier than
|
||||
usual for the hour, hosts restarted in the last day. The **Hosts** page
|
||||
shows the same list over one square per host, grouped by the network
|
||||
map's sites and by role, the host name's first word after its site
|
||||
(phx1-app05 is an app server); the table is a click away.
|
||||
|
||||
The same history feeds it. `GET /api/v1/overview` carries, besides the
|
||||
readings:
|
||||
|
||||
- `today`: what happened since this person last looked. A visit ends after
|
||||
30 minutes without the dashboard open, and the end of the last one is
|
||||
@@ -754,7 +775,8 @@ besides the readings:
|
||||
|
||||
The strips and uptimes are read from history once a minute (30 days every
|
||||
ten), the watch list every ten minutes, whatever the number of dashboards
|
||||
open.
|
||||
open. `GET /api/v1/fleet` is the Hosts page's squares: every host's state
|
||||
by site and role, the hosts that need a look per site, and the watch list.
|
||||
|
||||
## checks.yaml: active checks
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// The Hosts page's grid (#72): one square per host, grouped by site (the
|
||||
// network map's) and role, so at thousands of hosts the odd one out still
|
||||
// stands out. GET /api/v1/fleet; not under /hosts/, where a host named
|
||||
// "grid" would lose its page.
|
||||
|
||||
// GridSite is a site's hosts by role.
|
||||
type GridSite struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Roles []GridRole `json:"roles"`
|
||||
Hosts int `json:"hosts"`
|
||||
// Trouble is its hosts that need a look, worst first.
|
||||
Trouble []GridHost `json:"trouble"`
|
||||
}
|
||||
|
||||
// GridRole is one role's hosts in a site.
|
||||
type GridRole struct {
|
||||
Role string `json:"role"`
|
||||
Hosts []GridHost `json:"hosts"`
|
||||
}
|
||||
|
||||
// GridHost is one square.
|
||||
type GridHost struct {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Word string `json:"word"`
|
||||
}
|
||||
|
||||
// hostRole is what a host is from its name: the first word after its
|
||||
// site, without its number. phx1-app05 in phx1 is "app", web-02 is "web",
|
||||
// win-dc01 is "win", host3 is "host".
|
||||
func hostRole(name, site string) string {
|
||||
r := name
|
||||
if site != "" && strings.HasPrefix(r, site) {
|
||||
r = r[len(site):]
|
||||
}
|
||||
r = strings.Trim(r, "-_.")
|
||||
if i := strings.IndexAny(r, "-_."); i >= 0 {
|
||||
r = r[:i]
|
||||
}
|
||||
r = strings.TrimRight(r, "0123456789")
|
||||
if r == "" {
|
||||
return "other"
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// fleetGrid groups hosts by site and role. siteOf names each host's site
|
||||
// (id → name in names); hosts in none go under "Elsewhere".
|
||||
func fleetGrid(hosts []HostView, siteOf map[string]string, names map[string]string) []GridSite {
|
||||
by := map[string]*GridSite{}
|
||||
roles := map[string]map[string]*GridRole{}
|
||||
// A host the map didn't place (a collector, one without map samples)
|
||||
// goes with the site its name starts with, when one does: phx1-stor01
|
||||
// with phx1.
|
||||
prefixes := map[string]string{}
|
||||
for id, n := range names {
|
||||
if n != "" {
|
||||
prefixes[n] = id
|
||||
}
|
||||
}
|
||||
for _, h := range hosts {
|
||||
id := siteOf[h.Name]
|
||||
if id == "" {
|
||||
if p, _, ok := strings.Cut(h.Name, "-"); ok && prefixes[p] != "" {
|
||||
id = prefixes[p]
|
||||
}
|
||||
}
|
||||
s := by[id]
|
||||
if s == nil {
|
||||
name := names[id]
|
||||
if id == "" {
|
||||
name = "Elsewhere"
|
||||
}
|
||||
s = &GridSite{ID: id, Name: name, Trouble: []GridHost{}}
|
||||
by[id] = s
|
||||
roles[id] = map[string]*GridRole{}
|
||||
}
|
||||
prefix := names[id]
|
||||
role := hostRole(h.Name, prefix)
|
||||
r := roles[id][role]
|
||||
if r == nil {
|
||||
r = &GridRole{Role: role}
|
||||
roles[id][role] = r
|
||||
}
|
||||
st := h.Status
|
||||
if h.Silent {
|
||||
st = "critical"
|
||||
}
|
||||
g := GridHost{Name: h.Name, Status: st, Word: h.Word}
|
||||
r.Hosts = append(r.Hosts, g)
|
||||
s.Hosts++
|
||||
if st == "warning" || st == "serious" || st == "critical" {
|
||||
s.Trouble = append(s.Trouble, g)
|
||||
}
|
||||
}
|
||||
out := []GridSite{}
|
||||
for id, s := range by {
|
||||
for _, r := range roles[id] {
|
||||
sort.Slice(r.Hosts, func(i, j int) bool { return r.Hosts[i].Name < r.Hosts[j].Name })
|
||||
s.Roles = append(s.Roles, *r)
|
||||
}
|
||||
// The biggest role first (the app servers), then by name.
|
||||
sort.Slice(s.Roles, func(i, j int) bool {
|
||||
if len(s.Roles[i].Hosts) != len(s.Roles[j].Hosts) {
|
||||
return len(s.Roles[i].Hosts) > len(s.Roles[j].Hosts)
|
||||
}
|
||||
return s.Roles[i].Role < s.Roles[j].Role
|
||||
})
|
||||
sort.SliceStable(s.Trouble, func(i, j int) bool { return statusRank[s.Trouble[i].Status] > statusRank[s.Trouble[j].Status] })
|
||||
out = append(out, *s)
|
||||
}
|
||||
// Sites by size, Elsewhere last.
|
||||
sort.Slice(out, func(i, j int) bool {
|
||||
if (out[i].ID == "") != (out[j].ID == "") {
|
||||
return out[j].ID == ""
|
||||
}
|
||||
if out[i].Hosts != out[j].Hosts {
|
||||
return out[i].Hosts > out[j].Hosts
|
||||
}
|
||||
return out[i].Name < out[j].Name
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
func (srv *Server) handleFleet(w http.ResponseWriter, r *http.Request) {
|
||||
now := time.Now()
|
||||
hosts, _ := srv.view(now)
|
||||
siteOf, names := map[string]string{}, map[string]string{}
|
||||
if g := srv.mapGraph(now); g != nil {
|
||||
for _, s := range g.Sites {
|
||||
names[s.ID] = s.Name
|
||||
for _, h := range s.Hosts {
|
||||
siteOf[h] = s.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"sites": fleetGrid(hosts, siteOf, names), "watch": srv.watch(hosts, now)})
|
||||
}
|
||||
@@ -428,6 +428,7 @@ func (srv *Server) Handler() http.Handler {
|
||||
mux.HandleFunc("GET /api/v1/map/network", srv.needSession(srv.handleMapNetwork))
|
||||
mux.HandleFunc("GET /api/v1/map/services", srv.needSession(srv.handleMapServices))
|
||||
mux.HandleFunc("GET /api/v1/services", srv.needSession(srv.handleServices))
|
||||
mux.HandleFunc("GET /api/v1/fleet", srv.needSession(srv.handleFleet))
|
||||
mux.HandleFunc("GET /api/v1/map/find", srv.needSession(srv.handleMapFind))
|
||||
mux.HandleFunc("GET /api/v1/map/found", srv.needSession(srv.handleMapFound))
|
||||
mux.HandleFunc("GET /api/v1/map/corrections", srv.needSession(srv.handleMapCorrections))
|
||||
|
||||
@@ -151,3 +151,34 @@ func TestWithIncidents(t *testing.T) {
|
||||
t.Errorf("others: %+v %+v", got[1].Incident, got[2].Incident)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFleetGrid(t *testing.T) {
|
||||
for _, c := range [][3]string{{"phx1-app05", "phx1", "app"}, {"web-02", "", "web"}, {"host3", "", "host"}, {"db1.example.com", "", "db"}, {"phx1-07", "phx1", "other"}, {"win-dc01", "", "win"}, {"lb-edge-01", "", "lb"}} {
|
||||
if got := hostRole(c[0], c[1]); got != c[2] {
|
||||
t.Errorf("hostRole(%s, %s) = %s, want %s", c[0], c[1], got, c[2])
|
||||
}
|
||||
}
|
||||
hosts := []HostView{
|
||||
{Name: "phx1-app02", Status: "good"}, {Name: "phx1-app01", Status: "warning", Word: "disk 91%"},
|
||||
{Name: "phx1-db01", Status: "good"}, {Name: "lon1-app01", Status: "good"},
|
||||
{Name: "bench", Status: "good", Silent: true}, {Name: "phx1-stor01", Status: "good"},
|
||||
}
|
||||
siteOf := map[string]string{"phx1-app01": "s1", "phx1-app02": "s1", "phx1-db01": "s1", "lon1-app01": "s2"}
|
||||
names := map[string]string{"s1": "phx1", "s2": "lon1"}
|
||||
got := fleetGrid(hosts, siteOf, names)
|
||||
if len(got) != 3 || got[0].Name != "phx1" || got[1].Name != "lon1" || got[2].Name != "Elsewhere" {
|
||||
t.Fatalf("sites = %+v", got)
|
||||
}
|
||||
if got[0].Hosts != 4 {
|
||||
t.Errorf("phx1-stor01 should join phx1 by its name: %+v", got[0])
|
||||
}
|
||||
if r := got[0].Roles; len(r) != 3 || r[0].Role != "app" || r[0].Hosts[0].Name != "phx1-app01" || r[1].Role != "db" || r[2].Role != "stor" {
|
||||
t.Errorf("phx1 roles = %+v", r)
|
||||
}
|
||||
if tr := got[0].Trouble; len(tr) != 1 || tr[0].Name != "phx1-app01" {
|
||||
t.Errorf("phx1 trouble = %+v", tr)
|
||||
}
|
||||
if tr := got[2].Trouble; len(tr) != 1 || tr[0].Status != "critical" {
|
||||
t.Errorf("a silent host is trouble: %+v", tr)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<script lang="ts">
|
||||
// One square per host, grouped by site and role (#72): at thousands of
|
||||
// hosts a table hides the one that's wrong; a field of calm squares
|
||||
// doesn't. Above it, the few hosts heading somewhere.
|
||||
import { get, SignedOut, type Watch } from './api';
|
||||
import { live } from './live.svelte';
|
||||
import { duration } from './format';
|
||||
|
||||
interface GridHost { name: string; status: string; word: string }
|
||||
interface GridSite { id: string; name: string; hosts: number; roles: { role: string; hosts: GridHost[] }[]; trouble: GridHost[] }
|
||||
|
||||
let sites = $state<GridSite[] | null>(null);
|
||||
let watch = $state<Watch | null>(null);
|
||||
let error = $state('');
|
||||
async function load() {
|
||||
try {
|
||||
const r = await get<{ sites: GridSite[]; watch: Watch }>('/api/v1/fleet');
|
||||
sites = r.sites;
|
||||
watch = r.watch;
|
||||
error = '';
|
||||
} catch (e) {
|
||||
if (e instanceof SignedOut) void live.checkSession();
|
||||
else error = String(e);
|
||||
}
|
||||
}
|
||||
$effect(() => {
|
||||
void load();
|
||||
const t = setInterval(() => void load(), 10_000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
|
||||
const total = $derived((sites ?? []).reduce((n, s) => n + s.hosts, 0));
|
||||
// Smaller squares for a bigger fleet, so a site still fits on a screen.
|
||||
const size = $derived(total > 2000 ? 8 : total > 600 ? 11 : 18);
|
||||
const WORD: Record<string, string> = { good: 'fine', warning: 'warning', serious: 'serious', critical: 'critical', waiting: 'waiting for its first report', off: 'off' };
|
||||
const days = (d: number) => (d < 1 ? 'within a day' : `in about ${Math.round(d)} ${Math.round(d) === 1 ? 'day' : 'days'}`);
|
||||
const ROLE: Record<string, string> = { app: 'App', db: 'Database', lb: 'Load balancer', gw: 'Gateway', mx: 'Mail', mq: 'Messaging', cache: 'Cache', web: 'Web', stor: 'Storage', win: 'Windows', ibmi: 'IBM i', virt: 'Virtualization', kvm: 'KVM', k8s: 'Kubernetes', host: 'Host', other: 'Other' };
|
||||
const roleName = (r: string) => ROLE[r] ?? r.charAt(0).toUpperCase() + r.slice(1);
|
||||
</script>
|
||||
|
||||
{#if error}<p class="foot-note" style="color:var(--critical)">{error}</p>{/if}
|
||||
|
||||
{#if watch && (watch.filling.length || watch.busier.length || watch.restarted_n)}
|
||||
<section class="watch" aria-labelledby="watch-h">
|
||||
<h2 id="watch-h">Worth watching</h2>
|
||||
<div class="wcols">
|
||||
{#if watch.filling.length}
|
||||
<div class="card">
|
||||
<h3>Filling up</h3>
|
||||
<ul>{#each watch.filling as d (d.host + d.mount)}<li><a class="mono" href="/hosts/{d.host}">{d.host}</a><span class="val mono">{Math.round(d.pct)}%</span><span class="bar"><i style="width:{Math.min(100, d.pct)}%"></i></span><small>{d.mount} · full {days(d.full_days)}</small></li>{/each}</ul>
|
||||
</div>
|
||||
{/if}
|
||||
{#if watch.busier.length}
|
||||
<div class="card">
|
||||
<h3>Busier than usual</h3>
|
||||
<ul>{#each watch.busier as b (b.host + b.what)}<li><a class="mono" href="/hosts/{b.host}">{b.host}</a><span class="val mono">{Math.round(b.now)}% {b.what === 'cpu' ? 'CPU' : 'memory'}</span><span class="bar"><i style="width:{Math.min(100, b.now)}%"></i></span><small>usually {Math.round(b.usual)}% at this hour</small></li>{/each}</ul>
|
||||
</div>
|
||||
{/if}
|
||||
{#if watch.restarted_n}
|
||||
<div class="card">
|
||||
<h3>Restarted in the last day · {watch.restarted_n}</h3>
|
||||
<ul>{#each watch.restarted as r (r.host)}<li><a class="mono" href="/hosts/{r.host}">{r.host}</a><small>{duration(r.up_s)} ago</small></li>{/each}</ul>
|
||||
{#if watch.restarted_n > watch.restarted.length}<p class="sub">and {watch.restarted_n - watch.restarted.length} more</p>{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if sites === null}
|
||||
<p class="empty">Loading…</p>
|
||||
{:else}
|
||||
<div class="legend" aria-hidden="true">
|
||||
<span><i class="sq good"></i>Fine</span>
|
||||
<span><i class="sq warning"></i>Warning</span>
|
||||
<span><i class="sq serious"></i>Serious</span>
|
||||
<span><i class="sq critical"></i>Critical or silent</span>
|
||||
<span><i class="sq waiting"></i>Waiting</span>
|
||||
</div>
|
||||
<div class="sites" style="--sq:{size}px">
|
||||
{#each sites as s (s.id)}
|
||||
<section class="card site" aria-labelledby="site-{s.id || 'none'}">
|
||||
<div class="sh">
|
||||
<h2 id="site-{s.id || 'none'}">{s.name}</h2>
|
||||
<span class:bad={s.trouble.length}>{s.hosts} {s.hosts === 1 ? 'host' : 'hosts'} · {s.trouble.length ? `${s.trouble.length} need a look` : 'all fine'}</span>
|
||||
</div>
|
||||
{#each s.roles as r (r.role)}
|
||||
<div class="role">
|
||||
<span class="rl">{roleName(r.role)} · {r.hosts.length}</span>
|
||||
<span class="sqs">
|
||||
{#each r.hosts as h (h.name)}<a class="sq {h.status}" href="/hosts/{h.name}" title="{h.name}: {h.status === 'good' ? 'fine' : h.word || WORD[h.status]}" aria-label="{h.name}, {h.status === 'good' ? 'fine' : h.word || WORD[h.status]}"></a>{/each}
|
||||
</span>
|
||||
</div>
|
||||
{/each}
|
||||
{#if s.trouble.length}
|
||||
<ul class="trouble">
|
||||
{#each s.trouble.slice(0, 8) as h (h.name)}<li><i class="dot {h.status}"></i><a class="mono" href="/hosts/{h.name}">{h.name}</a> <span>{h.word}</span></li>{/each}
|
||||
{#if s.trouble.length > 8}<li class="sub">and {s.trouble.length - 8} more</li>{/if}
|
||||
</ul>
|
||||
{/if}
|
||||
</section>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-soft); }
|
||||
.watch { margin-bottom: 20px; }
|
||||
.watch h2 { font-size: 18px; margin-bottom: 10px; }
|
||||
.wcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
|
||||
.wcols .card { padding: 16px 18px; }
|
||||
.wcols h3 { font-size: 15px; margin-bottom: 10px; }
|
||||
.wcols ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
|
||||
.wcols li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
|
||||
.wcols .val { color: var(--data); font-size: 13px; }
|
||||
.wcols .bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--border); display: flex; }
|
||||
.wcols .bar i { border-radius: 3px; background: var(--data); }
|
||||
.wcols small { grid-column: 1 / -1; color: var(--muted-fg); font-size: 13px; }
|
||||
|
||||
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 14px; color: var(--muted-fg); font-size: 13px; }
|
||||
.legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.legend .sq { width: 14px; height: 14px; }
|
||||
.sites { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
|
||||
.site { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
|
||||
.sh { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
|
||||
.sh h2 { font-size: 19px; }
|
||||
.sh span { color: var(--muted-fg); font-size: 14px; }
|
||||
.sh span.bad { color: var(--warning); }
|
||||
.role { display: flex; gap: 12px; align-items: flex-start; }
|
||||
.rl { flex: 0 0 110px; color: var(--muted-fg); font-size: 13px; line-height: var(--sq); }
|
||||
.sqs { display: flex; flex-wrap: wrap; gap: 3px; flex: 1 1 auto; min-width: 0; }
|
||||
.sq { display: block; width: var(--sq); height: var(--sq); border-radius: 3px; background: color-mix(in oklab, var(--good) 38%, var(--card)); }
|
||||
a.sq:hover, a.sq:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
|
||||
.sq.warning { background: var(--warning); }
|
||||
.sq.serious { background: var(--serious); }
|
||||
.sq.critical { background: var(--critical); }
|
||||
.sq.waiting, .sq.off { background: var(--input); }
|
||||
.trouble { list-style: none; margin: 4px 0 0; padding: 10px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
|
||||
.trouble li { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
|
||||
.trouble li span { color: color-mix(in oklab, var(--foreground) 85%, var(--muted-fg)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
||||
.dot { flex: none; width: 10px; height: 10px; border-radius: 2px; background: var(--warning); align-self: center; }
|
||||
.dot.critical { background: var(--critical); } .dot.serious { background: var(--serious); }
|
||||
@media (max-width: 640px) { .rl { flex-basis: 84px; } }
|
||||
</style>
|
||||
+26
-18
@@ -70,29 +70,36 @@
|
||||
store('folded', JSON.stringify(folded));
|
||||
}
|
||||
type Item = { href: string; icon: IconName; label: string; show?: boolean; exact?: boolean; meta?: number; sev?: string; tip?: string };
|
||||
const overview = $derived(([
|
||||
{ href: '/', icon: 'dashboard', label: 'Dashboard', exact: true, show: true },
|
||||
// One entry for every host: a big fleet's partial list told you little.
|
||||
{ href: '/hosts', icon: 'hosts', label: 'Hosts', show: true, meta: hostLook, sev: hostCritical ? 'critical' : 'warning', tip: hostLook ? `${hostLook} need a look` : '' }
|
||||
// Shaped by what people come to do (#72): today's briefing and what to
|
||||
// act on first, then the fleet, the maps, and what Cairn OBS is
|
||||
// connected to.
|
||||
const hasServices = $derived((live.overview?.services?.length ?? 0) > 0);
|
||||
const today = $derived(([
|
||||
{ href: '/', icon: 'dashboard', label: 'Today', exact: true, show: true },
|
||||
{ href: '/services', icon: 'services', label: 'Services', show: hasServices },
|
||||
{ href: '/alerts', icon: 'bell', label: 'Alerts', show: true, meta: unacked, sev: 'critical', tip: unacked ? `${unacked} not acknowledged` : '' },
|
||||
{ href: '/reports', icon: 'report', label: 'Reports', show: f?.reports }
|
||||
] as Item[]).filter((i) => i.show));
|
||||
const infra = $derived(([
|
||||
{ href: '/map/network', icon: 'network', label: 'Network map', show: f?.maps },
|
||||
{ href: '/map/services', icon: 'services', label: 'Service map', show: f?.maps },
|
||||
{ href: '/mail', icon: 'mail', label: 'Mail', show: f?.mail },
|
||||
{ href: '/data', icon: 'database', label: 'Data layer', show: f?.data },
|
||||
const fleet = $derived(([
|
||||
// One entry for every host: a big fleet's partial list told you little.
|
||||
{ href: '/hosts', icon: 'hosts', label: 'Hosts', show: true, meta: hostLook, sev: hostCritical ? 'critical' : 'warning', tip: hostLook ? `${hostLook} need a look` : '' },
|
||||
{ href: '/clusters', icon: 'cluster', label: 'Clusters', show: f?.workloads, meta: clusterProblems, sev: clusterSeverity, tip: clusterProblems ? `${clusterProblems} need a look` : '' },
|
||||
{ href: '/workloads', icon: 'grid', label: 'Workloads', show: f?.workloads },
|
||||
{ href: '/containers', icon: 'box', label: 'Containers', show: f?.containers || problems > 0, meta: problems, sev: containerSeverity, tip: problems ? `${problems} need a look` : '' },
|
||||
{ href: '/containers', icon: 'box', label: 'Containers', show: f?.containers || problems > 0, meta: problems, sev: containerSeverity, tip: problems ? `${problems} need a look` : '' }
|
||||
] as Item[]).filter((i) => i.show));
|
||||
const maps = $derived(([
|
||||
{ href: '/map/network', icon: 'network', label: 'Network map', show: f?.maps },
|
||||
{ href: '/map/services', icon: 'services', label: 'Service map', show: f?.maps }
|
||||
] as Item[]).filter((i) => i.show));
|
||||
const connected = $derived(([
|
||||
{ href: '/checks', icon: 'check', label: 'Checks', show: f?.checks || checksDown > 0, meta: checksDown, sev: live.overview?.checks?.severity ?? 'warning', tip: checksDown ? `${checksDown} down` : '' },
|
||||
{ href: '/mail', icon: 'mail', label: 'Mail', show: f?.mail },
|
||||
{ href: '/data', icon: 'database', label: 'Data layer', show: f?.data },
|
||||
{ href: '/certificates', icon: 'lock', label: 'Certificates', show: f?.certificates },
|
||||
{ href: '/backups', icon: 'archive', label: 'Backups', show: f?.backups },
|
||||
{ href: '/cloudflare', icon: 'cloud', label: 'Cloudflare', show: f?.cloudflare },
|
||||
{ href: '/akamai', icon: 'globe', label: 'Akamai', show: f?.akamai }
|
||||
] as Item[]).filter((i) => i.show));
|
||||
const watch = $derived(([
|
||||
{ href: '/checks', icon: 'check', label: 'Checks', show: f?.checks || checksDown > 0, meta: checksDown, sev: live.overview?.checks?.severity ?? 'warning', tip: checksDown ? `${checksDown} down` : '' },
|
||||
{ href: '/alerts', icon: 'bell', label: 'Alerts', show: true, meta: unacked, sev: 'critical', tip: unacked ? `${unacked} not acknowledged` : '' },
|
||||
{ href: '/reports', icon: 'report', label: 'Reports', show: f?.reports }
|
||||
] as Item[]).filter((i) => i.show));
|
||||
const setup: Item[] = [
|
||||
{ href: '/configure', icon: 'settings', label: 'Overview', exact: true },
|
||||
{ href: '/configure/hosts', icon: 'hosts', label: 'Hosts' },
|
||||
@@ -215,9 +222,10 @@
|
||||
{@render group('Configure', setup)}
|
||||
{@render group('Access', access)}
|
||||
{:else}
|
||||
{@render group('Overview', overview)}
|
||||
{#if infra.length}{@render group('Infrastructure', infra)}{/if}
|
||||
{@render group('Watch', watch)}
|
||||
{@render group('Today', today)}
|
||||
{@render group('Fleet', fleet)}
|
||||
{#if maps.length}{@render group('Maps', maps)}{/if}
|
||||
{#if connected.length}{@render group('Connected to', connected)}{/if}
|
||||
{/if}
|
||||
</nav>
|
||||
<div class="side-foot">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
/** A service's last 24 hours: one bar per half hour, coloured by the worst status in it. */
|
||||
let { cells, name = '' }: { cells: string[]; name?: string } = $props();
|
||||
const bad = $derived(cells.filter((c) => c === 'warning' || c === 'serious' || c === 'critical').length);
|
||||
const label = $derived(`${name ? name + ', ' : ''}last 24 hours: ${bad ? `trouble in ${bad} of ${cells.length} half hours` : 'no trouble'}`);
|
||||
</script>
|
||||
|
||||
<span class="strip" role="img" aria-label={label}>{#each cells as c, i (i)}<i class={c || 'none'}></i>{/each}</span>
|
||||
|
||||
<style>
|
||||
.strip { display: flex; gap: 1px; height: 22px; min-width: 0; }
|
||||
.strip i { flex: 1 1 0; min-width: 1px; border-radius: 2px; background: var(--border); }
|
||||
.strip .good { background: var(--good); opacity: .45; }
|
||||
.strip .off, .strip .waiting { background: var(--muted-fg); opacity: .3; }
|
||||
.strip .warning { background: var(--warning); }
|
||||
.strip .serious { background: var(--serious); }
|
||||
.strip .critical { background: var(--critical); }
|
||||
</style>
|
||||
+20
-2
@@ -40,7 +40,25 @@ export interface VMLink { source: string; namespace?: string; name: string; node
|
||||
/** The libvirt VMs a host runs. */
|
||||
export interface HostVMCount { total: number; running: number; error?: string; href: string }
|
||||
export interface UnitView { name: string; load: string; active: string; sub: string; restarts: number; since?: string; host: string; severity: Severity; word: string }
|
||||
export interface Attention { severity: Severity; title: string; detail: string; href: string; host: string }
|
||||
export interface Attention {
|
||||
severity: Severity; title: string; detail: string; href: string; host: string;
|
||||
key?: string; affected?: string;
|
||||
/** The open incident it is, once there is one: the dashboard's "I'm on it" acknowledges it. */
|
||||
incident?: { id: string; opened: string; fired: string | null; ack: { by: string; at: string } | null };
|
||||
}
|
||||
/** What happened since this person last looked (internal/server/today.go). */
|
||||
export interface Today { since: string; last_visit: boolean; events: TodayEvent[]; opened: number; resolved: number; fixed_itself: number; told: number }
|
||||
export interface TodayEvent { id: string; severity: Severity; title: string; host?: string; href?: string; at: string; opened: string; resolved?: string; ack_by?: string; told: boolean }
|
||||
/** A service's last 24 hours as 48 half-hour cells (the worst status in each, '' unknown), and its uptime (-1 unknown). */
|
||||
export interface ServiceHistory { cells: string[]; pct_24h: number; pct_30d: number }
|
||||
export interface ServiceBrief { id: string; name: string; tier: string; status: Severity; word: string; history: ServiceHistory }
|
||||
/** The few hosts heading somewhere, in place of gauges. */
|
||||
export interface Watch {
|
||||
filling: { host: string; mount: string; pct: number; full_days: number }[];
|
||||
busier: { host: string; what: 'cpu' | 'memory'; now: number; usual: number }[];
|
||||
restarted: { host: string; up_s: number }[];
|
||||
restarted_n: number;
|
||||
}
|
||||
/** Every host in a few numbers (internal/server/lists.go). */
|
||||
export interface Fleet {
|
||||
hosts: number;
|
||||
@@ -58,7 +76,7 @@ export interface HostRow {
|
||||
os?: string; uptime_s: number; cpu_pct: number; mem_pct: number; fullest?: Disk; containers: ContainerSummary;
|
||||
}
|
||||
/** hosts is every host in a small fleet, else the ones most in need; fleet counts them all. */
|
||||
export interface Overview { now: string; version: string; hosts: Host[]; fleet: Fleet; attention: Attention[]; containers: ContainerSummary; alerts: { firing: number; unacknowledged: number }; checks?: { down: number; severity: string }; features?: Features; clusters?: Cluster[] }
|
||||
export interface Overview { now: string; version: string; hosts: Host[]; fleet: Fleet; attention: Attention[]; containers: ContainerSummary; alerts: { firing: number; unacknowledged: number }; checks?: { down: number; severity: string }; features?: Features; clusters?: Cluster[]; today?: Today; services?: ServiceBrief[]; watch?: Watch }
|
||||
/** A cluster agent's cluster: GET /api/v1/clusters, and the overview. */
|
||||
export interface Cluster {
|
||||
name: string; status: Severity; word: string; heard: string | null; listed: string | null; agent?: string; version?: string;
|
||||
|
||||
+320
-158
@@ -1,13 +1,14 @@
|
||||
<script lang="ts">
|
||||
// The dashboard as a briefing (#69): first a sentence on whether
|
||||
// anything needs you, then what does, what can wait, the services, what
|
||||
// happened since you last looked and the fleet in a line. Readings live
|
||||
// on the Hosts page; here only what someone has to act on or know.
|
||||
import Icon from '$lib/Icon.svelte';
|
||||
import Mark from '$lib/Mark.svelte';
|
||||
import Panel from '$lib/Panel.svelte';
|
||||
import Gauge from '$lib/Gauge.svelte';
|
||||
import Meter from '$lib/Meter.svelte';
|
||||
import Spark from '$lib/Spark.svelte';
|
||||
import Status from '$lib/Status.svelte';
|
||||
import Strip from '$lib/Strip.svelte';
|
||||
import { live } from '$lib/live.svelte';
|
||||
import { duration, hms, hour, rate, utc, zone } from '$lib/format';
|
||||
import { post, type Attention, type TodayEvent } from '$lib/api';
|
||||
import { ago, duration, hm, hour } from '$lib/format';
|
||||
|
||||
let now = $state(Date.now());
|
||||
$effect(() => {
|
||||
@@ -16,180 +17,341 @@
|
||||
});
|
||||
|
||||
const o = $derived(live.overview);
|
||||
const hosts = $derived(o?.hosts ?? []);
|
||||
// Totals over every host; a big fleet's hosts list is only the ones most in need.
|
||||
const total = $derived(o?.fleet?.hosts ?? hosts.length);
|
||||
const total = $derived(o?.fleet?.hosts ?? 0);
|
||||
const reporting = $derived(o?.fleet?.reporting ?? 0);
|
||||
const busiest = $derived(o?.fleet?.busiest);
|
||||
const fullest = $derived(o?.fleet?.fullest);
|
||||
const attn = $derived(o?.attention ?? []);
|
||||
const urgent = (a: Attention) => a.severity === 'critical' || a.severity === 'serious';
|
||||
// Picked up by someone: out of "Needs you", shown as being handled.
|
||||
const taken = $derived(attn.filter((a) => a.incident?.ack));
|
||||
const needs = $derived(attn.filter((a) => urgent(a) && !a.incident?.ack));
|
||||
const later = $derived(attn.filter((a) => !urgent(a) && !a.incident?.ack));
|
||||
const services = $derived(o?.services ?? []);
|
||||
const working = $derived(services.filter((s) => s.status === 'good' || s.status === 'off').length);
|
||||
const customer = $derived(services.filter((s) => s.tier === 'public'));
|
||||
const custDown = $derived(customer.filter((s) => s.status === 'critical'));
|
||||
const custHurt = $derived(customer.filter((s) => s.status === 'warning' || s.status === 'serious'));
|
||||
const clusters = $derived(o?.clusters ?? []);
|
||||
const clusterTrouble = $derived(clusters.filter((k) => k.status !== 'good' && k.status !== 'off').length);
|
||||
const c = $derived(o?.containers);
|
||||
const crit = $derived(o?.attention.some((a) => a.severity === 'critical') ?? false);
|
||||
const today = $derived(o?.today);
|
||||
const watch = $derived(o?.watch);
|
||||
|
||||
const NUM = ['No', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'];
|
||||
const num = (n: number) => (n <= 10 ? NUM[n] : String(n));
|
||||
const names = (l: { name: string }[]) => (l.length <= 2 ? l.map((s) => s.name).join(' and ') : `${l[0].name} and ${l.length - 1} more`);
|
||||
|
||||
const headline = $derived(
|
||||
needs.length ? `${num(needs.length)} ${needs.length === 1 ? 'thing needs' : 'things need'} you.` : later.length ? 'Nothing needs you right now.' : 'All quiet. Nothing needs you.'
|
||||
);
|
||||
const customers = $derived(
|
||||
!customer.length ? '' : custDown.length ? `${names(custDown)} ${custDown.length === 1 ? 'is' : 'are'} down for customers.` : custHurt.length ? `Customers may notice trouble with ${names(custHurt)}.` : 'Customers aren’t affected.'
|
||||
);
|
||||
const subline = $derived.by(() => {
|
||||
const parts: string[] = [];
|
||||
if (total) parts.push(reporting === total ? `All ${total} hosts are reporting` : `${reporting} of ${total} hosts are reporting, ${total - reporting} gone quiet`);
|
||||
if (services.length) parts.push(working === services.length ? 'every service is working' : `${working} of ${services.length} services are fully working`);
|
||||
let s = parts.join(', and ');
|
||||
if (s) s = s[0].toUpperCase() + s.slice(1) + '.';
|
||||
if (!needs.length && later.length) s += ` ${num(later.length)} ${later.length === 1 ? 'thing' : 'things'} can wait.`;
|
||||
return s.trim();
|
||||
});
|
||||
|
||||
const hello = $derived(hour(now) < 12 ? 'Good morning' : hour(now) < 18 ? 'Good afternoon' : 'Good evening');
|
||||
const firstName = $derived((live.session?.user ?? '').split(' ')[0]);
|
||||
const dayFmt = new Intl.DateTimeFormat(undefined, { weekday: 'long', month: 'long', day: 'numeric' });
|
||||
const checked = $derived(live.updated ? Math.max(0, Math.round((now - live.updated) / 1000)) : -1);
|
||||
|
||||
// "I'm on it" is the acknowledgement: the repeats stop and everyone sees who has it.
|
||||
const canAck = $derived(live.seesAll && !live.session?.demo);
|
||||
let busy = $state('');
|
||||
let error = $state('');
|
||||
async function onIt(a: Attention) {
|
||||
if (!a.incident) return;
|
||||
busy = a.incident.id;
|
||||
error = '';
|
||||
try {
|
||||
await post(`/api/v1/incidents/${encodeURIComponent(a.incident.id)}/ack`);
|
||||
await live.refresh();
|
||||
} catch (e) {
|
||||
error = String(e);
|
||||
} finally {
|
||||
busy = '';
|
||||
}
|
||||
}
|
||||
|
||||
const outcome = (e: TodayEvent): [string, string] =>
|
||||
!e.resolved ? (e.ack_by ? [`${e.ack_by} is on it`, 'warning'] : ['Still open', e.severity === 'critical' ? 'critical' : 'warning']) : e.ack_by ? ['Fixed', 'good'] : ['Fixed itself', 'good'];
|
||||
const upPct = (p: number) => (p < 0 ? '–' : p >= 99.995 ? '100%' : p.toFixed(2) + '%');
|
||||
const days = (d: number) => (d < 1 ? 'within a day' : `in about ${Math.round(d)} ${Math.round(d) === 1 ? 'day' : 'days'}`);
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Cairn OBS · Dashboard</title></svelte:head>
|
||||
<svelte:head><title>Cairn OBS · Today</title></svelte:head>
|
||||
|
||||
<div class="greet">
|
||||
<div class="gridbg"></div>
|
||||
<div class="glow"></div>
|
||||
<div class="in">
|
||||
<div class="hello">
|
||||
<span class="mk"><Mark size={32} /></span>
|
||||
<div>
|
||||
<h1>{hello}{firstName ? ', ' + firstName : ''}</h1>
|
||||
<p>Here's how your systems are doing.</p>
|
||||
</div>
|
||||
<div class="today">
|
||||
<header class="lead">
|
||||
<div class="words">
|
||||
<p class="hi">{hello}{firstName ? ', ' + firstName : ''} · {dayFmt.format(now)}</p>
|
||||
{#if o}
|
||||
<h1>{headline} {#if needs.length}<span class="cust">{customers}</span>{/if}</h1>
|
||||
{#if subline || (!needs.length && customers)}<p class="subline">{!needs.length && customers ? customers + ' ' : ''}{subline}</p>{/if}
|
||||
{:else}
|
||||
<h1>Looking…</h1>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="ctl">
|
||||
<span class="pillc">{reporting}/{total} hosts reporting</span>
|
||||
<div class="clock"><b>{hms(now)}</b><small>{zone(now)} · {utc(now)}</small></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="live" class:stale={!!live.error}>
|
||||
<i></i>{live.error ? live.error : checked < 0 ? 'Connecting' : checked < 3 ? 'Live · checked just now' : `Live · checked ${checked} s ago`}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{#if o}
|
||||
<section aria-labelledby="attn">
|
||||
<div class="attn-h">
|
||||
<span class="ping" class:crit class:clear={o.attention.length === 0}><i></i></span>
|
||||
<h2 id="attn">{o.attention.length ? `Needs attention · ${o.attention.length}` : 'All clear'}</h2>
|
||||
<span class="rule"></span>
|
||||
</div>
|
||||
{#if o.attention.length}
|
||||
<div class="attn">
|
||||
{#each o.attention.slice(0, 6) as a}
|
||||
<a class="acard {a.severity}" href={a.href}>
|
||||
<div class="body"><Status s={a.severity} /><div class="t">{a.title}</div>{#if a.detail}<p>{a.detail}</p>{/if}</div>
|
||||
<span class="arrow"><Icon name="arrow" /></span>
|
||||
</a>
|
||||
{#if o}
|
||||
{#if error}<p class="err" role="alert">{error}</p>{/if}
|
||||
|
||||
{#if needs.length || taken.length}
|
||||
<section aria-labelledby="needs">
|
||||
<div class="sh">
|
||||
<h2 id="needs">Needs you{#if needs.length}<span> · {needs.length}</span>{/if}</h2>
|
||||
<p>Worst first. {needs.length ? 'Nobody has picked these up yet.' : 'Everything urgent has someone on it.'}</p>
|
||||
</div>
|
||||
{#each needs as a (a.key || a.title)}
|
||||
<article class="card need {a.severity}">
|
||||
<div class="meta">
|
||||
<Status s={a.severity} />
|
||||
<span>
|
||||
{a.host ? a.host + ' · ' : ''}{a.incident ? 'started ' + ago(a.incident.opened, now) : 'just now'}{a.incident?.fired ? ' · people were told' : ''}
|
||||
</span>
|
||||
</div>
|
||||
<h3>{a.title}</h3>
|
||||
{#if a.detail}<p class="why">{a.detail}</p>{/if}
|
||||
{#if a.affected}<p class="touch"><b>What it touches</b> {a.affected}</p>{/if}
|
||||
<div class="acts">
|
||||
{#if a.incident && canAck}
|
||||
<button class="btn pri big" disabled={busy === a.incident.id} onclick={() => onIt(a)}>{busy === a.incident.id ? 'Saving…' : 'I’m on it'}</button>
|
||||
{:else if a.incident && live.session?.demo}
|
||||
<button class="btn pri big" disabled title="The demo changes nothing">I’m on it</button>
|
||||
{/if}
|
||||
<a class="btn big" href={a.href}>Open</a>
|
||||
{#if a.incident}<a class="btn big ghost" href="/alerts?q={encodeURIComponent(a.incident.id)}">{a.incident.id}</a>{/if}
|
||||
</div>
|
||||
</article>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="foot-note clearline">Every host is reporting, no disk is past 80%, and every container is where it should be.</p>
|
||||
{#if taken.length}
|
||||
<div class="taken">
|
||||
<h3>Being handled · {taken.length}</h3>
|
||||
<ul>
|
||||
{#each taken as a (a.key || a.title)}
|
||||
<li>
|
||||
<span class="sev {a.severity}" title={a.severity}><Icon name={a.severity} size={16} /></span>
|
||||
<a href={a.href}>{a.title}</a>
|
||||
<span class="who">{a.incident?.ack?.by} is on it · {ago(a.incident?.ack?.at ?? now, now)}</span>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<Panel title="Vital signs" aside="right now">
|
||||
<div class="gauges">
|
||||
<Gauge value={total ? reporting / total : 0} reading={reporting} unit="/{total}" label="Hosts reporting" detail={reporting === total ? 'all agents heard from' : `${total - reporting} silent or waiting`} tone={reporting === total ? 'data' : 'critical'} />
|
||||
<Gauge value={(busiest?.cpu_pct ?? 0) / 100} reading={Math.round(busiest?.cpu_pct ?? 0)} unit="%" label="Busiest CPU" detail={busiest?.host ?? '—'} bands={[{ from: 0.85, to: 1, tone: 'critical' }]} />
|
||||
<Gauge value={(fullest?.pct ?? 0) / 100} reading={Math.round(fullest?.pct ?? 0)} unit="%" label="Fullest disk" detail={fullest ? `${fullest.host} ${fullest.mount}` : '—'} tone={(fullest?.pct ?? 0) >= 90 ? 'critical' : (fullest?.pct ?? 0) >= 80 ? 'warning' : 'data'} bands={[{ from: 0.8, to: 0.9, tone: 'warning' }, { from: 0.9, to: 1, tone: 'critical' }]} />
|
||||
<Gauge value={c && c.running + c.problems ? c.running / (c.running + c.problems) : 0} reading={c?.running ?? 0} unit="/{(c?.running ?? 0) + (c?.problems ?? 0)}" label="Containers fine" detail={c?.problems ? `${c.problems} need a look` : 'all where they should be'} tone={c?.problems ? 'warning' : 'data'} />
|
||||
</div>
|
||||
</Panel>
|
||||
{#if later.length}
|
||||
<section aria-labelledby="later">
|
||||
<div class="sh">
|
||||
<h2 id="later">Can wait<span> · {later.length}</span></h2>
|
||||
<p>Worth a look today. None of these is hurting anything yet.</p>
|
||||
</div>
|
||||
<ul class="card rows">
|
||||
{#each later.slice(0, 6) as a (a.key || a.title)}
|
||||
<li>
|
||||
<span class="ic"><span class="sev {a.severity}" title={a.severity}><Icon name={a.severity} size={16} /></span></span>
|
||||
<span class="txt"><b>{a.title}</b>{#if a.detail}<small>{a.detail}</small>{/if}</span>
|
||||
{#if a.incident}<span class="age">{duration((now - new Date(a.incident.opened).getTime()) / 1000)}</span>{/if}
|
||||
<a class="open" href={a.href}>Open</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{#if later.length > 6}<a class="more" href="/alerts">And {later.length - 6} more on the Alerts page</a>{/if}
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<div class="mt">
|
||||
<Panel title="Hosts" aside={total > hosts.length ? `the ${hosts.length} most in need, of ${total}` : 'cpu · last hour'} href={total > hosts.length ? '/hosts' : undefined} hrefLabel="All hosts">
|
||||
<div class="hostrow">
|
||||
{#each hosts as h (h.name)}
|
||||
<a class="hcard" href="/hosts/{h.name}">
|
||||
<div class="hh"><b>{h.name}</b><span class="os">{h.os ?? ''}</span><span class="st"><Status s={h.status} word={h.word} /></span></div>
|
||||
{#if h.last_seen}
|
||||
<div class="meters">
|
||||
<Meter label="CPU" value={h.cpu_pct} warn={85} crit={95} />
|
||||
<Meter label="Memory" value={h.mem_pct} warn={90} crit={95} />
|
||||
<Meter label="Fullest disk" value={h.fullest?.pct ?? 0} />
|
||||
<Meter label="Swap" value={h.swap_pct} warn={50} crit={80} />
|
||||
</div>
|
||||
<Spark data={h.history.cpu} max={100} label="{h.name} CPU, last hour" />
|
||||
<div class="foot"><span>OUT {rate(h.net.tx_bps)}</span><span>IN {rate(h.net.rx_bps)}</span><span>UP {duration(h.uptime_s)}</span></div>
|
||||
{:else}
|
||||
<p class="foot-note">No report yet. Is its agent running?</p>
|
||||
{/if}
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
{#if !needs.length && !later.length && !taken.length}
|
||||
<section class="card calm" aria-label="Nothing needs you">
|
||||
<span class="big-ok"><Icon name="good" size={36} /></span>
|
||||
<div>
|
||||
<h2>Nothing needs you right now</h2>
|
||||
<p>Cairn OBS tells the alert channels if that changes.{watch?.filling.length ? ` Next to look at: ${watch.filling[0].host}'s ${watch.filling[0].mount}, which fills ${days(watch.filling[0].full_days)}.` : ''}</p>
|
||||
</div>
|
||||
<a href="/reports">This week’s report</a>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if o.clusters?.length}
|
||||
<div class="mt">
|
||||
<Panel title="Clusters" href="/clusters" hrefLabel="All clusters">
|
||||
<div class="clist">
|
||||
{#each o.clusters as k (k.name)}
|
||||
<a class="crow" href="/workloads?source={encodeURIComponent(k.name)}{k.problems ? '&show=problems' : ''}">
|
||||
<b class="mono">{k.name}</b>
|
||||
<Status s={k.status} word={k.word} />
|
||||
<span class="sub">{k.version ?? ''}</span>
|
||||
<span class="sub sum">{k.summary}</span>
|
||||
{#if services.length}
|
||||
<section aria-labelledby="svc">
|
||||
<div class="sh">
|
||||
<h2 id="svc">Your services</h2>
|
||||
<p>Last 24 hours, one bar per half hour · <a href="/map/services">Service map</a></p>
|
||||
</div>
|
||||
<div class="tiles">
|
||||
{#each services as s (s.id)}
|
||||
<a class="card tile" href="/services?s={encodeURIComponent(s.id)}">
|
||||
<b>{s.name}</b>
|
||||
<Status s={s.status} word={s.status === 'good' ? 'Working' : s.word} />
|
||||
<Strip cells={s.history.cells} name={s.name} />
|
||||
<small>{s.history.pct_24h < 0 ? 'No history yet' : `Up ${upPct(s.history.pct_24h)} today · ${upPct(s.history.pct_30d)} in 30 days`}</small>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if c}
|
||||
<div class="mt">
|
||||
<Panel title="Containers" href="/containers" hrefLabel="All containers">
|
||||
<div class="csum">
|
||||
<div><b>{c.running}</b><span>running fine</span></div>
|
||||
<div class:bad={c.problems > 0}><b>{c.problems}</b><span>need a look</span></div>
|
||||
<div><b>{c.stopped}</b><span>stopped on purpose</span></div>
|
||||
<div><b>{c.ci}</b><span>CI jobs now</span></div>
|
||||
{#if today}
|
||||
<section aria-labelledby="since">
|
||||
<div class="sh">
|
||||
<h2 id="since">Since you last looked</h2>
|
||||
<p>{today.last_visit ? `You were last here ${ago(today.since, now)}, at ${hm(today.since)}` : 'The last 12 hours'}</p>
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
{#if today.events.length}
|
||||
<ol class="card rows events">
|
||||
{#each today.events as e (e.id)}
|
||||
{@const [word, tone] = outcome(e)}
|
||||
<li>
|
||||
<time class="mono" datetime={e.at}>{hm(e.at)}</time>
|
||||
<span class="ic sev {e.severity}" title={e.severity}><Icon name={e.severity} size={16} /></span>
|
||||
<span class="txt">{#if e.href}<a href={e.href}>{e.title}</a>{:else}{e.title}{/if}</span>
|
||||
<span class="out {tone}">{word}</span>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
<p class="foot">
|
||||
{today.opened} opened, {today.resolved} closed{today.fixed_itself ? ` (${today.fixed_itself} on their own)` : ''}. {today.told ? `${today.told} ${today.told === 1 ? 'alert' : 'alerts'} went out to people.` : 'Nobody was alerted.'}
|
||||
{#if today.opened + today.resolved > today.events.length}<a href="/alerts">Everything on the Alerts page</a>{/if}
|
||||
</p>
|
||||
{:else}
|
||||
<p class="card quiet">Nothing opened or closed since then.</p>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<section aria-labelledby="fleet">
|
||||
<div class="sh">
|
||||
<h2 id="fleet">The fleet</h2>
|
||||
<p><a href="/hosts">All hosts</a>{#if clusters.length} · <a href="/clusters">Clusters</a>{/if}</p>
|
||||
</div>
|
||||
<div class="facts">
|
||||
<a class="card fact" href="/hosts"><b>{reporting} of {total}</b><span>hosts reporting</span></a>
|
||||
{#if c}<a class="card fact" href="/containers"><b>{c.running + c.problems}</b><span>{c.problems ? `containers, ${c.problems} need a look` : 'containers, all where they should be'}</span></a>{/if}
|
||||
{#if clusters.length}<a class="card fact" href="/clusters"><b>{clusters.length} {clusters.length === 1 ? 'cluster' : 'clusters'}</b><span>{clusterTrouble ? `${clusterTrouble} with a problem` : 'all healthy'}</span></a>{/if}
|
||||
{#if o.fleet?.busiest}<a class="card fact" href="/hosts/{o.fleet.busiest.host}"><b>{Math.round(o.fleet.busiest.cpu_pct)}% CPU</b><span>busiest host, {o.fleet.busiest.host}</span></a>{/if}
|
||||
</div>
|
||||
{#if watch && (watch.filling.length || watch.busier.length || watch.restarted_n)}
|
||||
<div class="card watch">
|
||||
<h3>Worth watching</h3>
|
||||
<ul>
|
||||
{#each watch.filling as d (d.host + d.mount)}
|
||||
<li><a class="mono" href="/hosts/{d.host}">{d.host}</a> <span>{d.mount} is {Math.round(d.pct)}% full and fills {days(d.full_days)}</span></li>
|
||||
{/each}
|
||||
{#each watch.busier as b (b.host + b.what)}
|
||||
<li><a class="mono" href="/hosts/{b.host}">{b.host}</a> <span>{b.what === 'cpu' ? 'CPU' : 'memory'} at {Math.round(b.now)}%, usually {Math.round(b.usual)}% at this hour</span></li>
|
||||
{/each}
|
||||
{#if watch.restarted_n}
|
||||
<li>
|
||||
<span>{watch.restarted_n === 1 ? 'Restarted' : `${watch.restarted_n} hosts restarted`} in the last day:</span>
|
||||
{#each watch.restarted as r, i (r.host)}{i ? ', ' : ' '}<a class="mono" href="/hosts/{r.host}">{r.host}</a> <span class="sub">{duration(r.up_s)} ago</span>{/each}{watch.restarted_n > watch.restarted.length ? ` and ${watch.restarted_n - watch.restarted.length} more` : ''}
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
{:else}
|
||||
<p class="empty">Loading…</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.greet { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--card); box-shadow: var(--shadow-soft); margin-bottom: 20px; }
|
||||
.gridbg { position: absolute; inset: 0; opacity: .6; pointer-events: none; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 24px 24px; mask-image: linear-gradient(90deg, transparent, #000 45%, #000); }
|
||||
.glow { position: absolute; left: -96px; top: -96px; width: 256px; height: 256px; border-radius: 50%; background: color-mix(in oklab, var(--primary) 18%, transparent); filter: blur(48px); pointer-events: none; }
|
||||
.in { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; flex-wrap: wrap; }
|
||||
.hello { display: flex; align-items: center; gap: 16px; min-width: 0; }
|
||||
.mk { width: 48px; height: 48px; flex: none; border-radius: 8px; display: grid; place-items: center; background: color-mix(in oklab, var(--primary) 14%, transparent); }
|
||||
.greet h1 { font-size: 24px; }
|
||||
.greet p { margin: 0; color: var(--muted-fg); }
|
||||
.ctl { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
|
||||
.pillc { padding: 5px 10px; border-radius: 20px; border: 1px solid color-mix(in oklab, var(--primary) 45%, transparent); color: var(--primary); font: 600 10px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
|
||||
.clock { text-align: right; }
|
||||
.clock b { display: block; font: 600 22px var(--mono); line-height: 1.1; }
|
||||
.clock small { display: block; font: 500 10px var(--mono); letter-spacing: .14em; color: var(--muted-fg); text-transform: uppercase; }
|
||||
.today { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 40px; font-size: 15px; padding-bottom: 48px; }
|
||||
.lead { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: flex-start; padding-top: 8px; }
|
||||
.words { display: flex; flex-direction: column; gap: 10px; max-width: 800px; min-width: 0; }
|
||||
.hi { margin: 0; color: var(--muted-fg); }
|
||||
.lead h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.18; letter-spacing: -.01em; }
|
||||
.lead h1 .cust { color: var(--muted-fg); font-weight: 500; }
|
||||
.subline { margin: 0; font-size: 17px; color: color-mix(in oklab, var(--foreground) 82%, var(--muted-fg)); }
|
||||
.live { margin: 0; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted-fg); font-size: 13px; }
|
||||
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
|
||||
.live.stale i { background: var(--critical); }
|
||||
.err { margin: 0; color: var(--critical); }
|
||||
.sev { display: inline-flex; color: var(--muted-fg); }
|
||||
.sev.good { color: var(--good); } .sev.warning { color: var(--warning); } .sev.serious { color: var(--serious); } .sev.critical { color: var(--critical); }
|
||||
|
||||
.attn-h { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
|
||||
.attn-h h2 { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
|
||||
.rule { height: 1px; flex: 1; background: linear-gradient(90deg, var(--border), transparent); }
|
||||
.ping { display: inline-flex; color: var(--warning); }
|
||||
.ping.crit { color: var(--critical); }
|
||||
.ping.clear { color: var(--good); }
|
||||
.ping i { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
|
||||
.ping i::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: currentColor; animation: ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; }
|
||||
.ping.clear i::after { animation: none; }
|
||||
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
|
||||
.attn { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
|
||||
.clearline { margin: 0 0 20px; }
|
||||
.acard { position: relative; flex: 1 1 260px; min-width: 0; display: flex; align-items: flex-start; gap: 12px; overflow: hidden; padding: 14px 16px 14px 20px; border-radius: var(--radius); border: 1px solid color-mix(in oklab, var(--warning) 50%, transparent); background: var(--card); box-shadow: var(--shadow-soft); color: var(--foreground); transition: transform .15s; }
|
||||
.acard:hover { transform: translateY(-2px); }
|
||||
.acard::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--warning); }
|
||||
.acard.critical { border-color: color-mix(in oklab, var(--critical) 55%, transparent); }
|
||||
.acard.critical::before { background: var(--critical); }
|
||||
.acard .body { min-width: 0; flex: 1; }
|
||||
.acard .t { font-weight: 600; margin-top: 4px; }
|
||||
.acard p { margin: 4px 0 0; font-size: 12px; color: var(--muted-fg); }
|
||||
.arrow { color: var(--muted-fg); }
|
||||
section { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
|
||||
.sh { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
|
||||
.sh h2 { font-size: 21px; }
|
||||
.sh h2 span { color: var(--muted-fg); font-weight: 400; }
|
||||
.sh p { margin: 0; color: var(--muted-fg); font-size: 14px; }
|
||||
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-soft); }
|
||||
|
||||
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px 16px; }
|
||||
.hostrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
|
||||
.hcard { display: block; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--foreground); background: color-mix(in oklab, var(--muted) 35%, var(--card)); }
|
||||
.hcard:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
|
||||
.hh { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-width: 0; }
|
||||
.hh b { font-size: 16px; }
|
||||
.os { color: var(--muted-fg); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
||||
.hh .st { margin-left: auto; }
|
||||
.hcard :global(.spark) { margin-top: 12px; }
|
||||
.foot { display: flex; gap: 12px; margin-top: 8px; font: 500 11px var(--mono); color: var(--muted-fg); flex-wrap: wrap; }
|
||||
.csum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
|
||||
.csum div { display: flex; flex-direction: column; }
|
||||
.csum b { font: 600 26px var(--mono); }
|
||||
.csum span { color: var(--muted-fg); font-size: 12px; }
|
||||
.csum .bad b { color: var(--critical); }
|
||||
.clist { display: grid; gap: 6px; }
|
||||
.crow { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(140px, 1.4fr) minmax(60px, .8fr) 2fr; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--foreground); }
|
||||
.crow:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
|
||||
@media (max-width: 700px) { .crow { grid-template-columns: 1fr 1fr; } .crow .sum { grid-column: 1 / -1; } }
|
||||
@media (max-width: 860px) { .clock { text-align: left; } .csum { grid-template-columns: 1fr 1fr; } }
|
||||
.need { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
|
||||
.need.critical { border-color: color-mix(in oklab, var(--critical) 45%, var(--border)); }
|
||||
.need.serious { border-color: color-mix(in oklab, var(--serious) 45%, var(--border)); }
|
||||
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--muted-fg); font-size: 14px; }
|
||||
.need h3 { font-size: 22px; line-height: 1.3; }
|
||||
.why { margin: 0; max-width: 75ch; color: color-mix(in oklab, var(--foreground) 85%, var(--muted-fg)); font-size: 16px; }
|
||||
.touch { margin: 0; font-size: 15px; }
|
||||
.touch b { color: var(--muted-fg); font-weight: 500; margin-right: 6px; }
|
||||
.acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
|
||||
.btn.big { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 8px; }
|
||||
.btn.pri.big { font-weight: 700; }
|
||||
.btn.ghost { background: transparent; color: var(--muted-fg); }
|
||||
|
||||
.taken { padding: 4px 4px 0; }
|
||||
.taken h3 { font-size: 15px; color: var(--muted-fg); font-weight: 600; margin-bottom: 6px; }
|
||||
.taken ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
||||
.taken li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
|
||||
.taken a { color: var(--foreground); }
|
||||
.who { color: var(--muted-fg); font-size: 14px; }
|
||||
|
||||
.rows { list-style: none; margin: 0; padding: 0; overflow: hidden; }
|
||||
.rows li { display: flex; gap: 14px; align-items: baseline; padding: 14px 20px; border-top: 1px solid var(--border); min-width: 0; }
|
||||
.rows li:first-child { border-top: 0; }
|
||||
.rows .ic { flex: none; align-self: flex-start; padding-top: 1px; }
|
||||
.rows .txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.rows .txt b { font-weight: 600; }
|
||||
.rows .txt small { color: var(--muted-fg); font-size: 14px; }
|
||||
.rows .age { flex: none; color: var(--muted-fg); font-size: 14px; white-space: nowrap; }
|
||||
.rows .open { flex: none; font-weight: 600; font-size: 14px; }
|
||||
.more { align-self: flex-start; }
|
||||
|
||||
.calm { padding: 26px; display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
|
||||
.calm div { flex: 1 1 320px; }
|
||||
.calm h2 { font-size: 21px; }
|
||||
.calm p { margin: 6px 0 0; color: color-mix(in oklab, var(--foreground) 85%, var(--muted-fg)); }
|
||||
.big-ok { color: var(--good); display: inline-flex; }
|
||||
|
||||
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
|
||||
.tile { display: flex; flex-direction: column; gap: 10px; padding: 16px; color: var(--foreground); min-width: 0; }
|
||||
.tile:hover { border-color: color-mix(in oklab, var(--primary) 50%, var(--border)); }
|
||||
.tile b { font-size: 16px; }
|
||||
.tile small { color: var(--muted-fg); font-size: 13px; }
|
||||
|
||||
.events time { flex: 0 0 52px; color: var(--data); font-size: 14px; }
|
||||
.events .txt a { color: var(--foreground); }
|
||||
.events .out { flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
|
||||
.out.good { color: var(--good); } .out.warning { color: var(--warning); } .out.critical { color: var(--critical); }
|
||||
.foot { margin: 0; color: var(--muted-fg); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
|
||||
.quiet { margin: 0; padding: 16px 20px; color: var(--muted-fg); }
|
||||
|
||||
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
|
||||
.fact { padding: 16px 20px; color: var(--foreground); display: flex; flex-direction: column; gap: 2px; }
|
||||
.fact:hover { border-color: color-mix(in oklab, var(--primary) 50%, var(--border)); }
|
||||
.fact b { font: 600 26px var(--sans); color: var(--data); }
|
||||
.fact span { color: color-mix(in oklab, var(--foreground) 85%, var(--muted-fg)); }
|
||||
.watch { padding: 18px 20px; }
|
||||
.watch h3 { font-size: 16px; margin-bottom: 8px; }
|
||||
.watch ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
|
||||
.watch li span { color: color-mix(in oklab, var(--foreground) 85%, var(--muted-fg)); }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.today { gap: 32px; }
|
||||
.need { padding: 18px; }
|
||||
.acts .btn.pri.big { flex: 1 1 100%; justify-content: center; }
|
||||
.rows li { padding: 12px 14px; flex-wrap: wrap; row-gap: 4px; }
|
||||
.rows .txt { flex-basis: calc(100% - 40px); }
|
||||
.rows .age { margin-left: 30px; }
|
||||
.events time { flex-basis: 44px; }
|
||||
}
|
||||
</style>
|
||||
@@ -2,12 +2,22 @@
|
||||
import Icon from '$lib/Icon.svelte';
|
||||
import Status from '$lib/Status.svelte';
|
||||
import Pager from '$lib/Pager.svelte';
|
||||
import FleetGrid from '$lib/FleetGrid.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { get, SignedOut, type HostRow } from '$lib/api';
|
||||
import { live } from '$lib/live.svelte';
|
||||
import { ago, pct } from '$lib/format';
|
||||
|
||||
// The hosts list, filtered and paged by obs-beacond: a fleet can be
|
||||
// thousands of hosts.
|
||||
// Squares by site and role first (#72); the list, filtered and paged by
|
||||
// obs-beacond, a click away: a fleet can be thousands of hosts.
|
||||
const view = $derived(page.url.searchParams.get('view') === 'list' ? 'list' : 'grid');
|
||||
function setView(v: string) {
|
||||
const u = new URL(page.url);
|
||||
if (v === 'list') u.searchParams.set('view', 'list');
|
||||
else u.searchParams.delete('view');
|
||||
void goto(u, { replaceState: true, noScroll: true, keepFocus: true });
|
||||
}
|
||||
const limit = 100;
|
||||
let rows = $state<HostRow[]>([]);
|
||||
let total = $state(0);
|
||||
@@ -41,6 +51,7 @@
|
||||
}
|
||||
}
|
||||
$effect(() => {
|
||||
if (view !== 'list') return;
|
||||
const args = [q, status, offset] as const;
|
||||
void load(...args);
|
||||
const t = setInterval(() => void load(...args), 10_000);
|
||||
@@ -62,10 +73,20 @@
|
||||
|
||||
<div class="phead">
|
||||
<span class="tile"><Icon name="hosts" /></span>
|
||||
<div><h1>Hosts</h1><p>Every host with an agent, the ones that need a look first. Adding and removing hosts is under Configure.</p></div>
|
||||
{#if live.seesAll}<div class="acts"><a class="btn sm" href="/configure/hosts"><Icon name="settings" /> Configure</a></div>{/if}
|
||||
<div><h1>Hosts</h1><p>Every host with an agent, grouped by site and role so the odd one out stands out. Adding and removing hosts is under Configure.</p></div>
|
||||
<div class="acts">
|
||||
<span role="group" aria-label="Show as" class="views">
|
||||
<button class="chip" class:on={view === 'grid'} aria-pressed={view === 'grid'} onclick={() => setView('grid')}>By site</button>
|
||||
<button class="chip" class:on={view === 'list'} aria-pressed={view === 'list'} onclick={() => setView('list')}>List</button>
|
||||
</span>
|
||||
{#if live.seesAll}<a class="btn sm" href="/configure/hosts"><Icon name="settings" /> Configure</a>{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if view === 'grid'}
|
||||
<FleetGrid />
|
||||
{:else}
|
||||
|
||||
{#if error}<p class="foot-note" style="color:var(--critical)">{error}</p>{/if}
|
||||
|
||||
<div class="filters">
|
||||
@@ -97,8 +118,10 @@
|
||||
</table>
|
||||
</div>
|
||||
<Pager bind:offset {limit} {total} what="hosts" />
|
||||
{/if}
|
||||
<p class="foot-note">Refreshes every 10 seconds.</p>
|
||||
|
||||
<style>
|
||||
.bad { color: var(--critical); }
|
||||
.views { display: inline-flex; gap: 6px; }
|
||||
</style>
|
||||
@@ -0,0 +1,227 @@
|
||||
<script lang="ts">
|
||||
// Every service as rows, grouped by who depends on it (#71): its state in
|
||||
// words, its last 24 hours and its month, and for the one picked what
|
||||
// it's made of, what it needs and what breaks if it goes. The service
|
||||
// map's side panel as a page you can scan.
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import Icon from '$lib/Icon.svelte';
|
||||
import Status from '$lib/Status.svelte';
|
||||
import Strip from '$lib/Strip.svelte';
|
||||
import { get, type ServiceHistory, type Severity } from '$lib/api';
|
||||
|
||||
interface Signal { kind: string; name: string; host?: string; status: Severity; word: string; href?: string }
|
||||
interface Service { id: string; name: string; tier: string; needs: string[]; needed_by: string[]; status: Severity; word: string; signals: Signal[]; history: ServiceHistory }
|
||||
|
||||
let services = $state<Service[] | null>(null);
|
||||
let topology = $state(true);
|
||||
let error = $state('');
|
||||
async function load() {
|
||||
try {
|
||||
const r = await get<{ services: Service[]; topology: boolean }>('/api/v1/services');
|
||||
services = r.services;
|
||||
topology = r.topology;
|
||||
error = '';
|
||||
} catch (e) {
|
||||
error = String(e);
|
||||
}
|
||||
}
|
||||
$effect(() => {
|
||||
void load();
|
||||
const t = setInterval(() => void load(), 10000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
|
||||
const TIERS: [string, string, string][] = [
|
||||
['public', 'What customers use', 'when these break, people notice'],
|
||||
['apps', 'What runs it', 'the machinery behind those'],
|
||||
['data', 'Where the data lives', 'slow to fix, so watched closest'],
|
||||
['edge', 'At the edge', 'the outside services everything goes through']
|
||||
];
|
||||
const bad = (s: { status: Severity }) => s.status === 'warning' || s.status === 'serious' || s.status === 'critical';
|
||||
|
||||
const show = $derived(page.url.searchParams.get('show') ?? '');
|
||||
const picked = $derived(page.url.searchParams.get('s') ?? '');
|
||||
const all = $derived(services ?? []);
|
||||
const troubled = $derived(all.filter(bad).length);
|
||||
const shown = $derived(all.filter((s) => (show === 'problems' ? bad(s) : show === 'working' ? !bad(s) : true)));
|
||||
const tiers = $derived.by(() => {
|
||||
const known = new Set(TIERS.map((t) => t[0]));
|
||||
const out = TIERS.map(([id, name, blurb]) => ({ id, name, blurb, rows: shown.filter((s) => s.tier === id) }));
|
||||
const rest = shown.filter((s) => !known.has(s.tier));
|
||||
if (rest.length) out.push({ id: 'other', name: 'Other services', blurb: '', rows: rest });
|
||||
return out.filter((t) => t.rows.length);
|
||||
});
|
||||
// The one picked, else the worst, else the first.
|
||||
const sel = $derived(
|
||||
all.find((s) => s.id === picked) ??
|
||||
[...all].sort((a, b) => rank(b.status) - rank(a.status))[0]
|
||||
);
|
||||
const byId = $derived(new Map(all.map((s) => [s.id, s])));
|
||||
function rank(s: Severity) {
|
||||
return ({ critical: 5, serious: 4, warning: 3, waiting: 2, off: 1, good: 0 } as Record<string, number>)[s] ?? 0;
|
||||
}
|
||||
|
||||
function setParam(k: string, v: string) {
|
||||
const u = new URL(page.url);
|
||||
if (v) u.searchParams.set(k, v);
|
||||
else u.searchParams.delete(k);
|
||||
void goto(u, { replaceState: true, noScroll: true, keepFocus: true });
|
||||
}
|
||||
|
||||
// What it's made of: the parts in trouble by name, the rest counted, so
|
||||
// a service with hundreds of containers stays readable.
|
||||
const parts = $derived.by(() => {
|
||||
if (!sel) return { trouble: [] as Signal[], fine: [] as Signal[], groups: [] as [string, number][] };
|
||||
const trouble = sel.signals.filter(bad);
|
||||
const fine = sel.signals.filter((g) => !bad(g));
|
||||
const counts = new Map<string, number>();
|
||||
for (const g of fine) counts.set(g.kind, (counts.get(g.kind) ?? 0) + 1);
|
||||
return { trouble, fine, groups: [...counts.entries()] };
|
||||
});
|
||||
const KIND: Record<string, [string, string]> = { check: ['check', 'checks'], container: ['container', 'containers'], unit: ['unit', 'units'], cloudflare: ['Cloudflare zone', 'Cloudflare zones'] };
|
||||
const kindWord = (k: string, n: number) => (KIND[k] ? KIND[k][n === 1 ? 0 : 1] : k);
|
||||
const upPct = (p: number) => (p < 0 ? 'no history yet' : p >= 99.995 ? '100%' : p.toFixed(2) + '%');
|
||||
const stateWord = (s: { status: Severity; word: string }) => (s.status === 'good' ? 'Working' : s.word);
|
||||
const heading = $derived.by(() => {
|
||||
if (!all.length) return '';
|
||||
const crit = all.filter((s) => s.status === 'critical').length;
|
||||
const look = troubled - crit;
|
||||
const ok = all.length - troubled;
|
||||
const bits = [`${ok} working`];
|
||||
if (look) bits.push(`${look} worth a look`);
|
||||
if (crit) bits.push(`${crit} down`);
|
||||
return `${all.length} services. ${bits.join(', ')}.`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Cairn OBS · Services</title></svelte:head>
|
||||
|
||||
<div class="page">
|
||||
<div class="phead">
|
||||
<div class="tile"><Icon name="services" /></div>
|
||||
<div>
|
||||
<h1>{heading || 'Services'}</h1>
|
||||
<p>Grouped by who depends on them. Pick one to see what it’s made of and what breaks if it goes.</p>
|
||||
</div>
|
||||
{#if all.length}
|
||||
<div class="acts" role="group" aria-label="Show">
|
||||
<button class="chip" class:on={!show} aria-pressed={!show} onclick={() => setParam('show', '')}>All <b>{all.length}</b></button>
|
||||
<button class="chip" class:on={show === 'problems'} aria-pressed={show === 'problems'} onclick={() => setParam('show', 'problems')}>Needs a look <b>{troubled}</b></button>
|
||||
<button class="chip" class:on={show === 'working'} aria-pressed={show === 'working'} onclick={() => setParam('show', 'working')}>Working <b>{all.length - troubled}</b></button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if error}<p class="err" role="alert">{error}</p>{/if}
|
||||
|
||||
{#if services === null}
|
||||
<p class="empty">Loading…</p>
|
||||
{:else if !topology || !all.length}
|
||||
<p class="empty">No services yet. Services come from the service map: declare them in topology.yaml, or correct what the map found (docs/maps.md).</p>
|
||||
{:else}
|
||||
<div class="split">
|
||||
<div class="list">
|
||||
{#each tiers as t (t.id)}
|
||||
<section aria-labelledby="tier-{t.id}">
|
||||
<h2 id="tier-{t.id}">{t.name}{#if t.blurb}<span> · {t.blurb}</span>{/if}</h2>
|
||||
<div class="box">
|
||||
{#each t.rows as s (s.id)}
|
||||
<button class="row" class:on={sel?.id === s.id} aria-pressed={sel?.id === s.id} onclick={() => setParam('s', s.id)}>
|
||||
<span class="st"><Status s={s.status} word={stateWord(s)} /></span>
|
||||
<span class="nm"><b>{s.name}</b><small>{s.needs.length ? 'needs ' + s.needs.map((n) => byId.get(n)?.name ?? n).join(', ') : `${s.signals.length} ${s.signals.length === 1 ? 'part' : 'parts'} watched`}</small></span>
|
||||
<span class="strip"><Strip cells={s.history.cells} name={s.name} /></span>
|
||||
<span class="pct mono" title="Up over 30 days">{upPct(s.history.pct_30d)}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if sel}
|
||||
<aside class="detail" aria-labelledby="detail-h">
|
||||
<div>
|
||||
<Status s={sel.status} word={stateWord(sel)} />
|
||||
<h2 id="detail-h">{sel.name}</h2>
|
||||
</div>
|
||||
<div class="blk">
|
||||
<h3>Made of</h3>
|
||||
{#if parts.trouble.length}
|
||||
<ul class="parts">
|
||||
{#each parts.trouble as g (g.kind + g.name + (g.host ?? ''))}
|
||||
<li><a href={g.href ?? '#'}><span class="mono">{g.name}</span>{#if g.host}<span class="sub"> on {g.host}</span>{/if}</a><Status s={g.status} word={g.word} /></li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
{#if parts.groups.length}
|
||||
<p class="fine">{parts.trouble.length ? 'And ' : ''}{parts.groups.map(([k, n]) => `${n} ${kindWord(k, n)}`).join(', ')} {parts.trouble.length ? 'that are fine' : 'all fine'}.</p>
|
||||
{/if}
|
||||
{#if !sel.signals.length}<p class="fine">Nothing watched for it yet.</p>{/if}
|
||||
</div>
|
||||
<div class="two">
|
||||
<div class="blk">
|
||||
<h3>Needs</h3>
|
||||
{#if sel.needs.length}
|
||||
<ul class="links">{#each sel.needs as n (n)}{@const d = byId.get(n)}<li><button class="lnk" onclick={() => setParam('s', n)}>{d?.name ?? n}</button>{#if d && bad(d)} <Status s={d.status} word={d.word} />{/if}</li>{/each}</ul>
|
||||
{:else}<p class="fine">Nothing else.</p>{/if}
|
||||
</div>
|
||||
<div class="blk">
|
||||
<h3>If it breaks</h3>
|
||||
{#if sel.needed_by.length}
|
||||
<ul class="links">{#each sel.needed_by as n (n)}<li><button class="lnk" onclick={() => setParam('s', n)}>{byId.get(n)?.name ?? n}</button></li>{/each}</ul>
|
||||
{:else}<p class="fine">Nothing else depends on it.</p>{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="blk">
|
||||
<h3>Uptime</h3>
|
||||
<p class="fine">{upPct(sel.history.pct_24h)} in the last day · {upPct(sel.history.pct_30d)} in 30 days</p>
|
||||
<Strip cells={sel.history.cells} name={sel.name} />
|
||||
</div>
|
||||
<div class="acts2">
|
||||
<a class="btn pri" href="/map/services?focus={encodeURIComponent('svc:' + sel.id)}">On the service map</a>
|
||||
<a class="btn" href="/reports">Reports</a>
|
||||
</div>
|
||||
</aside>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.err { color: var(--critical); }
|
||||
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
|
||||
.list { flex: 999 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
|
||||
.list h2 { font-size: 16px; margin: 0 0 8px 4px; }
|
||||
.list h2 span { color: var(--muted-fg); font-weight: 400; }
|
||||
.box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-soft); }
|
||||
.row { display: grid; grid-template-columns: minmax(130px, 170px) minmax(0, 1fr) minmax(120px, 220px) 72px; gap: 16px; align-items: center; width: 100%; min-height: 64px; padding: 12px 18px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--foreground); text-align: left; cursor: pointer; font-size: 14px; }
|
||||
.row:first-child { border-top: 0; }
|
||||
.row:hover { background: var(--muted); }
|
||||
.row.on { background: var(--accent); box-shadow: inset 0 0 0 1px var(--primary); }
|
||||
.st { min-width: 0; overflow: hidden; }
|
||||
.nm { display: flex; flex-direction: column; min-width: 0; }
|
||||
.nm b { font-size: 16px; }
|
||||
.nm small { color: var(--muted-fg); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.pct { text-align: right; color: var(--data); font-size: 13px; }
|
||||
|
||||
.detail { flex: 1 1 340px; min-width: 0; position: sticky; top: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow-soft); }
|
||||
.detail h2 { font-size: 24px; margin-top: 4px; }
|
||||
.blk h3 { font-size: 13px; font-weight: 600; color: var(--muted-fg); margin-bottom: 6px; }
|
||||
.parts { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
||||
.parts li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; background: var(--muted); border-radius: 8px; }
|
||||
.parts a { color: var(--foreground); min-width: 0; }
|
||||
.fine { margin: 0; color: color-mix(in oklab, var(--foreground) 85%, var(--muted-fg)); }
|
||||
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
|
||||
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
|
||||
.lnk { border: 0; background: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-align: left; }
|
||||
.lnk:hover { text-decoration: underline; }
|
||||
.detail :global(.strip) { margin-top: 8px; }
|
||||
.acts2 { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'nm pct' 'st st' 'strip strip'; gap: 8px 12px; }
|
||||
.row .nm { grid-area: nm; } .row .pct { grid-area: pct; } .row .st { grid-area: st; } .row .strip { grid-area: strip; }
|
||||
.detail { position: static; }
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user