@juice-js/observability 1.3.0 → 1.3.1-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/{juice-js-observability-overview.page-g4Cv_Y5c.mjs → juice-js-observability-overview.page-vRttHzPw.mjs} +5 -3
- package/fesm2022/juice-js-observability-overview.page-vRttHzPw.mjs.map +1 -0
- package/fesm2022/juice-js-observability.mjs +1 -1
- package/package.json +1 -1
- package/fesm2022/juice-js-observability-overview.page-g4Cv_Y5c.mjs.map +0 -1
|
@@ -177,7 +177,8 @@ var PlatformPanel = class PlatformPanel {
|
|
|
177
177
|
@if (o.capacity.calibrated) {
|
|
178
178
|
<p>Held every line to <strong>{{ o.capacity.heldTo }}×</strong>; crossed one by {{ o.capacity.crossedAt }}×
|
|
179
179
|
@if (o.capacity.crossed.length) { <span class="jc-muted">({{ o.capacity.crossed.join('; ') }})</span> }.
|
|
180
|
-
@if (o.capacity.headroom !== null) { Today's load is {{ (1 / o.capacity.headroom * 100).toFixed(0) }} % of what held. }
|
|
180
|
+
@if (o.capacity.headroom !== null) { Today's load is {{ (1 / o.capacity.headroom * 100).toFixed(0) }} % of what held. }
|
|
181
|
+
<span class="jc-muted">What held is a measurement, not a plan: a step meets only a few bursts, so plan a step under it.</span></p>
|
|
181
182
|
}
|
|
182
183
|
<div class="jc-list-row jc-muted">
|
|
183
184
|
Now: {{ o.capacity.mix.rules ?? '—' }} rules, {{ o.capacity.mix.slos ?? '—' }} SLOs, {{ o.capacity.mix.services ?? '—' }} services
|
|
@@ -321,7 +322,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
321
322
|
@if (o.capacity.calibrated) {
|
|
322
323
|
<p>Held every line to <strong>{{ o.capacity.heldTo }}×</strong>; crossed one by {{ o.capacity.crossedAt }}×
|
|
323
324
|
@if (o.capacity.crossed.length) { <span class="jc-muted">({{ o.capacity.crossed.join('; ') }})</span> }.
|
|
324
|
-
@if (o.capacity.headroom !== null) { Today's load is {{ (1 / o.capacity.headroom * 100).toFixed(0) }} % of what held. }
|
|
325
|
+
@if (o.capacity.headroom !== null) { Today's load is {{ (1 / o.capacity.headroom * 100).toFixed(0) }} % of what held. }
|
|
326
|
+
<span class="jc-muted">What held is a measurement, not a plan: a step meets only a few bursts, so plan a step under it.</span></p>
|
|
325
327
|
}
|
|
326
328
|
<div class="jc-list-row jc-muted">
|
|
327
329
|
Now: {{ o.capacity.mix.rules ?? '—' }} rules, {{ o.capacity.mix.slos ?? '—' }} SLOs, {{ o.capacity.mix.services ?? '—' }} services
|
|
@@ -598,4 +600,4 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
598
600
|
});
|
|
599
601
|
export { OverviewPage };
|
|
600
602
|
|
|
601
|
-
//# sourceMappingURL=juice-js-observability-overview.page-
|
|
603
|
+
//# sourceMappingURL=juice-js-observability-overview.page-vRttHzPw.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"juice-js-observability-overview.page-vRttHzPw.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/shared/platform-panel.ts","../../../../projects/juice-js/observability/src/lib/pages/overview.page.ts"],"sourcesContent":["import { DecimalPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { EMPTY, catchError, map, switchMap, takeWhile, tap, timer } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { PlatformLevel } from '../core/models';\nimport { AgoPipe, formatBytes, formatDuration, formatPercent } from './format';\nimport { apiResource } from './resource';\nimport { problemText } from './telemetry';\n\n/** How often the panel reads again: the platform samples every 15 s, so faster shows nothing new. */\nconst REFRESH_MS = 15_000;\n\nconst LEVEL_CLASS: Record<PlatformLevel, string> = {\n ok: 'jc-health-healthy', warn: 'jc-health-degraded', bad: 'jc-health-unhealthy', unknown: 'jc-health-unknown',\n};\n\nconst RESOURCE_NAMES: Record<string, string> = {\n 'clickhouse.cpu': 'ClickHouse CPU', 'clickhouse.inserts_in_flight': 'Collector inserts in flight', 'collector.queue': 'Export queue',\n};\n\nexport function formatRate(perSecond: number | null | undefined): string {\n if (perSecond === null || perSecond === undefined) return '—';\n return perSecond >= 1000 ? `${(perSecond / 1000).toFixed(perSecond >= 100_000 ? 0 : 1)}k/s` : `${perSecond.toFixed(perSecond >= 10 ? 0 : 1)}/s`;\n}\n\n/** A resource's figure in its own unit: cores and inserts as numbers, shares as percentages. */\nexport function formatMeasure(value: number | null | undefined, unit: string): string {\n if (value === null || value === undefined) return '—';\n return unit === 'cores' || unit === 'inserts' ? value.toFixed(value >= 10 ? 0 : 1) : formatPercent(value);\n}\n\n/**\n * The Overview's \"Platform\" panel (Phase 11 R8) and the capacity view (R9), for operators: the workers, ingestion, ClickHouse and disk, each\n * green, amber or red against the scale steps' lines, and what the platform held at in the steps it is calibrated on. A viewer doesn't see it.\n */\n@Component({\n selector: 'jc-platform-panel',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [AgoPipe, DecimalPipe],\n template: `\n @if (!hidden()) {\n <section class=\"jc-card jc-platform\" aria-labelledby=\"jc-platform-title\">\n <div class=\"jc-row\">\n <h2 id=\"jc-platform-title\">Platform</h2>\n @if (o(); as o) {\n <span class=\"jc-badge\" [class]=\"cls(o.status === 'ok' ? 'ok' : 'bad')\">{{ o.status }}</span>\n <span class=\"jc-muted\">sampled {{ o.at | ago }}</span>\n }\n </div>\n @if (error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (o(); as o) {\n <div class=\"jc-grid-2\">\n <div>\n <h3>Workers</h3>\n @for (w of o.workers; track w.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(w.level)\">{{ w.state }}</span>\n <strong>{{ w.name }}</strong>\n @if (w.utilisation !== null) { <span title=\"Its recent passes against its interval\">{{ pct(w.utilisation) }} busy</span> }\n @if (w.lastPassEndedAt) { <span class=\"jc-muted\">last pass {{ w.lastPassEndedAt | ago }}</span> }\n </div>\n }\n @for (b of o.backlogs; track b.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(b.level)\">{{ b.state }}</span>\n <strong>{{ b.name }} backlog</strong>\n <span class=\"jc-muted\">{{ b.ageSeconds === null ? '—' : seconds(b.ageSeconds) }} of {{ seconds(b.lineSeconds) }}</span>\n </div>\n }\n </div>\n <div>\n <h3>Ingestion</h3>\n @if (o.ingestion; as i) {\n @for (s of i.signals; track s.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(s.level)\">{{ s.name }}</span>\n <span>{{ rate(s.acceptedPerSecond) }} received</span>\n <span [class.jc-muted]=\"!s.refusedPerSecond\">{{ rate(s.refusedPerSecond) }} refused</span>\n <span [class.jc-muted]=\"!s.droppedPerSecond\">{{ rate(s.droppedPerSecond) }} dropped</span>\n </div>\n }\n @for (q of i.queues; track q.exporter) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(q.level)\">{{ pct(q.fill) }}</span>\n <span>{{ q.exporter }} queue</span>\n <span class=\"jc-muted\">{{ q.size | number }} of {{ q.capacity | number }}</span>\n </div>\n }\n } @else { <p class=\"jc-muted\">No figures: the Collector's metrics page isn't read (Telemetry:CollectorMetricsUrl), or the last sample is old.</p> }\n\n <h3>ClickHouse</h3>\n @if (o.clickHouse; as c) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(c.cpuLevel)\">CPU</span>\n <span>{{ c.cores === null ? '—' : c.cores.toFixed(1) }} of {{ c.coresAvailable ?? '—' }} cores</span>\n <span class=\"jc-muted\">{{ c.runningQueries }} queries running</span>\n </div>\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(c.insertLevel)\">inserts</span>\n <span>p95 {{ ms(c.insertP95Seconds) }}</span>\n <span class=\"jc-muted\">{{ c.insertsInFlight === null ? '—' : c.insertsInFlight.toFixed(1) }} in flight</span>\n </div>\n @for (r of c.reads.slice(0, 6); track r.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(r.level)\">p95 {{ ms(r.p95Seconds) }}</span>\n <span>{{ r.name }}</span><span class=\"jc-muted\">{{ r.count }} in the last minute</span>\n </div>\n }\n } @else { <p class=\"jc-muted\">No figures: ClickHouse isn't sampled (ClickHouse:MonitorConnectionString), or didn't answer.</p> }\n\n <h3>Disk</h3>\n @if (o.disk; as d) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(d.level)\">{{ d.daysUntilFull !== null ? days(d.daysUntilFull) + ' until full' : d.bytesPerDay === null ? 'no estimate yet' : d.bytesPerDay > 0 ? 'fits at retention' : 'not growing' }}</span>\n <span>{{ bytes(d.used) }} used, {{ bytes(d.free) }} free</span>\n </div>\n <div class=\"jc-list-row\">\n <span>{{ bytes(d.bytesPerDay) }} a day@if (d.estimated) { <span class=\"jc-muted\"> (estimated from today)</span> }</span>\n <span class=\"jc-muted\">at retention: {{ bytes(d.needAtRetention) }} of {{ bytes(d.total) }}</span>\n </div>\n } @else { <p class=\"jc-muted\">No figures.</p> }\n </div>\n </div>\n\n <h3>Capacity</h3>\n <p class=\"jc-muted\">{{ o.capacity.label }}</p>\n <div class=\"jc-list-row\">\n @for (l of o.capacity.load; track l.signal) {\n <span>{{ l.signal }} <strong>{{ l.multiple === null ? '—' : l.multiple.toFixed(1) + '×' }}</strong>\n <span class=\"jc-muted\">({{ rate(l.perSecond) }} of {{ rate(l.reference) }} at 1×)</span></span>\n }\n </div>\n @if (o.capacity.calibrated) {\n <p>Held every line to <strong>{{ o.capacity.heldTo }}×</strong>; crossed one by {{ o.capacity.crossedAt }}×\n @if (o.capacity.crossed.length) { <span class=\"jc-muted\">({{ o.capacity.crossed.join('; ') }})</span> }.\n @if (o.capacity.headroom !== null) { Today's load is {{ (1 / o.capacity.headroom * 100).toFixed(0) }} % of what held. }\n <span class=\"jc-muted\">What held is a measurement, not a plan: a step meets only a few bursts, so plan a step under it.</span></p>\n }\n <div class=\"jc-list-row jc-muted\">\n Now: {{ o.capacity.mix.rules ?? '—' }} rules, {{ o.capacity.mix.slos ?? '—' }} SLOs, {{ o.capacity.mix.services ?? '—' }} services\n @if (o.capacity.mix.calibratedRules !== null) {\n · calibrated with {{ o.capacity.mix.calibratedRules }} rules, {{ o.capacity.mix.calibratedSlos }} SLOs, {{ o.capacity.mix.calibratedServices }} services\n and {{ o.capacity.mix.calibratedSearchesPerSecond }} searches a second\n }\n </div>\n <table class=\"jc-table\">\n <thead><tr><th>Resource</th><th>Now</th>@if (o.capacity.calibrated) { <th>Where every line held ({{ o.capacity.heldTo }}×)</th><th>Where one crossed ({{ o.capacity.crossedAt }}×)</th> }</tr></thead>\n <tbody>\n @for (r of o.capacity.resources; track r.name) {\n <tr>\n <td>{{ resource(r.name) }}</td>\n <td><span class=\"jc-badge\" [class]=\"cls(r.level)\">{{ measure(r.now, r.unit) }}</span></td>\n @if (o.capacity.calibrated) { <td>{{ measure(r.atHeld, r.unit) }}</td><td>{{ measure(r.atCrossed, r.unit) }}</td> }\n </tr>\n }\n </tbody>\n </table>\n }\n </section>\n }`,\n})\nexport class PlatformPanel {\n private readonly api = inject(ApiService);\n\n /** The last read's failure, cleared by the next that succeeds: a failed read keeps the last figures and the 15 s reads going. */\n private readonly failed = signal<unknown>(undefined);\n protected readonly overview = apiResource({\n // Only for operators and admins (the tenant says so): a viewer never asks, so never gets the 403.\n // A new tenant answer starts afresh: a 403 before it doesn't stop the reads it allows.\n stream: () => this.api.tenant$.pipe(tap(() => this.failed.set(undefined)), switchMap(t => t.canOperate\n ? timer(0, REFRESH_MS).pipe(\n // Refused (a role taken away since sign-in): stop asking, rather than be refused every 15 s.\n takeWhile(() => (this.failed() as { status?: number } | undefined)?.status !== 403),\n switchMap(() => this.api.platformOverview().pipe(\n tap(() => this.failed.set(undefined)),\n catchError(e => { this.failed.set(e); return EMPTY; }))))\n : EMPTY)),\n });\n protected readonly o = computed(() => this.overview.value());\n /** Whether the user is an operator or admin, from the tenant (false until it is known). */\n private readonly canOperate = toSignal(this.api.tenant$.pipe(map(t => !!t.canOperate)), { initialValue: false });\n /** A viewer isn't an operator: no panel (and a 403 from a role changed since sign-in hides it too, without an error). */\n protected readonly hidden = computed(() => !this.canOperate() || (this.failed() as { status?: number } | undefined)?.status === 403);\n protected readonly error = computed(() => this.failed() && !this.hidden() ? problemText(this.failed()) : '');\n\n protected cls(level: PlatformLevel): string { return `jc-badge ${LEVEL_CLASS[level]}`; }\n protected pct(share: number): string { return formatPercent(share); }\n protected rate(perSecond: number | null): string { return formatRate(perSecond); }\n protected bytes(bytes: number | null): string { return formatBytes(bytes); }\n protected measure(value: number | null, unit: string): string { return formatMeasure(value, unit); }\n protected ms(seconds: number | null): string { return formatDuration(seconds === null ? null : seconds * 1000); }\n protected seconds(s: number): string { return s >= 120 ? `${Math.round(s / 60)} min` : `${Math.round(s)} s`; }\n protected days(d: number): string { return d >= 365 ? 'over a year' : `${Math.round(d)} days`; }\n protected resource(name: string): string { return RESOURCE_NAMES[name] ?? (name.startsWith('worker.') ? `Worker ${name.slice(7)}` : name); }\n}\n","import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { map } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { HealthState } from '../core/models';\nimport { AgoPipe, ReasonPipe } from '../shared/format';\nimport { ContextBar, HealthBadge } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\nimport { PlatformPanel } from '../shared/platform-panel';\n\nconst ORDER: HealthState[] = ['Critical', 'Unhealthy', 'Degraded', 'Offline', 'Unknown', 'Healthy'];\n\n/** How many rows each list shows: the overview orients, the alerts and services pages list everything. */\nconst SHOWN = 10;\n\n/**\n * Where an investigation starts (Console requirements §4, §21 step 1): what is firing and which services are not\n * healthy, each one click from its service page. Orientation, not a dashboard.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, MatProgressBarModule, ContextBar, HealthBadge, AgoPipe, PlatformPanel],\n template: `\n <jc-context-bar><h1>Overview</h1></jc-context-bar>\n @if (health.isLoading() || alerts.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (health.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n\n <div class=\"jc-tiles\">\n @for (s of order; track s) {\n <a class=\"jc-card jc-tile\" [routerLink]=\"['services'] | jcLink\" [queryParams]=\"ctx.keep({ state: s })\">\n <jc-health [state]=\"s\" /><strong>{{ counts()[s] ?? 0 }}</strong><span class=\"jc-muted\">services</span>\n </a>\n }\n </div>\n\n <section class=\"jc-card\">\n <div class=\"jc-row\">\n <h2>Firing alerts @if (firing().length) { <span class=\"jc-muted\">({{ firing().length }}@if (criticalCount()) { · {{ criticalCount() }} critical})</span> }</h2>\n @if (firing().length) { <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep({ state: 'firing' })\">All firing alerts</a> }\n </div>\n @for (a of firingShown(); track a.id) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"a.severity === 'Critical'\" [class.jc-health-degraded]=\"a.severity !== 'Critical'\">{{ a.severity }}</span>\n <a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a>\n <span>{{ a.subjectKey }}</span>\n <span class=\"jc-muted\">fired {{ a.firedAt | ago }}@if (a.acknowledgedBy) { · acknowledged by {{ a.acknowledgedBy }} }</span>\n </div>\n } @empty { <p class=\"jc-muted\">Nothing firing.</p> }\n @if (firing().length > shown) {\n <p class=\"jc-more\"><span class=\"jc-muted\">Critical first, then the newest; {{ firing().length - shown }} more.</span>\n <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep({ state: 'firing' })\">See all {{ firing().length }}</a></p>\n }\n </section>\n\n <section class=\"jc-card\">\n <h2>Services needing attention @if (attention().length) { <span class=\"jc-muted\">({{ attention().length }})</span> }</h2>\n @for (h of attention().slice(0, shown); track h.subjectId + h.environment) {\n <div class=\"jc-list-row\">\n <jc-health [state]=\"h.state\" [stale]=\"h.stale\" />\n <a [routerLink]=\"['services', h.subjectId] | jcLink\" [queryParams]=\"ctx.keep({ env: h.environment })\">{{ h.subjectName }}</a>\n <span class=\"jc-muted\">{{ h.environment }}</span>\n <span>{{ h.reasons.slice(0, 3).map(reason).join(' · ') }}</span>\n <span class=\"jc-muted\">since {{ h.since | ago }}</span>\n </div>\n } @empty { <p class=\"jc-muted\">Every evaluated service is healthy.</p> }\n @if (attention().length > shown) {\n <p class=\"jc-more\"><span class=\"jc-muted\">The worst first; {{ attention().length - shown }} more. The counts above open each state's list:</span>\n @for (s of order; track s) { @if (s !== 'Healthy' && counts()[s]) {\n <a [routerLink]=\"['services'] | jcLink\" [queryParams]=\"ctx.keep({ state: s })\">{{ counts()[s] }} {{ s.toLowerCase() }}</a>\n } }</p>\n }\n </section>\n\n <jc-platform-panel />`,\n})\nexport class OverviewPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly order = ORDER;\n protected readonly shown = SHOWN;\n private readonly reasonPipe = new ReasonPipe();\n protected readonly reason = (r: string) => this.reasonPipe.transform(r);\n\n protected readonly health = apiResource({\n params: () => this.ctx.environment(),\n stream: ({ params }) => this.api.health({ subjectType: 'service', environment: params }).pipe(map(p => p.items)),\n });\n protected readonly alerts = apiResource({\n params: () => this.ctx.environment(),\n stream: ({ params }) => this.api.allAlerts({ state: 'firing', environment: params }).pipe(map(p => p.items)),\n });\n protected readonly error = computed(() => problemText(this.health.error()));\n /** Critical first, then the newest. */\n protected readonly firing = computed(() => [...(this.alerts.value() ?? [])].sort((a, b) =>\n Number(b.severity === 'Critical') - Number(a.severity === 'Critical')\n || (b.firedAt ?? '').localeCompare(a.firedAt ?? '')));\n protected readonly firingShown = computed(() => this.firing().slice(0, SHOWN));\n protected readonly criticalCount = computed(() => this.firing().filter(a => a.severity === 'Critical').length);\n protected readonly counts = computed(() => {\n const counts: Partial<Record<HealthState, number>> = {};\n for (const h of this.health.value() ?? []) counts[h.state] = (counts[h.state] ?? 0) + 1;\n return counts;\n });\n protected readonly attention = computed(() => (this.health.value() ?? [])\n .filter(h => h.state !== 'Healthy')\n .sort((a, b) => ORDER.indexOf(a.state) - ORDER.indexOf(b.state)));\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,aAAa;AAEnB,MAAM,cAA6C;CACjD,IAAI;CAAqB,MAAM;CAAsB,KAAK;CAAuB,SAAS;AAC3F;AAED,MAAM,iBAAyC;CAC7C,kBAAkB;CAAkB,gCAAgC;CAA+B,mBAAmB;AACvH;AAED,SAAgB,WAAW,WAAoC;CAC7D,IAAI,cAAc,QAAQ,cAAc,QAAW,OAAO;CAC1D,OAAO,aAAa,MAAO,IAAI,YAAY,IAAA,CAAM,QAAQ,aAAa,MAAU,IAAI,CAAC,EAAC,OAAQ,GAAG,UAAU,QAAQ,aAAa,KAAK,IAAI,CAAC,EAAC;AAC7I;AAGA,SAAgB,cAAc,OAAkC,MAAY;CAC1E,IAAI,UAAU,QAAQ,UAAU,QAAW,OAAO;CAClD,OAAO,SAAS,WAAW,SAAS,YAAY,MAAM,QAAQ,SAAS,KAAK,IAAI,CAAC,IAAI,cAAc,KAAK;AAC1G;AAoIA,IAAa,gBAAb,MAAa,cAAa;CACP,MAAM,OAAO,UAAU;CAGvB,SAAS,OAAgB,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CACjC,WAAW,YAAY,EAGxC,cAAc,KAAK,IAAI,QAAQ,KAAK,UAAU,KAAK,OAAO,IAAI,MAAS,CAAC,GAAG,WAAU,MAAK,EAAE,aACxF,MAAM,GAAG,UAAU,CAAC,CAAC,KAErB,gBAAiB,KAAK,OAAM,CAAsC,EAAE,WA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AA;GAAA;GAAA;IAAA,MAAA;IAAA,MAA3F;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAA6D;IAAO,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAsD3E,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EAxDxB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAsB;IAAY;IAAa;IAAS;GAAa;GACrG,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDX,CAAA"}
|
|
@@ -664,7 +664,7 @@ function page(path, title, load) {
|
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
666
|
const OBSERVABILITY_ROUTES = [
|
|
667
|
-
page("", "Overview", () => import("./juice-js-observability-overview.page-
|
|
667
|
+
page("", "Overview", () => import("./juice-js-observability-overview.page-vRttHzPw.mjs").then((m) => m.OverviewPage)),
|
|
668
668
|
page("services", "Services", () => import("./juice-js-observability-services.page-C5-ohRLS.mjs").then((m) => m.ServicesPage)),
|
|
669
669
|
page("services/:id", "Service", () => import("./juice-js-observability-service.page-Dx4p3DmT.mjs").then((m) => m.ServicePage)),
|
|
670
670
|
page("traces", "Traces", () => import("./juice-js-observability-traces.page-C2z6MUzK.mjs").then((m) => m.TracesPage)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juice-js/observability",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1-alpha.41",
|
|
4
4
|
"description": "Juice Observability pages (services, traces, topology, logs, metrics, resources, alerts, rules) for an Angular app on juice-layout",
|
|
5
5
|
"author": "jack@creatorflow.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"juice-js-observability-overview.page-g4Cv_Y5c.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/shared/platform-panel.ts","../../../../projects/juice-js/observability/src/lib/pages/overview.page.ts"],"sourcesContent":["import { DecimalPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { EMPTY, catchError, map, switchMap, takeWhile, tap, timer } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { PlatformLevel } from '../core/models';\nimport { AgoPipe, formatBytes, formatDuration, formatPercent } from './format';\nimport { apiResource } from './resource';\nimport { problemText } from './telemetry';\n\n/** How often the panel reads again: the platform samples every 15 s, so faster shows nothing new. */\nconst REFRESH_MS = 15_000;\n\nconst LEVEL_CLASS: Record<PlatformLevel, string> = {\n ok: 'jc-health-healthy', warn: 'jc-health-degraded', bad: 'jc-health-unhealthy', unknown: 'jc-health-unknown',\n};\n\nconst RESOURCE_NAMES: Record<string, string> = {\n 'clickhouse.cpu': 'ClickHouse CPU', 'clickhouse.inserts_in_flight': 'Collector inserts in flight', 'collector.queue': 'Export queue',\n};\n\nexport function formatRate(perSecond: number | null | undefined): string {\n if (perSecond === null || perSecond === undefined) return '—';\n return perSecond >= 1000 ? `${(perSecond / 1000).toFixed(perSecond >= 100_000 ? 0 : 1)}k/s` : `${perSecond.toFixed(perSecond >= 10 ? 0 : 1)}/s`;\n}\n\n/** A resource's figure in its own unit: cores and inserts as numbers, shares as percentages. */\nexport function formatMeasure(value: number | null | undefined, unit: string): string {\n if (value === null || value === undefined) return '—';\n return unit === 'cores' || unit === 'inserts' ? value.toFixed(value >= 10 ? 0 : 1) : formatPercent(value);\n}\n\n/**\n * The Overview's \"Platform\" panel (Phase 11 R8) and the capacity view (R9), for operators: the workers, ingestion, ClickHouse and disk, each\n * green, amber or red against the scale steps' lines, and what the platform held at in the steps it is calibrated on. A viewer doesn't see it.\n */\n@Component({\n selector: 'jc-platform-panel',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [AgoPipe, DecimalPipe],\n template: `\n @if (!hidden()) {\n <section class=\"jc-card jc-platform\" aria-labelledby=\"jc-platform-title\">\n <div class=\"jc-row\">\n <h2 id=\"jc-platform-title\">Platform</h2>\n @if (o(); as o) {\n <span class=\"jc-badge\" [class]=\"cls(o.status === 'ok' ? 'ok' : 'bad')\">{{ o.status }}</span>\n <span class=\"jc-muted\">sampled {{ o.at | ago }}</span>\n }\n </div>\n @if (error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (o(); as o) {\n <div class=\"jc-grid-2\">\n <div>\n <h3>Workers</h3>\n @for (w of o.workers; track w.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(w.level)\">{{ w.state }}</span>\n <strong>{{ w.name }}</strong>\n @if (w.utilisation !== null) { <span title=\"Its recent passes against its interval\">{{ pct(w.utilisation) }} busy</span> }\n @if (w.lastPassEndedAt) { <span class=\"jc-muted\">last pass {{ w.lastPassEndedAt | ago }}</span> }\n </div>\n }\n @for (b of o.backlogs; track b.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(b.level)\">{{ b.state }}</span>\n <strong>{{ b.name }} backlog</strong>\n <span class=\"jc-muted\">{{ b.ageSeconds === null ? '—' : seconds(b.ageSeconds) }} of {{ seconds(b.lineSeconds) }}</span>\n </div>\n }\n </div>\n <div>\n <h3>Ingestion</h3>\n @if (o.ingestion; as i) {\n @for (s of i.signals; track s.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(s.level)\">{{ s.name }}</span>\n <span>{{ rate(s.acceptedPerSecond) }} received</span>\n <span [class.jc-muted]=\"!s.refusedPerSecond\">{{ rate(s.refusedPerSecond) }} refused</span>\n <span [class.jc-muted]=\"!s.droppedPerSecond\">{{ rate(s.droppedPerSecond) }} dropped</span>\n </div>\n }\n @for (q of i.queues; track q.exporter) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(q.level)\">{{ pct(q.fill) }}</span>\n <span>{{ q.exporter }} queue</span>\n <span class=\"jc-muted\">{{ q.size | number }} of {{ q.capacity | number }}</span>\n </div>\n }\n } @else { <p class=\"jc-muted\">No figures: the Collector's metrics page isn't read (Telemetry:CollectorMetricsUrl), or the last sample is old.</p> }\n\n <h3>ClickHouse</h3>\n @if (o.clickHouse; as c) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(c.cpuLevel)\">CPU</span>\n <span>{{ c.cores === null ? '—' : c.cores.toFixed(1) }} of {{ c.coresAvailable ?? '—' }} cores</span>\n <span class=\"jc-muted\">{{ c.runningQueries }} queries running</span>\n </div>\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(c.insertLevel)\">inserts</span>\n <span>p95 {{ ms(c.insertP95Seconds) }}</span>\n <span class=\"jc-muted\">{{ c.insertsInFlight === null ? '—' : c.insertsInFlight.toFixed(1) }} in flight</span>\n </div>\n @for (r of c.reads.slice(0, 6); track r.name) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(r.level)\">p95 {{ ms(r.p95Seconds) }}</span>\n <span>{{ r.name }}</span><span class=\"jc-muted\">{{ r.count }} in the last minute</span>\n </div>\n }\n } @else { <p class=\"jc-muted\">No figures: ClickHouse isn't sampled (ClickHouse:MonitorConnectionString), or didn't answer.</p> }\n\n <h3>Disk</h3>\n @if (o.disk; as d) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class]=\"cls(d.level)\">{{ d.daysUntilFull !== null ? days(d.daysUntilFull) + ' until full' : d.bytesPerDay === null ? 'no estimate yet' : d.bytesPerDay > 0 ? 'fits at retention' : 'not growing' }}</span>\n <span>{{ bytes(d.used) }} used, {{ bytes(d.free) }} free</span>\n </div>\n <div class=\"jc-list-row\">\n <span>{{ bytes(d.bytesPerDay) }} a day@if (d.estimated) { <span class=\"jc-muted\"> (estimated from today)</span> }</span>\n <span class=\"jc-muted\">at retention: {{ bytes(d.needAtRetention) }} of {{ bytes(d.total) }}</span>\n </div>\n } @else { <p class=\"jc-muted\">No figures.</p> }\n </div>\n </div>\n\n <h3>Capacity</h3>\n <p class=\"jc-muted\">{{ o.capacity.label }}</p>\n <div class=\"jc-list-row\">\n @for (l of o.capacity.load; track l.signal) {\n <span>{{ l.signal }} <strong>{{ l.multiple === null ? '—' : l.multiple.toFixed(1) + '×' }}</strong>\n <span class=\"jc-muted\">({{ rate(l.perSecond) }} of {{ rate(l.reference) }} at 1×)</span></span>\n }\n </div>\n @if (o.capacity.calibrated) {\n <p>Held every line to <strong>{{ o.capacity.heldTo }}×</strong>; crossed one by {{ o.capacity.crossedAt }}×\n @if (o.capacity.crossed.length) { <span class=\"jc-muted\">({{ o.capacity.crossed.join('; ') }})</span> }.\n @if (o.capacity.headroom !== null) { Today's load is {{ (1 / o.capacity.headroom * 100).toFixed(0) }} % of what held. }</p>\n }\n <div class=\"jc-list-row jc-muted\">\n Now: {{ o.capacity.mix.rules ?? '—' }} rules, {{ o.capacity.mix.slos ?? '—' }} SLOs, {{ o.capacity.mix.services ?? '—' }} services\n @if (o.capacity.mix.calibratedRules !== null) {\n · calibrated with {{ o.capacity.mix.calibratedRules }} rules, {{ o.capacity.mix.calibratedSlos }} SLOs, {{ o.capacity.mix.calibratedServices }} services\n and {{ o.capacity.mix.calibratedSearchesPerSecond }} searches a second\n }\n </div>\n <table class=\"jc-table\">\n <thead><tr><th>Resource</th><th>Now</th>@if (o.capacity.calibrated) { <th>Where every line held ({{ o.capacity.heldTo }}×)</th><th>Where one crossed ({{ o.capacity.crossedAt }}×)</th> }</tr></thead>\n <tbody>\n @for (r of o.capacity.resources; track r.name) {\n <tr>\n <td>{{ resource(r.name) }}</td>\n <td><span class=\"jc-badge\" [class]=\"cls(r.level)\">{{ measure(r.now, r.unit) }}</span></td>\n @if (o.capacity.calibrated) { <td>{{ measure(r.atHeld, r.unit) }}</td><td>{{ measure(r.atCrossed, r.unit) }}</td> }\n </tr>\n }\n </tbody>\n </table>\n }\n </section>\n }`,\n})\nexport class PlatformPanel {\n private readonly api = inject(ApiService);\n\n /** The last read's failure, cleared by the next that succeeds: a failed read keeps the last figures and the 15 s reads going. */\n private readonly failed = signal<unknown>(undefined);\n protected readonly overview = apiResource({\n // Only for operators and admins (the tenant says so): a viewer never asks, so never gets the 403.\n // A new tenant answer starts afresh: a 403 before it doesn't stop the reads it allows.\n stream: () => this.api.tenant$.pipe(tap(() => this.failed.set(undefined)), switchMap(t => t.canOperate\n ? timer(0, REFRESH_MS).pipe(\n // Refused (a role taken away since sign-in): stop asking, rather than be refused every 15 s.\n takeWhile(() => (this.failed() as { status?: number } | undefined)?.status !== 403),\n switchMap(() => this.api.platformOverview().pipe(\n tap(() => this.failed.set(undefined)),\n catchError(e => { this.failed.set(e); return EMPTY; }))))\n : EMPTY)),\n });\n protected readonly o = computed(() => this.overview.value());\n /** Whether the user is an operator or admin, from the tenant (false until it is known). */\n private readonly canOperate = toSignal(this.api.tenant$.pipe(map(t => !!t.canOperate)), { initialValue: false });\n /** A viewer isn't an operator: no panel (and a 403 from a role changed since sign-in hides it too, without an error). */\n protected readonly hidden = computed(() => !this.canOperate() || (this.failed() as { status?: number } | undefined)?.status === 403);\n protected readonly error = computed(() => this.failed() && !this.hidden() ? problemText(this.failed()) : '');\n\n protected cls(level: PlatformLevel): string { return `jc-badge ${LEVEL_CLASS[level]}`; }\n protected pct(share: number): string { return formatPercent(share); }\n protected rate(perSecond: number | null): string { return formatRate(perSecond); }\n protected bytes(bytes: number | null): string { return formatBytes(bytes); }\n protected measure(value: number | null, unit: string): string { return formatMeasure(value, unit); }\n protected ms(seconds: number | null): string { return formatDuration(seconds === null ? null : seconds * 1000); }\n protected seconds(s: number): string { return s >= 120 ? `${Math.round(s / 60)} min` : `${Math.round(s)} s`; }\n protected days(d: number): string { return d >= 365 ? 'over a year' : `${Math.round(d)} days`; }\n protected resource(name: string): string { return RESOURCE_NAMES[name] ?? (name.startsWith('worker.') ? `Worker ${name.slice(7)}` : name); }\n}\n","import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { map } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { HealthState } from '../core/models';\nimport { AgoPipe, ReasonPipe } from '../shared/format';\nimport { ContextBar, HealthBadge } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\nimport { PlatformPanel } from '../shared/platform-panel';\n\nconst ORDER: HealthState[] = ['Critical', 'Unhealthy', 'Degraded', 'Offline', 'Unknown', 'Healthy'];\n\n/** How many rows each list shows: the overview orients, the alerts and services pages list everything. */\nconst SHOWN = 10;\n\n/**\n * Where an investigation starts (Console requirements §4, §21 step 1): what is firing and which services are not\n * healthy, each one click from its service page. Orientation, not a dashboard.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, MatProgressBarModule, ContextBar, HealthBadge, AgoPipe, PlatformPanel],\n template: `\n <jc-context-bar><h1>Overview</h1></jc-context-bar>\n @if (health.isLoading() || alerts.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (health.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n\n <div class=\"jc-tiles\">\n @for (s of order; track s) {\n <a class=\"jc-card jc-tile\" [routerLink]=\"['services'] | jcLink\" [queryParams]=\"ctx.keep({ state: s })\">\n <jc-health [state]=\"s\" /><strong>{{ counts()[s] ?? 0 }}</strong><span class=\"jc-muted\">services</span>\n </a>\n }\n </div>\n\n <section class=\"jc-card\">\n <div class=\"jc-row\">\n <h2>Firing alerts @if (firing().length) { <span class=\"jc-muted\">({{ firing().length }}@if (criticalCount()) { · {{ criticalCount() }} critical})</span> }</h2>\n @if (firing().length) { <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep({ state: 'firing' })\">All firing alerts</a> }\n </div>\n @for (a of firingShown(); track a.id) {\n <div class=\"jc-list-row\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"a.severity === 'Critical'\" [class.jc-health-degraded]=\"a.severity !== 'Critical'\">{{ a.severity }}</span>\n <a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a>\n <span>{{ a.subjectKey }}</span>\n <span class=\"jc-muted\">fired {{ a.firedAt | ago }}@if (a.acknowledgedBy) { · acknowledged by {{ a.acknowledgedBy }} }</span>\n </div>\n } @empty { <p class=\"jc-muted\">Nothing firing.</p> }\n @if (firing().length > shown) {\n <p class=\"jc-more\"><span class=\"jc-muted\">Critical first, then the newest; {{ firing().length - shown }} more.</span>\n <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep({ state: 'firing' })\">See all {{ firing().length }}</a></p>\n }\n </section>\n\n <section class=\"jc-card\">\n <h2>Services needing attention @if (attention().length) { <span class=\"jc-muted\">({{ attention().length }})</span> }</h2>\n @for (h of attention().slice(0, shown); track h.subjectId + h.environment) {\n <div class=\"jc-list-row\">\n <jc-health [state]=\"h.state\" [stale]=\"h.stale\" />\n <a [routerLink]=\"['services', h.subjectId] | jcLink\" [queryParams]=\"ctx.keep({ env: h.environment })\">{{ h.subjectName }}</a>\n <span class=\"jc-muted\">{{ h.environment }}</span>\n <span>{{ h.reasons.slice(0, 3).map(reason).join(' · ') }}</span>\n <span class=\"jc-muted\">since {{ h.since | ago }}</span>\n </div>\n } @empty { <p class=\"jc-muted\">Every evaluated service is healthy.</p> }\n @if (attention().length > shown) {\n <p class=\"jc-more\"><span class=\"jc-muted\">The worst first; {{ attention().length - shown }} more. The counts above open each state's list:</span>\n @for (s of order; track s) { @if (s !== 'Healthy' && counts()[s]) {\n <a [routerLink]=\"['services'] | jcLink\" [queryParams]=\"ctx.keep({ state: s })\">{{ counts()[s] }} {{ s.toLowerCase() }}</a>\n } }</p>\n }\n </section>\n\n <jc-platform-panel />`,\n})\nexport class OverviewPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly order = ORDER;\n protected readonly shown = SHOWN;\n private readonly reasonPipe = new ReasonPipe();\n protected readonly reason = (r: string) => this.reasonPipe.transform(r);\n\n protected readonly health = apiResource({\n params: () => this.ctx.environment(),\n stream: ({ params }) => this.api.health({ subjectType: 'service', environment: params }).pipe(map(p => p.items)),\n });\n protected readonly alerts = apiResource({\n params: () => this.ctx.environment(),\n stream: ({ params }) => this.api.allAlerts({ state: 'firing', environment: params }).pipe(map(p => p.items)),\n });\n protected readonly error = computed(() => problemText(this.health.error()));\n /** Critical first, then the newest. */\n protected readonly firing = computed(() => [...(this.alerts.value() ?? [])].sort((a, b) =>\n Number(b.severity === 'Critical') - Number(a.severity === 'Critical')\n || (b.firedAt ?? '').localeCompare(a.firedAt ?? '')));\n protected readonly firingShown = computed(() => this.firing().slice(0, SHOWN));\n protected readonly criticalCount = computed(() => this.firing().filter(a => a.severity === 'Critical').length);\n protected readonly counts = computed(() => {\n const counts: Partial<Record<HealthState, number>> = {};\n for (const h of this.health.value() ?? []) counts[h.state] = (counts[h.state] ?? 0) + 1;\n return counts;\n });\n protected readonly attention = computed(() => (this.health.value() ?? [])\n .filter(h => h.state !== 'Healthy')\n .sort((a, b) => ORDER.indexOf(a.state) - ORDER.indexOf(b.state)));\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,aAAa;AAEnB,MAAM,cAA6C;CACjD,IAAI;CAAqB,MAAM;CAAsB,KAAK;CAAuB,SAAS;AAC3F;AAED,MAAM,iBAAyC;CAC7C,kBAAkB;CAAkB,gCAAgC;CAA+B,mBAAmB;AACvH;AAED,SAAgB,WAAW,WAAoC;CAC7D,IAAI,cAAc,QAAQ,cAAc,QAAW,OAAO;CAC1D,OAAO,aAAa,MAAO,IAAI,YAAY,IAAA,CAAM,QAAQ,aAAa,MAAU,IAAI,CAAC,EAAC,OAAQ,GAAG,UA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