@juice-js/observability 1.1.0-alpha.32 → 1.1.0-alpha.35

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.
@@ -1 +1 @@
1
- {"version":3,"file":"juice-js-observability.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/core/api.service.ts","../../../../projects/juice-js/observability/src/lib/core/approval-count.ts","../../../../projects/juice-js/observability/src/lib/core/options.ts","../../../../projects/juice-js/observability/src/lib/core/context.service.ts","../../../../projects/juice-js/observability/src/lib/observability.routes.ts"],"sourcesContent":["import { HttpClient, HttpParams } from '@angular/common/http';\nimport { Injectable, inject, signal } from '@angular/core';\nimport { EMPTY, Observable, expand, map, reduce, shareReplay, switchMap, tap } from 'rxjs';\nimport { OBSERVABILITY_OPTIONS } from './options';\nimport {\n ActionRequest, ActionRequestsWaiting, ActionTarget, Agent, SloDetail, SloSummary, AgentActions, AgentCommand, AgentPackage, EnrollmentToken, AlertDetail, AlertNotifications, Alert, AllowlistEntry, Application, Channel, ChannelTestResult, Delivery, EscalationPolicy, IncidentDetail, IncidentEvent, IncidentSummary, Silence, DependencyEvidence, DependencyStatsPage, DeploymentEnvironment, LoadRun, LoadRunResults, Related, Timeline, Health, LogRecord, MetricInfo, Operation,\n Page, ResourceDetail, ResourceSummary, Rule, SearchHit, Series, Capacity, ServiceStats, Tenant, TelemetryPage, Topology, Trace,\n TraceSummary,\n} from './models';\n\n/**\n * A random UUID v4 for `Idempotency-Key`. Not `crypto.randomUUID()`: browsers offer it only in a secure context (HTTPS or localhost), so it\n * throws on a Console opened over plain HTTP at the machine's address, as the local stack is. `getRandomValues` works everywhere.\n */\nexport function idempotencyKey(): string {\n const b = crypto.getRandomValues(new Uint8Array(16));\n b[6] = (b[6] & 0x0f) | 0x40;\n b[8] = (b[8] & 0x3f) | 0x80;\n const hex = Array.from(b, x => x.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nexport type Query =Record<string, string | number | boolean | string[] | null | undefined>;\n\n/**\n * The Console's only backend: the Juice API (Console requirements §3). One deployment serves one tenant, the one the\n * signed-in user's token names.\n */\n@Injectable({ providedIn: 'root' })\nexport class ApiService {\n private readonly http = inject(HttpClient);\n private readonly base = `${inject(OBSERVABILITY_OPTIONS).apiBase}/api/v1`;\n\n /** Set once a page has fetched the caller's tenant: the user is signed in, so background calls such as {@link ApprovalCount}'s may start. */\n readonly tenantKnown = signal(false);\n\n /** The caller's tenant, fetched once. */\n readonly tenant$: Observable<Tenant> = this.http.get<Page<Tenant>>(`${this.base}/tenants`).pipe(\n map(page => {\n if (page.items.length === 0) throw new Error('No tenant is authorized for this user.');\n return page.items[0];\n }),\n tap(() => this.tenantKnown.set(true)),\n shareReplay(1),\n );\n\n private get<T>(path: string, query: Query = {}): Observable<T> {\n let params = new HttpParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === null || value === undefined || value === '') continue;\n for (const item of Array.isArray(value) ? value : [value]) params = params.append(key, String(item));\n }\n return this.tenant$.pipe(switchMap(t => this.http.get<T>(`${this.base}/tenants/${t.id}${path}`, { params })));\n }\n\n /** A change. `Idempotency-Key` on what can be retried, so a repeated click or a lost response doesn't do it twice. */\n private send<T>(method: 'POST' | 'PUT' | 'DELETE', path: string, body?: unknown, headers: Record<string, string> = {}): Observable<T> {\n return this.tenant$.pipe(switchMap(t => this.http.request<T>(method, `${this.base}/tenants/${t.id}${path}`, { body, headers })));\n }\n private once<T>(path: string, body: unknown): Observable<T> { return this.send<T>('POST', path, body, { 'Idempotency-Key': idempotencyKey() }); }\n\n /** Every page of a cursor-paged list (bounded: at most `maxPages` requests). */\n private all<T>(path: string, query: Query = {}, maxPages = 25): Observable<Page<T>> {\n let pages = 0;\n return this.get<Page<T>>(path, { ...query, limit: 200 }).pipe(\n expand(page => page.nextCursor && ++pages < maxPages ? this.get<Page<T>>(path, { ...query, limit: 200, cursor: page.nextCursor }) : EMPTY),\n reduce((all, page) => ({ items: [...all.items, ...page.items], nextCursor: page.nextCursor }), { items: [] as T[], nextCursor: null as string | null }),\n );\n }\n\n environments() { return this.get<Page<DeploymentEnvironment>>('/environments'); }\n applications() { return this.get<Page<Application>>('/applications', { limit: 200 }); }\n resources(type?: string) { return this.all<ResourceSummary>('/resources', { type }); }\n resource(id: string) { return this.get<ResourceDetail>(`/resources/${id}`); }\n health(query: Query) { return this.all<Health>('/health', query); }\n topology(environment?: string | null) { return this.get<Topology>('/topology', { environment }); }\n\n rules() { return this.get<Page<Rule>>('/rules', { limit: 200 }); }\n createRule(definition: unknown) { return this.send<Rule>('POST', '/rules', definition); }\n /** With the rule's etag, so a change made since it was read isn't overwritten. */\n updateRule(key: string, definition: unknown, etag: string) { return this.send<Rule>('PUT', `/rules/${key}`, definition, { 'If-Match': `\"${etag}\"` }); }\n\n channels() { return this.get<Page<Channel>>('/webhooks'); }\n createChannel(body: unknown) { return this.send<Channel>('POST', '/webhooks', body); }\n updateChannel(id: string, body: unknown) { return this.send<Channel>('PUT', `/webhooks/${id}`, body); }\n deliveries(id: string, query: Query = {}) { return this.get<Page<Delivery>>(`/webhooks/${id}/deliveries`, { limit: 50, ...query }); }\n testChannel(id: string) { return this.send<ChannelTestResult>('POST', `/webhooks/${id}/test`); }\n retryDelivery(channelId: string, deliveryId: string) { return this.send<Delivery>('POST', `/webhooks/${channelId}/deliveries/${deliveryId}/retry`); }\n allowlist() { return this.get<Page<AllowlistEntry>>('/webhooks/allowlist'); }\n putAllowlist(destination: string, ports: number[]) { return this.send<AllowlistEntry>('PUT', '/webhooks/allowlist', { destination, ports }); }\n removeAllowlist(destination: string) { return this.send<void>('DELETE', `/webhooks/allowlist?destination=${encodeURIComponent(destination)}`); }\n\n escalationPolicies() { return this.get<Page<EscalationPolicy>>('/escalation-policies'); }\n createEscalationPolicy(body: unknown) { return this.send<EscalationPolicy>('POST', '/escalation-policies', body); }\n updateEscalationPolicy(key: string, body: unknown) { return this.send<EscalationPolicy>('PUT', `/escalation-policies/${key}`, body); }\n\n silences(query: Query = {}) { return this.get<Page<Silence>>('/silences', { limit: 200, ...query }); }\n createSilence(body: unknown) { return this.once<Silence>('/silences', body); }\n cancelSilence(id: string) { return this.send<void>('DELETE', `/silences/${id}`); }\n\n incidents(query: Query = {}) { return this.get<Page<IncidentSummary>>('/incidents', { limit: 100, ...query }); }\n incident(id: string) { return this.get<IncidentDetail>(`/incidents/${id}`); }\n createIncident(body: unknown) { return this.once<IncidentSummary>('/incidents', body); }\n moveIncident(id: string, to: string, comment: string) { return this.once<IncidentSummary>(`/incidents/${id}/transitions`, { to, comment }); }\n addIncidentNote(id: string, text: string) { return this.once<IncidentEvent>(`/incidents/${id}/notes`, { text }); }\n removeIncidentAlert(id: string, alertId: string) { return this.send<void>('DELETE', `/incidents/${id}/alerts/${alertId}`); }\n /** Active agents, or with `all` the revoked ones too (at most 500). */\n agents(all = false) { return this.get<Page<Agent>>('/agents', { all: all || null }); }\n agent(id: string) { return this.get<Agent>(`/agents/${id}`); }\n createEnrollmentToken(purpose: string, expiresInMinutes: number) { return this.send<EnrollmentToken>('POST', '/agents/enrollment-tokens', { purpose, expiresInMinutes }); }\n revokeAgent(id: string, reason: string) { return this.send<Agent>('POST', `/agents/${id}/revocation`, { reason }); }\n /** What the agent reported it can run, custom actions included, with what its host permits; the built-ins if it never reported. */\n agentActions(id: string) { return this.get<AgentActions>(`/agents/${id}/actions`); }\n agentPackages() { return this.get<Page<AgentPackage>>('/agents/packages'); }\n /** Idempotent: a repeated click or a lost response signs one command, not two. */\n issueCommand(id: string, action: string, parameters: Record<string, unknown>) { return this.once<AgentCommand>(`/agents/${id}/commands`, { action, parameters }); }\n /** Asks for an action under its approval policy: issued at once when nobody else needs to approve, otherwise waiting. */\n requestAction(agentId: string, action: string, parameters: Record<string, unknown>, reason: string, target: ActionTarget | null = null) {\n return this.once<ActionRequest>(`/agents/${agentId}/action-requests`, { action, parameters, reason, target });\n }\n actionRequests(query: Query = {}) { return this.get<Page<ActionRequest>>('/action-requests', { limit: 100, ...query }); }\n /** A diagnostic bundle's zip (operators and admins; audited). */\n downloadBundle(agentId: string, bundleId: string) {\n return this.tenant$.pipe(switchMap(t => this.http.get(`${this.base}/tenants/${t.id}/agents/${agentId}/bundles/${bundleId}`, { responseType: 'blob', observe: 'response' })));\n }\n /** SLOs, technical or business apart (category), with their budgets and burn rates. */\n slos(category?: string) { return this.get<Page<SloSummary>>('/slos', { category }); }\n slo(key: string) { return this.get<SloDetail>(`/slos/${encodeURIComponent(key)}`); }\n /** How many requests wait, and how many of them the signed-in user can decide. */\n waitingRequests() { return this.get<ActionRequestsWaiting>('/action-requests/waiting'); }\n approveRequest(id: string, comment: string) { return this.send<ActionRequest>('POST', `/action-requests/${id}/approval`, { comment }); }\n rejectRequest(id: string, comment: string) { return this.send<ActionRequest>('POST', `/action-requests/${id}/rejection`, { comment }); }\n cancelRequest(id: string) { return this.send<ActionRequest>('POST', `/action-requests/${id}/cancellation`, {}); }\n agentCommands(id: string, cursor?: string | null) { return this.get<Page<AgentCommand>>(`/agents/${id}/commands`, { limit: 25, cursor }); }\n\n alertNotifications(id: string) { return this.get<AlertNotifications>(`/alerts/${id}/notifications`); }\n\n /** One page of alerts, newest first; pass the previous page's `nextCursor` as `cursor` for the next. */\n alerts(query: Query) { return this.get<Page<Alert>>('/alerts', { limit: 100, ...query }); }\n /** Every alert matching the query (bounded, like the other complete lists). */\n allAlerts(query: Query) { return this.all<Alert>('/alerts', query); }\n alert(id: string) { return this.get<AlertDetail>(`/alerts/${id}`); }\n acknowledge(id: string, comment: string): Observable<Alert> {\n return this.tenant$.pipe(switchMap(t => this.http.post<Alert>(`${this.base}/tenants/${t.id}/alerts/${id}/acknowledgement`,\n { comment }, { headers: { 'Idempotency-Key': idempotencyKey() } })));\n }\n\n traces(query: Query) { return this.get<TelemetryPage<TraceSummary>>('/telemetry/traces', query); }\n trace(traceId: string) { return this.get<Trace>(`/telemetry/traces/${traceId}`); }\n logs(query: Query) { return this.get<TelemetryPage<LogRecord>>('/telemetry/logs', query); }\n operations(query: Query) { return this.get<TelemetryPage<Operation>>('/telemetry/operations', query); }\n metrics(query: Query) { return this.get<TelemetryPage<MetricInfo>>('/telemetry/metrics', query); }\n series(query: Query) { return this.get<Series>('/telemetry/metrics/series', query); }\n serviceStats(query: Query) { return this.get<ServiceStats>('/telemetry/service-stats', query); }\n capacity(query: Query) { return this.get<Capacity>('/telemetry/capacity', query); }\n timeline(query: Query) { return this.get<Timeline>('/timeline', query); }\n relatedToAlert(id: string) { return this.get<Related>(`/alerts/${id}/related`); }\n loadRuns(query: Query) { return this.get<Page<LoadRun>>('/load-runs', query); }\n loadRunResults(id: string) { return this.get<LoadRunResults>(`/load-runs/${id}/results`); }\n dependencyStats(query: Query) { return this.get<DependencyStatsPage>('/telemetry/dependencies', query); }\n dependency(id: string, query: Query) { return this.get<DependencyEvidence>(`/telemetry/dependencies/${id}`, query); }\n search(q: string) { return this.get<TelemetryPage<SearchHit>>('/search', { q }); }\n}\n","import { DestroyRef, Injectable, effect, inject, signal, untracked } from '@angular/core';\nimport { NavigationEnd, Router } from '@angular/router';\nimport { Subscription, filter, timer, switchMap } from 'rxjs';\nimport { ApiService } from './api.service';\n\n/**\n * How many action requests wait for the signed-in user to decide, refreshed every 30 seconds from whatever page is open, and at once\n * when a page made or decided one ({@link refresh}). It starts only once a page has fetched the tenant: before that the user may still be\n * signing in, and an early call would fail, along with the page's own call sharing it. It stops on an error (signed out, or no rights)\n * until the next navigation, so a signed-out tab doesn't keep asking.\n */\n@Injectable({ providedIn: 'root' })\nexport class ApprovalCount {\n static readonly Every = 30_000;\n\n private readonly api = inject(ApiService);\n private polling: Subscription | null = null;\n /** Requests the signed-in user can approve or reject now. */\n readonly forYou = signal(0);\n\n constructor() {\n effect(() => { if (this.api.tenantKnown() && !untracked(() => this.polling)) untracked(() => this.start()); });\n const navigations = inject(Router).events.pipe(filter(e => e instanceof NavigationEnd))\n .subscribe(() => { if (!this.polling && this.api.tenantKnown()) this.start(); });\n inject(DestroyRef).onDestroy(() => { navigations.unsubscribe(); this.polling?.unsubscribe(); });\n }\n\n /** Asks again now, for a page that just changed what waits. */\n refresh() { if (this.api.tenantKnown()) this.start(); }\n\n private start() {\n this.polling?.unsubscribe();\n this.polling = timer(0, ApprovalCount.Every).pipe(switchMap(() => this.api.waitingRequests())).subscribe({\n next: w => this.forYou.set(w.forYou),\n error: () => { this.forYou.set(0); this.polling = null; },\n });\n }\n}\n\n/**\n * Shows {@link ApprovalCount} on the Approvals entry of juice-layout's side menu, found by its icon. juice-layout's menu has no badge of its\n * own, so this adds one beside the label and puts it back whenever the menu is drawn again.\n */\n@Injectable({ providedIn: 'root' })\nexport class ApprovalMenuBadge {\n static readonly Icon = 'approval';\n\n private readonly count = inject(ApprovalCount);\n private observer: MutationObserver | null = null;\n\n constructor() {\n if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return;\n effect(() => this.apply(this.count.forYou()));\n let scheduled = false;\n this.observer = new MutationObserver(() => {\n if (scheduled) return;\n scheduled = true;\n requestAnimationFrame(() => { scheduled = false; this.apply(this.count.forYou()); });\n });\n this.observer.observe(document.body, { childList: true, subtree: true });\n inject(DestroyRef).onDestroy(() => this.observer?.disconnect());\n }\n\n private apply(count: number) {\n for (const icon of Array.from(document.querySelectorAll<HTMLElement>('juice-nav-menu mat-icon'))) {\n if (icon.textContent?.trim() !== ApprovalMenuBadge.Icon) continue;\n const item = icon.closest<HTMLElement>('mat-list-item, .mat-mdc-list-item');\n const title = item?.querySelector<HTMLElement>('[matListItemTitle], .mdc-list-item__primary-text');\n if (!item || !title) continue;\n let badge = title.querySelector<HTMLElement>('.jc-menu-badge');\n if (count <= 0) { badge?.remove(); item.removeAttribute('title'); continue; }\n if (!badge) {\n badge = document.createElement('span');\n badge.className = 'jc-menu-badge';\n badge.setAttribute('data-testid', 'approvals-badge');\n badge.style.cssText = 'display:inline-block;min-width:1.25rem;margin-left:.5rem;padding:0 .375rem;border-radius:999px;font-size:.75rem;'\n + 'line-height:1.25rem;text-align:center;font-weight:600;background:var(--mat-sys-error,#b3261e);color:var(--mat-sys-on-error,#fff)';\n title.appendChild(badge);\n }\n const text = count > 99 ? '99+' : String(count);\n if (badge.textContent !== text) badge.textContent = text;\n const hint = `${count} request${count === 1 ? '' : 's'} waiting for your approval`;\n if (item.getAttribute('title') !== hint) item.setAttribute('title', hint);\n }\n }\n}\n","import { EnvironmentProviders, Injectable, InjectionToken, Pipe, PipeTransform, inject, makeEnvironmentProviders, provideEnvironmentInitializer } from '@angular/core';\nimport { ApprovalMenuBadge } from './approval-count';\n\n/** How the host app mounts Juice Observability. */\nexport interface ObservabilityOptions {\n /** The Juice API origin; empty when the API serves the app (same origin). */\n apiBase: string;\n /** Where the host mounts {@link OBSERVABILITY_ROUTES}: `/` for the whole app, or a path such as `/observability`. */\n basePath: string;\n /**\n * A link to the audit records of a trace, shown on the trace page: for the Juice Audit pages mounted at `/audit`,\n * `id => ['/audit/traces', id]`. A string is an external URL. Without it, no link.\n */\n auditLink?: ((traceId: string) => unknown[] | string | null) | null;\n /** Show on the Approvals menu entry how many action requests wait for the signed-in user. On unless false. */\n approvalCount?: boolean;\n}\n\nexport const OBSERVABILITY_OPTIONS = new InjectionToken<ObservabilityOptions>('OBSERVABILITY_OPTIONS', {\n providedIn: 'root',\n factory: () => ({ apiBase: '', basePath: '/', auditLink: null }),\n});\n\n/**\n * Configures the pages: where the API is, where the host mounted the routes, and where a trace's audit records open. Also shows the count\n * of requests waiting for approval on the Approvals menu entry, unless `approvalCount: false`.\n */\nexport function provideJuiceObservability(options: Partial<ObservabilityOptions> = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: OBSERVABILITY_OPTIONS,\n useValue: {\n apiBase: options.apiBase ?? '',\n basePath: options.basePath ?? '/',\n auditLink: options.auditLink ?? null,\n } satisfies ObservabilityOptions,\n },\n ...(options.approvalCount === false ? [] : [provideEnvironmentInitializer(() => { inject(ApprovalMenuBadge); })]),\n ]);\n}\n\n/** `/observability/` → `/observability`; `` and `/` → `/`. */\nexport function normalizeBasePath(basePath: string): string {\n const trimmed = basePath.trim().replace(/^\\/+|\\/+$/g, '');\n return trimmed ? `/${trimmed}` : '/';\n}\n\n/** Router links to the pages, under the host's mount path. */\n@Injectable({ providedIn: 'root' })\nexport class ObservabilityLinks {\n private readonly options = inject(OBSERVABILITY_OPTIONS);\n readonly base = normalizeBasePath(this.options.basePath);\n\n /** `to('services', id)` → `['/observability', 'services', id]`. */\n to(...segments: unknown[]): unknown[] { return [this.base, ...segments]; }\n\n /** The host's link to the audit records of a trace, if it gave one. */\n audit(traceId: string | null | undefined): { route: unknown[] } | { href: string } | null {\n if (!traceId || !this.options.auditLink) return null;\n const link = this.options.auditLink(traceId);\n if (!link) return null;\n return typeof link === 'string' ? { href: link } : { route: link };\n }\n}\n\n/** `['services', id] | jcLink`: the same as {@link ObservabilityLinks.to} in a template. */\n@Pipe({ name: 'jcLink' })\nexport class LinkPipe implements PipeTransform {\n private readonly links = inject(ObservabilityLinks);\n transform(segments: unknown[]): unknown[] { return this.links.to(...segments); }\n}\n","import { Injectable, computed, inject } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router';\nimport { filter, map, startWith } from 'rxjs';\n\nexport const RANGES: Record<string, number> = {\n '15m': 15 * 60_000, '1h': 3_600_000, '6h': 6 * 3_600_000, '24h': 24 * 3_600_000, '7d': 7 * 24 * 3_600_000,\n};\n\n/** Search ranges are at most 24 hours (the API's bound); series and operations take up to 7 days. */\nexport const MAX_SEARCH_MS = RANGES['24h'];\n\n/**\n * The investigation context that follows the user between pages (Console requirements §17): environment and time\n * range. It lives in the URL (`env`, and `range` or `from`/`to`), so every page is a deep link and the browser's back\n * button restores it.\n */\n@Injectable({ providedIn: 'root' })\nexport class ContextService {\n private readonly router = inject(Router);\n\n // Created on first use, after the first navigation may already have ended: start from the current URL.\n private readonly params = toSignal(this.router.events.pipe(\n filter(e => e instanceof NavigationEnd),\n startWith(null),\n map(() => this.leaf().snapshot.queryParams),\n ), { initialValue: {} as Params });\n\n readonly environment = computed(() => (this.params()['env'] as string | undefined) ?? '');\n readonly range = computed(() => {\n const p = this.params();\n return p['from'] && p['to'] ? 'custom' : ((p['range'] as string | undefined) ?? '1h');\n });\n readonly absolute = computed(() => {\n const p = this.params();\n return p['from'] && p['to'] ? { from: p['from'] as string, to: p['to'] as string } : null;\n });\n\n /** The window as ISO strings, evaluated now for a relative range. */\n window(maxMs?: number): { from: string; to: string } {\n const absolute = this.absolute();\n if (absolute) return absolute;\n const to = Date.now();\n const span = Math.min(RANGES[this.range()] ?? RANGES['1h'], maxMs ?? Number.MAX_SAFE_INTEGER);\n return { from: new Date(to - span).toISOString(), to: new Date(to).toISOString() };\n }\n\n /** Query parameters for a link: the context plus the target page's own. */\n keep(extra: Params = {}): Params {\n const p = this.params();\n const context: Params = {};\n for (const key of ['env', 'range', 'from', 'to']) if (p[key]) context[key] = p[key];\n return { ...context, ...extra };\n }\n\n /** Changes the context on the current page, keeping its other parameters. */\n set(change: { env?: string | null; range?: string | null; from?: string | null; to?: string | null }) {\n const queryParams: Params = { ...change };\n if (change.range) Object.assign(queryParams, { from: null, to: null });\n void this.router.navigate([], { relativeTo: this.leaf(), queryParams, queryParamsHandling: 'merge' });\n }\n\n /** A time window centred on a moment, for \"around this span\" links. */\n around(at: string, durationMs: number, paddingMs = 5 * 60_000): Params {\n const start = new Date(at).getTime();\n return this.keep({\n from: new Date(start - paddingMs).toISOString(),\n to: new Date(start + durationMs + paddingMs).toISOString(),\n range: null,\n });\n }\n\n private leaf(): ActivatedRoute {\n let route = this.router.routerState.root;\n while (route.firstChild) route = route.firstChild;\n return route;\n }\n}\n","import { Routes } from '@angular/router';\nimport { Menus } from '@juice-js/core';\nimport { normalizeBasePath } from './core/options';\n\nfunction page(path: string, title: string, load: Routes[number]['loadComponent']): Routes[number] {\n return { path, title: `${title} · Juice Observability`, loadComponent: load };\n}\n\n/**\n * The pages, investigation first (Console requirements §4): services, traces, topology, logs and metrics; alerts and\n * rules after. Detail pages are deep links (§17) and carry the environment and time range in their query parameters.\n * The host mounts them at its `basePath` (see {@link provideJuiceObservability}) and adds its own guards.\n */\nexport const OBSERVABILITY_ROUTES: Routes = [\n page('', 'Overview', () => import('./pages/overview.page').then(m => m.OverviewPage)),\n page('services', 'Services', () => import('./pages/services.page').then(m => m.ServicesPage)),\n page('services/:id', 'Service', () => import('./pages/service.page').then(m => m.ServicePage)),\n page('traces', 'Traces', () => import('./pages/traces.page').then(m => m.TracesPage)),\n page('traces/:traceId', 'Trace', () => import('./pages/trace.page').then(m => m.TracePage)),\n page('topology', 'Dependencies', () => import('./pages/topology.page').then(m => m.TopologyPage)),\n page('logs', 'Logs', () => import('./pages/logs.page').then(m => m.LogsPage)),\n page('metrics', 'Metrics', () => import('./pages/metrics.page').then(m => m.MetricsPage)),\n page('resources', 'Resources', () => import('./pages/resources.page').then(m => m.ResourcesPage)),\n page('resources/:id', 'Resource', () => import('./pages/resource.page').then(m => m.ResourcePage)),\n page('alerts', 'Alerts', () => import('./pages/alerts.page').then(m => m.AlertsPage)),\n page('alerts/:id', 'Alert', () => import('./pages/alert.page').then(m => m.AlertPage)),\n page('rules', 'Rules', () => import('./pages/rules.page').then(m => m.RulesPage)),\n page('notifications', 'Notifications', () => import('./pages/notifications.page').then(m => m.NotificationsPage)),\n page('silences', 'Silences', () => import('./pages/silences.page').then(m => m.SilencesPage)),\n page('incidents', 'Incidents', () => import('./pages/incidents.page').then(m => m.IncidentsPage)),\n page('incidents/:id', 'Incident', () => import('./pages/incident.page').then(m => m.IncidentPage)),\n page('agents', 'Agents', () => import('./pages/agents.page').then(m => m.AgentsPage)),\n page('agents/:id', 'Agent', () => import('./pages/agent.page').then(m => m.AgentPage)),\n page('approvals', 'Approvals', () => import('./pages/approvals.page').then(m => m.ApprovalsPage)),\n page('slos', 'SLOs', () => import('./pages/slos.page').then(m => m.SlosPage)),\n page('slos/:key', 'SLO', () => import('./pages/slo.page').then(m => m.SloPage)),\n page('timeline', 'Timeline', () => import('./pages/timeline.page').then(m => m.TimelinePage)),\n page('load-runs', 'Load runs', () => import('./pages/load-runs.page').then(m => m.LoadRunsPage)),\n];\n\n/** The side menu entries (juice-layout), investigation pages first, linking under `basePath`. */\nexport function observabilityMenus(basePath = '/', order = 1): Menus {\n const base = normalizeBasePath(basePath);\n const link = (path: string) => (base === '/' ? `/${path}` : path ? `${base}/${path}` : base);\n return [\n { id: 'overview', label: 'Overview', icon: 'dashboard', routerLink: link('') },\n { id: 'services', label: 'Services', icon: 'hub', routerLink: link('services') },\n { id: 'traces', label: 'Traces', icon: 'timeline', routerLink: link('traces') },\n { id: 'topology', label: 'Dependencies', icon: 'account_tree', routerLink: link('topology') },\n { id: 'logs', label: 'Logs', icon: 'notes', routerLink: link('logs') },\n { id: 'metrics', label: 'Metrics', icon: 'show_chart', routerLink: link('metrics') },\n { id: 'resources', label: 'Resources', icon: 'dns', routerLink: link('resources') },\n { id: 'alerts', label: 'Alerts', icon: 'notifications', routerLink: link('alerts') },\n { id: 'incidents', label: 'Incidents', icon: 'emergency', routerLink: link('incidents') },\n { id: 'rules', label: 'Rules', icon: 'rule', routerLink: link('rules') },\n { id: 'silences', label: 'Silences', icon: 'notifications_paused', routerLink: link('silences') },\n { id: 'notifications', label: 'Notifications', icon: 'campaign', routerLink: link('notifications') },\n { id: 'slos', label: 'SLOs', icon: 'track_changes', routerLink: link('slos') },\n { id: 'agents', label: 'Agents', icon: 'smart_toy', routerLink: link('agents') },\n { id: 'approvals', label: 'Approvals', icon: 'approval', routerLink: link('approvals') },\n { id: 'timeline', label: 'Timeline', icon: 'history', routerLink: link('timeline') },\n { id: 'load-runs', label: 'Load runs', icon: 'speed', routerLink: link('load-runs') },\n ].map((menu, index) => ({ ...menu, order: order + index }));\n}\n"],"mappings":";;;;;;AAcA,SAAgB,iBAAc;CA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AAM;GAAY,YAAY,KAAK,WAAW;EAAC;EACtF;GAAE,IAAI;GAAY,OAAO;GAAY,MAAM;GAAW,YAAY,KAAK,UAAU;EAAC;EAClF;GAAE,IAAI;GAAa,OAAO;GAAa,MAAM;GAAS,YAAY,KAAK,WAAW;EAAC;CACpF,CAAA,CAAC,KAAK,MAAM,WAAW;EAAE,GAAG;EAAM,OAAO,QAAQ;CAAK,EAAG;AAC5D"}
1
+ {"version":3,"file":"juice-js-observability.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/core/api.service.ts","../../../../projects/juice-js/observability/src/lib/core/approval-count.ts","../../../../projects/juice-js/observability/src/lib/core/options.ts","../../../../projects/juice-js/observability/src/lib/core/context.service.ts","../../../../projects/juice-js/observability/src/lib/observability.routes.ts"],"sourcesContent":["import { HttpClient, HttpParams } from '@angular/common/http';\nimport { Injectable, inject, signal } from '@angular/core';\nimport { EMPTY, Observable, expand, map, reduce, shareReplay, switchMap, tap } from 'rxjs';\nimport { OBSERVABILITY_OPTIONS } from './options';\nimport {\n ActionRequest, ActionRequestsWaiting, ActionTarget, Agent, SloDetail, SloSummary, AgentActions, AgentCommand, AgentPackage, EnrollmentToken, AlertDetail, AlertNotifications, Alert, AllowlistEntry, Application, Channel, ChannelTestResult, Delivery, EscalationPolicy, IncidentDetail, IncidentEvent, IncidentSummary, Silence, DependencyEvidence, DependencyStatsPage, DeploymentEnvironment, LoadRun, LoadRunResults, Related, Timeline, Health, LogRecord, MetricInfo, Operation,\n Page, ResourceDetail, ResourceSummary, Rule, SearchHit, Series, Capacity, ServiceStats, Tenant, TelemetryPage, Topology, Trace,\n TraceSummary, Suggestions, CorrelationDecision,\n} from './models';\n\n/**\n * A random UUID v4 for `Idempotency-Key`. Not `crypto.randomUUID()`: browsers offer it only in a secure context (HTTPS or localhost), so it\n * throws on a Console opened over plain HTTP at the machine's address, as the local stack is. `getRandomValues` works everywhere.\n */\nexport function idempotencyKey(): string {\n const b = crypto.getRandomValues(new Uint8Array(16));\n b[6] = (b[6] & 0x0f) | 0x40;\n b[8] = (b[8] & 0x3f) | 0x80;\n const hex = Array.from(b, x => x.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nexport type Query =Record<string, string | number | boolean | string[] | null | undefined>;\n\n/**\n * The Console's only backend: the Juice API (Console requirements §3). One deployment serves one tenant, the one the\n * signed-in user's token names.\n */\n@Injectable({ providedIn: 'root' })\nexport class ApiService {\n private readonly http = inject(HttpClient);\n private readonly base = `${inject(OBSERVABILITY_OPTIONS).apiBase}/api/v1`;\n\n /** Set once a page has fetched the caller's tenant: the user is signed in, so background calls such as {@link ApprovalCount}'s may start. */\n readonly tenantKnown = signal(false);\n\n /** The caller's tenant, fetched once. */\n readonly tenant$: Observable<Tenant> = this.http.get<Page<Tenant>>(`${this.base}/tenants`).pipe(\n map(page => {\n if (page.items.length === 0) throw new Error('No tenant is authorized for this user.');\n return page.items[0];\n }),\n tap(() => this.tenantKnown.set(true)),\n shareReplay(1),\n );\n\n private get<T>(path: string, query: Query = {}): Observable<T> {\n let params = new HttpParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === null || value === undefined || value === '') continue;\n for (const item of Array.isArray(value) ? value : [value]) params = params.append(key, String(item));\n }\n return this.tenant$.pipe(switchMap(t => this.http.get<T>(`${this.base}/tenants/${t.id}${path}`, { params })));\n }\n\n /** A change. `Idempotency-Key` on what can be retried, so a repeated click or a lost response doesn't do it twice. */\n private send<T>(method: 'POST' | 'PUT' | 'DELETE', path: string, body?: unknown, headers: Record<string, string> = {}): Observable<T> {\n return this.tenant$.pipe(switchMap(t => this.http.request<T>(method, `${this.base}/tenants/${t.id}${path}`, { body, headers })));\n }\n private once<T>(path: string, body: unknown): Observable<T> { return this.send<T>('POST', path, body, { 'Idempotency-Key': idempotencyKey() }); }\n\n /** Every page of a cursor-paged list (bounded: at most `maxPages` requests). */\n private all<T>(path: string, query: Query = {}, maxPages = 25): Observable<Page<T>> {\n let pages = 0;\n return this.get<Page<T>>(path, { ...query, limit: 200 }).pipe(\n expand(page => page.nextCursor && ++pages < maxPages ? this.get<Page<T>>(path, { ...query, limit: 200, cursor: page.nextCursor }) : EMPTY),\n reduce((all, page) => ({ items: [...all.items, ...page.items], nextCursor: page.nextCursor }), { items: [] as T[], nextCursor: null as string | null }),\n );\n }\n\n environments() { return this.get<Page<DeploymentEnvironment>>('/environments'); }\n applications() { return this.get<Page<Application>>('/applications', { limit: 200 }); }\n resources(type?: string) { return this.all<ResourceSummary>('/resources', { type }); }\n resource(id: string) { return this.get<ResourceDetail>(`/resources/${id}`); }\n health(query: Query) { return this.all<Health>('/health', query); }\n topology(environment?: string | null) { return this.get<Topology>('/topology', { environment }); }\n\n rules() { return this.get<Page<Rule>>('/rules', { limit: 200 }); }\n createRule(definition: unknown) { return this.send<Rule>('POST', '/rules', definition); }\n /** With the rule's etag, so a change made since it was read isn't overwritten. */\n updateRule(key: string, definition: unknown, etag: string) { return this.send<Rule>('PUT', `/rules/${key}`, definition, { 'If-Match': `\"${etag}\"` }); }\n\n channels() { return this.get<Page<Channel>>('/webhooks'); }\n createChannel(body: unknown) { return this.send<Channel>('POST', '/webhooks', body); }\n updateChannel(id: string, body: unknown) { return this.send<Channel>('PUT', `/webhooks/${id}`, body); }\n deliveries(id: string, query: Query = {}) { return this.get<Page<Delivery>>(`/webhooks/${id}/deliveries`, { limit: 50, ...query }); }\n testChannel(id: string) { return this.send<ChannelTestResult>('POST', `/webhooks/${id}/test`); }\n retryDelivery(channelId: string, deliveryId: string) { return this.send<Delivery>('POST', `/webhooks/${channelId}/deliveries/${deliveryId}/retry`); }\n allowlist() { return this.get<Page<AllowlistEntry>>('/webhooks/allowlist'); }\n putAllowlist(destination: string, ports: number[]) { return this.send<AllowlistEntry>('PUT', '/webhooks/allowlist', { destination, ports }); }\n removeAllowlist(destination: string) { return this.send<void>('DELETE', `/webhooks/allowlist?destination=${encodeURIComponent(destination)}`); }\n\n escalationPolicies() { return this.get<Page<EscalationPolicy>>('/escalation-policies'); }\n createEscalationPolicy(body: unknown) { return this.send<EscalationPolicy>('POST', '/escalation-policies', body); }\n updateEscalationPolicy(key: string, body: unknown) { return this.send<EscalationPolicy>('PUT', `/escalation-policies/${key}`, body); }\n\n silences(query: Query = {}) { return this.get<Page<Silence>>('/silences', { limit: 200, ...query }); }\n createSilence(body: unknown) { return this.once<Silence>('/silences', body); }\n cancelSilence(id: string) { return this.send<void>('DELETE', `/silences/${id}`); }\n\n incidents(query: Query = {}) { return this.get<Page<IncidentSummary>>('/incidents', { limit: 100, ...query }); }\n incident(id: string) { return this.get<IncidentDetail>(`/incidents/${id}`); }\n createIncident(body: unknown) { return this.once<IncidentSummary>('/incidents', body); }\n moveIncident(id: string, to: string, comment: string) { return this.once<IncidentSummary>(`/incidents/${id}/transitions`, { to, comment }); }\n addIncidentNote(id: string, text: string) { return this.once<IncidentEvent>(`/incidents/${id}/notes`, { text }); }\n removeIncidentAlert(id: string, alertId: string) { return this.send<void>('DELETE', `/incidents/${id}/alerts/${alertId}`); }\n /** Active agents, or with `all` the revoked ones too (at most 500). */\n agents(all = false) { return this.get<Page<Agent>>('/agents', { all: all || null }); }\n agent(id: string) { return this.get<Agent>(`/agents/${id}`); }\n createEnrollmentToken(purpose: string, expiresInMinutes: number) { return this.send<EnrollmentToken>('POST', '/agents/enrollment-tokens', { purpose, expiresInMinutes }); }\n revokeAgent(id: string, reason: string) { return this.send<Agent>('POST', `/agents/${id}/revocation`, { reason }); }\n /** What the agent reported it can run, custom actions included, with what its host permits; the built-ins if it never reported. */\n agentActions(id: string) { return this.get<AgentActions>(`/agents/${id}/actions`); }\n agentPackages() { return this.get<Page<AgentPackage>>('/agents/packages'); }\n /** Idempotent: a repeated click or a lost response signs one command, not two. */\n issueCommand(id: string, action: string, parameters: Record<string, unknown>) { return this.once<AgentCommand>(`/agents/${id}/commands`, { action, parameters }); }\n /** Asks for an action under its approval policy: issued at once when nobody else needs to approve, otherwise waiting. */\n requestAction(agentId: string, action: string, parameters: Record<string, unknown>, reason: string, target: ActionTarget | null = null) {\n return this.once<ActionRequest>(`/agents/${agentId}/action-requests`, { action, parameters, reason, target });\n }\n actionRequests(query: Query = {}) { return this.get<Page<ActionRequest>>('/action-requests', { limit: 100, ...query }); }\n /** A diagnostic bundle's zip (operators and admins; audited). */\n downloadBundle(agentId: string, bundleId: string) {\n return this.tenant$.pipe(switchMap(t => this.http.get(`${this.base}/tenants/${t.id}/agents/${agentId}/bundles/${bundleId}`, { responseType: 'blob', observe: 'response' })));\n }\n /** SLOs, technical or business apart (category), with their budgets and burn rates. */\n slos(category?: string) { return this.get<Page<SloSummary>>('/slos', { category }); }\n slo(key: string) { return this.get<SloDetail>(`/slos/${encodeURIComponent(key)}`); }\n /** How many requests wait, and how many of them the signed-in user can decide. */\n waitingRequests() { return this.get<ActionRequestsWaiting>('/action-requests/waiting'); }\n approveRequest(id: string, comment: string) { return this.send<ActionRequest>('POST', `/action-requests/${id}/approval`, { comment }); }\n rejectRequest(id: string, comment: string) { return this.send<ActionRequest>('POST', `/action-requests/${id}/rejection`, { comment }); }\n cancelRequest(id: string) { return this.send<ActionRequest>('POST', `/action-requests/${id}/cancellation`, {}); }\n agentCommands(id: string, cursor?: string | null) { return this.get<Page<AgentCommand>>(`/agents/${id}/commands`, { limit: 25, cursor }); }\n\n alertNotifications(id: string) { return this.get<AlertNotifications>(`/alerts/${id}/notifications`); }\n\n /** One page of alerts, newest first; pass the previous page's `nextCursor` as `cursor` for the next. */\n alerts(query: Query) { return this.get<Page<Alert>>('/alerts', { limit: 100, ...query }); }\n /** Every alert matching the query (bounded, like the other complete lists). */\n allAlerts(query: Query) { return this.all<Alert>('/alerts', query); }\n alert(id: string) { return this.get<AlertDetail>(`/alerts/${id}`); }\n acknowledge(id: string, comment: string): Observable<Alert> {\n return this.tenant$.pipe(switchMap(t => this.http.post<Alert>(`${this.base}/tenants/${t.id}/alerts/${id}/acknowledgement`,\n { comment }, { headers: { 'Idempotency-Key': idempotencyKey() } })));\n }\n\n traces(query: Query) { return this.get<TelemetryPage<TraceSummary>>('/telemetry/traces', query); }\n trace(traceId: string) { return this.get<Trace>(`/telemetry/traces/${traceId}`); }\n logs(query: Query) { return this.get<TelemetryPage<LogRecord>>('/telemetry/logs', query); }\n operations(query: Query) { return this.get<TelemetryPage<Operation>>('/telemetry/operations', query); }\n metrics(query: Query) { return this.get<TelemetryPage<MetricInfo>>('/telemetry/metrics', query); }\n series(query: Query) { return this.get<Series>('/telemetry/metrics/series', query); }\n serviceStats(query: Query) { return this.get<ServiceStats>('/telemetry/service-stats', query); }\n capacity(query: Query) { return this.get<Capacity>('/telemetry/capacity', query); }\n timeline(query: Query) { return this.get<Timeline>('/timeline', query); }\n relatedToAlert(id: string) { return this.get<Related>(`/alerts/${id}/related`); }\n alertSuggestions(id: string) { return this.get<Suggestions>(`/alerts/${id}/suggestions`); }\n incidentSuggestions(id: string) { return this.get<Suggestions>(`/incidents/${id}/suggestions`); }\n acceptSuggestion(alertId: string, otherId: string) { return this.once<CorrelationDecision>(`/alerts/${alertId}/suggestions/${otherId}/accept`, {}); }\n dismissSuggestion(alertId: string, otherId: string, reason: string) { return this.once<CorrelationDecision>(`/alerts/${alertId}/suggestions/${otherId}/dismiss`, { reason }); }\n loadRuns(query: Query) { return this.get<Page<LoadRun>>('/load-runs', query); }\n loadRunResults(id: string) { return this.get<LoadRunResults>(`/load-runs/${id}/results`); }\n dependencyStats(query: Query) { return this.get<DependencyStatsPage>('/telemetry/dependencies', query); }\n dependency(id: string, query: Query) { return this.get<DependencyEvidence>(`/telemetry/dependencies/${id}`, query); }\n search(q: string) { return this.get<TelemetryPage<SearchHit>>('/search', { q }); }\n}\n","import { DestroyRef, Injectable, effect, inject, signal, untracked } from '@angular/core';\nimport { NavigationEnd, Router } from '@angular/router';\nimport { Subscription, filter, timer, switchMap } from 'rxjs';\nimport { ApiService } from './api.service';\n\n/**\n * How many action requests wait for the signed-in user to decide, refreshed every 30 seconds from whatever page is open, and at once\n * when a page made or decided one ({@link refresh}). It starts only once a page has fetched the tenant: before that the user may still be\n * signing in, and an early call would fail, along with the page's own call sharing it. It stops on an error (signed out, or no rights)\n * until the next navigation, so a signed-out tab doesn't keep asking.\n */\n@Injectable({ providedIn: 'root' })\nexport class ApprovalCount {\n static readonly Every = 30_000;\n\n private readonly api = inject(ApiService);\n private polling: Subscription | null = null;\n /** Requests the signed-in user can approve or reject now. */\n readonly forYou = signal(0);\n\n constructor() {\n effect(() => { if (this.api.tenantKnown() && !untracked(() => this.polling)) untracked(() => this.start()); });\n const navigations = inject(Router).events.pipe(filter(e => e instanceof NavigationEnd))\n .subscribe(() => { if (!this.polling && this.api.tenantKnown()) this.start(); });\n inject(DestroyRef).onDestroy(() => { navigations.unsubscribe(); this.polling?.unsubscribe(); });\n }\n\n /** Asks again now, for a page that just changed what waits. */\n refresh() { if (this.api.tenantKnown()) this.start(); }\n\n private start() {\n this.polling?.unsubscribe();\n this.polling = timer(0, ApprovalCount.Every).pipe(switchMap(() => this.api.waitingRequests())).subscribe({\n next: w => this.forYou.set(w.forYou),\n error: () => { this.forYou.set(0); this.polling = null; },\n });\n }\n}\n\n/**\n * Shows {@link ApprovalCount} on the Approvals entry of juice-layout's side menu, found by its icon. juice-layout's menu has no badge of its\n * own, so this adds one beside the label and puts it back whenever the menu is drawn again.\n */\n@Injectable({ providedIn: 'root' })\nexport class ApprovalMenuBadge {\n static readonly Icon = 'approval';\n\n private readonly count = inject(ApprovalCount);\n private observer: MutationObserver | null = null;\n\n constructor() {\n if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return;\n effect(() => this.apply(this.count.forYou()));\n let scheduled = false;\n this.observer = new MutationObserver(() => {\n if (scheduled) return;\n scheduled = true;\n requestAnimationFrame(() => { scheduled = false; this.apply(this.count.forYou()); });\n });\n this.observer.observe(document.body, { childList: true, subtree: true });\n inject(DestroyRef).onDestroy(() => this.observer?.disconnect());\n }\n\n private apply(count: number) {\n for (const icon of Array.from(document.querySelectorAll<HTMLElement>('juice-nav-menu mat-icon'))) {\n if (icon.textContent?.trim() !== ApprovalMenuBadge.Icon) continue;\n const item = icon.closest<HTMLElement>('mat-list-item, .mat-mdc-list-item');\n const title = item?.querySelector<HTMLElement>('[matListItemTitle], .mdc-list-item__primary-text');\n if (!item || !title) continue;\n let badge = title.querySelector<HTMLElement>('.jc-menu-badge');\n if (count <= 0) { badge?.remove(); item.removeAttribute('title'); continue; }\n if (!badge) {\n badge = document.createElement('span');\n badge.className = 'jc-menu-badge';\n badge.setAttribute('data-testid', 'approvals-badge');\n badge.style.cssText = 'display:inline-block;min-width:1.25rem;margin-left:.5rem;padding:0 .375rem;border-radius:999px;font-size:.75rem;'\n + 'line-height:1.25rem;text-align:center;font-weight:600;background:var(--mat-sys-error,#b3261e);color:var(--mat-sys-on-error,#fff)';\n title.appendChild(badge);\n }\n const text = count > 99 ? '99+' : String(count);\n if (badge.textContent !== text) badge.textContent = text;\n const hint = `${count} request${count === 1 ? '' : 's'} waiting for your approval`;\n if (item.getAttribute('title') !== hint) item.setAttribute('title', hint);\n }\n }\n}\n","import { EnvironmentProviders, Injectable, InjectionToken, Pipe, PipeTransform, inject, makeEnvironmentProviders, provideEnvironmentInitializer } from '@angular/core';\nimport { ApprovalMenuBadge } from './approval-count';\n\n/** How the host app mounts Juice Observability. */\nexport interface ObservabilityOptions {\n /** The Juice API origin; empty when the API serves the app (same origin). */\n apiBase: string;\n /** Where the host mounts {@link OBSERVABILITY_ROUTES}: `/` for the whole app, or a path such as `/observability`. */\n basePath: string;\n /**\n * A link to the audit records of a trace, shown on the trace page: for the Juice Audit pages mounted at `/audit`,\n * `id => ['/audit/traces', id]`. A string is an external URL. Without it, no link.\n */\n auditLink?: ((traceId: string) => unknown[] | string | null) | null;\n /** Show on the Approvals menu entry how many action requests wait for the signed-in user. On unless false. */\n approvalCount?: boolean;\n}\n\nexport const OBSERVABILITY_OPTIONS = new InjectionToken<ObservabilityOptions>('OBSERVABILITY_OPTIONS', {\n providedIn: 'root',\n factory: () => ({ apiBase: '', basePath: '/', auditLink: null }),\n});\n\n/**\n * Configures the pages: where the API is, where the host mounted the routes, and where a trace's audit records open. Also shows the count\n * of requests waiting for approval on the Approvals menu entry, unless `approvalCount: false`.\n */\nexport function provideJuiceObservability(options: Partial<ObservabilityOptions> = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: OBSERVABILITY_OPTIONS,\n useValue: {\n apiBase: options.apiBase ?? '',\n basePath: options.basePath ?? '/',\n auditLink: options.auditLink ?? null,\n } satisfies ObservabilityOptions,\n },\n ...(options.approvalCount === false ? [] : [provideEnvironmentInitializer(() => { inject(ApprovalMenuBadge); })]),\n ]);\n}\n\n/** `/observability/` → `/observability`; `` and `/` → `/`. */\nexport function normalizeBasePath(basePath: string): string {\n const trimmed = basePath.trim().replace(/^\\/+|\\/+$/g, '');\n return trimmed ? `/${trimmed}` : '/';\n}\n\n/** Router links to the pages, under the host's mount path. */\n@Injectable({ providedIn: 'root' })\nexport class ObservabilityLinks {\n private readonly options = inject(OBSERVABILITY_OPTIONS);\n readonly base = normalizeBasePath(this.options.basePath);\n\n /** `to('services', id)` → `['/observability', 'services', id]`. */\n to(...segments: unknown[]): unknown[] { return [this.base, ...segments]; }\n\n /** The host's link to the audit records of a trace, if it gave one. */\n audit(traceId: string | null | undefined): { route: unknown[] } | { href: string } | null {\n if (!traceId || !this.options.auditLink) return null;\n const link = this.options.auditLink(traceId);\n if (!link) return null;\n return typeof link === 'string' ? { href: link } : { route: link };\n }\n}\n\n/** `['services', id] | jcLink`: the same as {@link ObservabilityLinks.to} in a template. */\n@Pipe({ name: 'jcLink' })\nexport class LinkPipe implements PipeTransform {\n private readonly links = inject(ObservabilityLinks);\n transform(segments: unknown[]): unknown[] { return this.links.to(...segments); }\n}\n","import { Injectable, computed, inject } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router';\nimport { filter, map, startWith } from 'rxjs';\n\nexport const RANGES: Record<string, number> = {\n '15m': 15 * 60_000, '1h': 3_600_000, '6h': 6 * 3_600_000, '24h': 24 * 3_600_000, '7d': 7 * 24 * 3_600_000,\n};\n\n/** Search ranges are at most 24 hours (the API's bound); series and operations take up to 7 days. */\nexport const MAX_SEARCH_MS = RANGES['24h'];\n\n/**\n * The investigation context that follows the user between pages (Console requirements §17): environment and time\n * range. It lives in the URL (`env`, and `range` or `from`/`to`), so every page is a deep link and the browser's back\n * button restores it.\n */\n@Injectable({ providedIn: 'root' })\nexport class ContextService {\n private readonly router = inject(Router);\n\n // Created on first use, after the first navigation may already have ended: start from the current URL.\n private readonly params = toSignal(this.router.events.pipe(\n filter(e => e instanceof NavigationEnd),\n startWith(null),\n map(() => this.leaf().snapshot.queryParams),\n ), { initialValue: {} as Params });\n\n readonly environment = computed(() => (this.params()['env'] as string | undefined) ?? '');\n readonly range = computed(() => {\n const p = this.params();\n return p['from'] && p['to'] ? 'custom' : ((p['range'] as string | undefined) ?? '1h');\n });\n readonly absolute = computed(() => {\n const p = this.params();\n return p['from'] && p['to'] ? { from: p['from'] as string, to: p['to'] as string } : null;\n });\n\n /** The window as ISO strings, evaluated now for a relative range. */\n window(maxMs?: number): { from: string; to: string } {\n const absolute = this.absolute();\n if (absolute) return absolute;\n const to = Date.now();\n const span = Math.min(RANGES[this.range()] ?? RANGES['1h'], maxMs ?? Number.MAX_SAFE_INTEGER);\n return { from: new Date(to - span).toISOString(), to: new Date(to).toISOString() };\n }\n\n /** Query parameters for a link: the context plus the target page's own. */\n keep(extra: Params = {}): Params {\n const p = this.params();\n const context: Params = {};\n for (const key of ['env', 'range', 'from', 'to']) if (p[key]) context[key] = p[key];\n return { ...context, ...extra };\n }\n\n /** Changes the context on the current page, keeping its other parameters. */\n set(change: { env?: string | null; range?: string | null; from?: string | null; to?: string | null }) {\n const queryParams: Params = { ...change };\n if (change.range) Object.assign(queryParams, { from: null, to: null });\n void this.router.navigate([], { relativeTo: this.leaf(), queryParams, queryParamsHandling: 'merge' });\n }\n\n /** A time window centred on a moment, for \"around this span\" links. */\n around(at: string, durationMs: number, paddingMs = 5 * 60_000): Params {\n const start = new Date(at).getTime();\n return this.keep({\n from: new Date(start - paddingMs).toISOString(),\n to: new Date(start + durationMs + paddingMs).toISOString(),\n range: null,\n });\n }\n\n private leaf(): ActivatedRoute {\n let route = this.router.routerState.root;\n while (route.firstChild) route = route.firstChild;\n return route;\n }\n}\n","import { Routes } from '@angular/router';\nimport { Menus } from '@juice-js/core';\nimport { normalizeBasePath } from './core/options';\n\nfunction page(path: string, title: string, load: Routes[number]['loadComponent']): Routes[number] {\n return { path, title: `${title} · Juice Observability`, loadComponent: load };\n}\n\n/**\n * The pages, investigation first (Console requirements §4): services, traces, topology, logs and metrics; alerts and\n * rules after. Detail pages are deep links (§17) and carry the environment and time range in their query parameters.\n * The host mounts them at its `basePath` (see {@link provideJuiceObservability}) and adds its own guards.\n */\nexport const OBSERVABILITY_ROUTES: Routes = [\n page('', 'Overview', () => import('./pages/overview.page').then(m => m.OverviewPage)),\n page('services', 'Services', () => import('./pages/services.page').then(m => m.ServicesPage)),\n page('services/:id', 'Service', () => import('./pages/service.page').then(m => m.ServicePage)),\n page('traces', 'Traces', () => import('./pages/traces.page').then(m => m.TracesPage)),\n page('traces/:traceId', 'Trace', () => import('./pages/trace.page').then(m => m.TracePage)),\n page('topology', 'Dependencies', () => import('./pages/topology.page').then(m => m.TopologyPage)),\n page('logs', 'Logs', () => import('./pages/logs.page').then(m => m.LogsPage)),\n page('metrics', 'Metrics', () => import('./pages/metrics.page').then(m => m.MetricsPage)),\n page('resources', 'Resources', () => import('./pages/resources.page').then(m => m.ResourcesPage)),\n page('resources/:id', 'Resource', () => import('./pages/resource.page').then(m => m.ResourcePage)),\n page('alerts', 'Alerts', () => import('./pages/alerts.page').then(m => m.AlertsPage)),\n page('alerts/:id', 'Alert', () => import('./pages/alert.page').then(m => m.AlertPage)),\n page('rules', 'Rules', () => import('./pages/rules.page').then(m => m.RulesPage)),\n page('notifications', 'Notifications', () => import('./pages/notifications.page').then(m => m.NotificationsPage)),\n page('silences', 'Silences', () => import('./pages/silences.page').then(m => m.SilencesPage)),\n page('incidents', 'Incidents', () => import('./pages/incidents.page').then(m => m.IncidentsPage)),\n page('incidents/:id', 'Incident', () => import('./pages/incident.page').then(m => m.IncidentPage)),\n page('agents', 'Agents', () => import('./pages/agents.page').then(m => m.AgentsPage)),\n page('agents/:id', 'Agent', () => import('./pages/agent.page').then(m => m.AgentPage)),\n page('approvals', 'Approvals', () => import('./pages/approvals.page').then(m => m.ApprovalsPage)),\n page('slos', 'SLOs', () => import('./pages/slos.page').then(m => m.SlosPage)),\n page('slos/:key', 'SLO', () => import('./pages/slo.page').then(m => m.SloPage)),\n page('timeline', 'Timeline', () => import('./pages/timeline.page').then(m => m.TimelinePage)),\n page('load-runs', 'Load runs', () => import('./pages/load-runs.page').then(m => m.LoadRunsPage)),\n];\n\n/** The side menu entries (juice-layout), investigation pages first, linking under `basePath`. */\nexport function observabilityMenus(basePath = '/', order = 1): Menus {\n const base = normalizeBasePath(basePath);\n const link = (path: string) => (base === '/' ? `/${path}` : path ? `${base}/${path}` : base);\n return [\n { id: 'overview', label: 'Overview', icon: 'dashboard', routerLink: link('') },\n { id: 'services', label: 'Services', icon: 'hub', routerLink: link('services') },\n { id: 'traces', label: 'Traces', icon: 'timeline', routerLink: link('traces') },\n { id: 'topology', label: 'Dependencies', icon: 'account_tree', routerLink: link('topology') },\n { id: 'logs', label: 'Logs', icon: 'notes', routerLink: link('logs') },\n { id: 'metrics', label: 'Metrics', icon: 'show_chart', routerLink: link('metrics') },\n { id: 'resources', label: 'Resources', icon: 'dns', routerLink: link('resources') },\n { id: 'alerts', label: 'Alerts', icon: 'notifications', routerLink: link('alerts') },\n { id: 'incidents', label: 'Incidents', icon: 'emergency', routerLink: link('incidents') },\n { id: 'rules', label: 'Rules', icon: 'rule', routerLink: link('rules') },\n { id: 'silences', label: 'Silences', icon: 'notifications_paused', routerLink: link('silences') },\n { id: 'notifications', label: 'Notifications', icon: 'campaign', routerLink: link('notifications') },\n { id: 'slos', label: 'SLOs', icon: 'track_changes', routerLink: link('slos') },\n { id: 'agents', label: 'Agents', icon: 'smart_toy', routerLink: link('agents') },\n { id: 'approvals', label: 'Approvals', icon: 'approval', routerLink: link('approvals') },\n { id: 'timeline', label: 'Timeline', icon: 'history', routerLink: link('timeline') },\n { id: 'load-runs', label: 'Load runs', icon: 'speed', routerLink: link('load-runs') },\n ].map((menu, index) => ({ ...menu, order: order + index }));\n}\n"],"mappings":";;;;;;AAcA,SAAgB,iBAAc;CAC5B,MAAM,IAAI,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC;CACnD,EAAE,KAAM,EAAE,KAAK,KAAQ;CACvB,EAAE,KAAM,EAAE,KAAK,KAAQ;CACvB,MAAM,MAAM,MAAM,KAAK,IAAG,MAAK,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;CACvE,OAAO,GAAG,IAAI,MAAM,GAAG,CAAC,EAAC,GAAI,IAAI,MAAM,GAAG,EAAE,EAAC,GAAI,IAAI,MAAM,IAAI,EAAE,EAAC,GAAI,IAAI,MAAM,IAAI,EAAE,EAAC,GAAI,IAAI,MAAM,EAAE;AACzG;AASA,IAAa,aAAb,MAAa,WAAU;CACJ,OAAO,OAAO,UAAU;CACxB,OAAO,GAAG,OAAO,qBAAqB,CAAC,CAAC,QAAO;CAGvD,cAAc,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAG3B,UAA8B,KAAK,KAAK,IAAkB,GAAG,KAAK,KAAI,SAAU,CAAC,CAAC,KACzF,KAAI,SAAO;EACT,IAAI,KAAK,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,wCAAwC;EACrF,OAAO,KAAK,MAA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KAAK,UAAU;EAAC;EAC3F;GAAE,IAAI;GAAQ,OAAO;GAAQ,MAAM;GAAS,YAAY,KAAK,MAAM;EAAC;EACpE;GAAE,IAAI;GAAW,OAAO;GAAW,MAAM;GAAc,YAAY,KAAK,SAAS;EAAC;EAClF;GAAE,IAAI;GAAa,OAAO;GAAa,MAAM;GAAO,YAAY,KAAK,WAAW;EAAC;EACjF;GAAE,IAAI;GAAU,OAAO;GAAU,MAAM;GAAiB,YAAY,KAAK,QAAQ;EAAC;EAClF;GAAE,IAAI;GAAa,OAAO;GAAa,MAAM;GAAa,YAAY,KAAK,WAAW;EAAC;EACvF;GAAE,IAAI;GAAS,OAAO;GAAS,MAAM;GAAQ,YAAY,KAAK,OAAO;EAAC;EACtE;GAAE,IAAI;GAAY,OAAO;GAAY,MAAM;GAAwB,YAAY,KAAK,UAAU;EAAC;EAC/F;GAAE,IAAI;GAAiB,OAAO;GAAiB,MAAM;GAAY,YAAY,KAAK,eAAe;EAAC;EAClG;GAAE,IAAI;GAAQ,OAAO;GAAQ,MAAM;GAAiB,YAAY,KAAK,MAAM;EAAC;EAC5E;GAAE,IAAI;GAAU,OAAO;GAAU,MAAM;GAAa,YAAY,KAAK,QAAQ;EAAC;EAC9E;GAAE,IAAI;GAAa,OAAO;GAAa,MAAM;GAAY,YAAY,KAAK,WAAW;EAAC;EACtF;GAAE,IAAI;GAAY,OAAO;GAAY,MAAM;GAAW,YAAY,KAAK,UAAU;EAAC;EAClF;GAAE,IAAI;GAAa,OAAO;GAAa,MAAM;GAAS,YAAY,KAAK,WAAW;EAAC;CACpF,CAAA,CAAC,KAAK,MAAM,WAAW;EAAE,GAAG;EAAM,OAAO,QAAQ;CAAK,EAAG;AAC5D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juice-js/observability",
3
- "version": "1.1.0-alpha.32",
3
+ "version": "1.1.0-alpha.35",
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",
@@ -649,6 +649,38 @@ export interface Related {
649
649
  breachStartedAt: string;
650
650
  items: CorrelatedItem[];
651
651
  }
652
+ export interface CorrelationEvidence {
653
+ code: string;
654
+ text: string;
655
+ weight: number;
656
+ }
657
+ /** `incidentId`: the unresolved incident one of the pair is in; accepting adds the other to it, otherwise opens one. */
658
+ export interface Suggestion {
659
+ alert: Alert;
660
+ other: Alert;
661
+ score: number;
662
+ evidence: CorrelationEvidence[];
663
+ incidentId: string | null;
664
+ }
665
+ /** Alerts suggested together: correlation, never a proven cause, and nothing merges until someone accepts. */
666
+ export interface Suggestions {
667
+ relation: string;
668
+ note: string;
669
+ threshold: number;
670
+ items: Suggestion[];
671
+ }
672
+ export interface CorrelationDecision {
673
+ decision: string;
674
+ alertId: string;
675
+ otherAlertId: string;
676
+ score: number;
677
+ evidence: CorrelationEvidence[];
678
+ weightsVersion: string;
679
+ incidentId: string | null;
680
+ reason: string | null;
681
+ decidedBy: string;
682
+ decidedAt: string;
683
+ }
652
684
  export interface LoadRun {
653
685
  id: string;
654
686
  name: string;
@@ -787,12 +819,23 @@ export interface SloDay {
787
819
  minutes: number;
788
820
  expectedMinutes: number;
789
821
  }
822
+ export interface SloAlert {
823
+ id: string;
824
+ rule: string;
825
+ state: string;
826
+ severity: string;
827
+ firedAt: string | null;
828
+ resolvedAt: string | null;
829
+ burnRate: number | null;
830
+ noData: boolean;
831
+ }
790
832
  export interface SloDetail {
791
833
  slo: SloSummary;
792
834
  definition: SloDefinition;
793
835
  versions: SloVersion[];
794
836
  days: SloDay[];
795
837
  countedThrough: string | null;
838
+ alerts: SloAlert[];
796
839
  }
797
840
  /**
798
841
  * A random UUID v4 for `Idempotency-Key`. Not `crypto.randomUUID()`: browsers offer it only in a secure context (HTTPS or localhost), so it
@@ -889,6 +932,10 @@ export declare class ApiService {
889
932
  capacity(query: Query): Observable<Capacity>;
890
933
  timeline(query: Query): Observable<Timeline>;
891
934
  relatedToAlert(id: string): Observable<Related>;
935
+ alertSuggestions(id: string): Observable<Suggestions>;
936
+ incidentSuggestions(id: string): Observable<Suggestions>;
937
+ acceptSuggestion(alertId: string, otherId: string): Observable<CorrelationDecision>;
938
+ dismissSuggestion(alertId: string, otherId: string, reason: string): Observable<CorrelationDecision>;
892
939
  loadRuns(query: Query): Observable<Page<LoadRun>>;
893
940
  loadRunResults(id: string): Observable<LoadRunResults>;
894
941
  dependencyStats(query: Query): Observable<DependencyStatsPage>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"juice-js-observability-alert.page-BNlH9IdQ.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alert.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { DatePipe, LowerCasePipe } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { AgoPipe, ReasonPipe } from '../shared/format';\nimport { ContextBar, HealthBadge, KeyValueTable } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\n\n/**\n * One alert (Console requirements §14): evidence, lifecycle history, the subject's health and reasons, the way into\n * the investigation, and acknowledgement for operators.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, LowerCasePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule,\n ContextBar, HealthBadge, KeyValueTable, AgoPipe, ReasonPipe],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Alerts</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.alert?.rule ?? '…' }}</h1>\n </jc-context-bar>\n @if (detail.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <div class=\"jc-summary\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"d.alert.severity === 'Critical'\" [class.jc-health-degraded]=\"d.alert.severity === 'Warning'\">{{ d.alert.severity }}</span>\n <strong>{{ d.alert.state }}</strong>\n <span>{{ d.alert.subjectKey }}</span>\n @if (d.alert.noData) { <span class=\"jc-muted\">no data at the last evaluation: state kept</span> }\n @if (d.alert.subjectType === 'service' && d.alert.subjectId) {\n <a mat-flat-button [routerLink]=\"['services', d.alert.subjectId] | jcLink\" [queryParams]=\"investigate(d.alert.environment)\">Investigate</a>\n <a mat-stroked-button [routerLink]=\"['services', d.alert.subjectId] | jcLink\" [queryParams]=\"investigate(d.alert.environment, { tab: 'traces', status: 'error' })\">Error traces</a>\n }\n @for (l of d.links; track l.url) { <a mat-button [href]=\"l.url\" target=\"_blank\" rel=\"noopener\">{{ l.title }} ↗</a> }\n @if (d.alert.state !== 'Resolved') {\n <a mat-stroked-button data-testid=\"alert-open-incident\" [routerLink]=\"['incidents'] | jcLink\" [queryParams]=\"incidentLink(d.alert.id, d.alert.rule, d.alert.subjectKey)\">Open an incident</a>\n <a mat-stroked-button data-testid=\"alert-silence\" [routerLink]=\"['silences'] | jcLink\" [queryParams]=\"silenceLink(d.alert.subjectKey, d.alert.environment, d.alert.subjectType)\">Silence this</a>\n }\n </div>\n @if (notifications.value(); as n) {\n @for (s of n.silences; track s.id) {\n <p class=\"jc-notice\" data-testid=\"alert-silenced\">Notifications are held until {{ s.endsAt | date: 'MMM d, HH:mm' }}: “{{ s.comment }}” ({{ s.createdBy }}). The alert itself still fires and resolves.</p>\n }\n @for (i of n.incidents; track i.id) {\n <p>In incident <a [routerLink]=\"['incidents', i.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ i.title }}</a> ({{ i.state }})</p>\n }\n }\n <div class=\"jc-grid-2\">\n <section class=\"jc-card\"><h2>Evidence</h2><jc-kv [values]=\"d.evidence\" /></section>\n <section class=\"jc-card\">\n <h2>Subject health</h2>\n @for (h of d.subjectHealth; track h.subjectId + h.environment) {\n <p><jc-health [state]=\"h.state\" [stale]=\"h.stale\" /> {{ h.environment }}</p>\n <ul class=\"jc-reasons\">@for (r of h.reasons; track r) { <li>{{ r | reason }}</li> }</ul>\n } @empty { <p class=\"jc-muted\">No health for this subject.</p> }\n </section>\n </div>\n <section class=\"jc-card\" data-testid=\"alert-related\">\n <h2>Around this alert</h2>\n @if (related.value(); as r) {\n <p class=\"jc-notice\" data-testid=\"alert-related-note\">{{ r.note }}</p>\n <table class=\"jc-table\"><tbody>\n @for (i of r.items; track i.type + i.id) {\n <tr>\n <td class=\"jc-nowrap\">{{ i.at | date: 'MMM d, HH:mm:ss' }}</td>\n <td><strong>{{ i.title }}</strong>@if (i.detail) { <div class=\"jc-muted jc-small\">{{ i.detail }}</div> }</td>\n <td class=\"jc-small\"><ul class=\"jc-reasons\">@for (x of i.reasons; track x.code) { <li>{{ x.text }} <span class=\"jc-muted\">(+{{ x.points }})</span></li> }</ul></td>\n </tr>\n } @empty { <tr><td class=\"jc-muted\">No changes or dependency health changes in the 2 hours before this alert.</td></tr> }\n </tbody></table>\n @if (d.alert.subjectId && d.alert.subjectType === 'service') {\n <a mat-stroked-button [routerLink]=\"['timeline'] | jcLink\" [queryParams]=\"timelineLink(d.alert.subjectId, d.alert.environment, r.breachStartedAt)\">Open the timeline</a>\n }\n }\n @if (related.error()) { <p class=\"jc-error\">{{ relatedError() }}</p> }\n </section>\n <section class=\"jc-card\" data-testid=\"alert-notifications\">\n <h2>Notifications</h2>\n @if (notifications.value(); as n) {\n @for (e of n.escalations; track e.policy) {\n <p>Escalation <strong>{{ e.name }}</strong>: {{ e.stepsSent }} of {{ e.steps }} steps sent, {{ e.state | lowercase }}@if (e.stopReason) { ({{ e.stopReason | reason }}) }@if (e.nextAt) {, next at {{ e.nextAt | date: 'HH:mm:ss' }} }</p>\n }\n <table class=\"jc-table\">\n <thead><tr><th>To</th><th>Event</th><th>Status</th><th>Attempts</th><th>Detail</th><th>When</th></tr></thead>\n <tbody>\n @for (x of n.deliveries; track x.delivery.id) {\n <tr>\n <td>{{ x.endpointKey }} <span class=\"jc-muted jc-small\">{{ x.kind }}</span></td>\n <td>{{ x.delivery.event }}@if (x.delivery.escalationStep) { step {{ x.delivery.escalationStep }} }</td>\n <td [class.jc-bad]=\"x.delivery.status === 'Failed'\">{{ x.delivery.status }}</td>\n <td>{{ x.delivery.attempts }}</td>\n <td class=\"jc-small\">{{ x.delivery.lastError }}@if (x.delivery.nextAttemptAt && x.delivery.status === 'Retrying') { · next {{ x.delivery.nextAttemptAt | date: 'HH:mm:ss' }} }</td>\n <td class=\"jc-nowrap\">{{ x.delivery.createdAt | date: 'MMM d, HH:mm:ss' }}</td>\n </tr>\n } @empty { <tr><td colspan=\"6\" class=\"jc-muted\">Nothing sent about this alert: no channel takes it.</td></tr> }\n </tbody>\n </table>\n }\n @if (notifications.error()) { <p class=\"jc-error\">{{ notificationsError() }}</p> }\n </section>\n <section class=\"jc-card\">\n <h2>History</h2>\n <table class=\"jc-table\"><tbody>\n @for (t of d.history; track t.at + t.to) {\n <tr><td>{{ t.at | date: 'MMM d, HH:mm:ss' }}</td><td>{{ t.from ?? '—' }} → <strong>{{ t.to }}</strong></td><td>{{ t.reason | reason }}</td><td>{{ t.value ?? '—' }}</td></tr>\n }\n </tbody></table>\n </section>\n <section class=\"jc-card\">\n <h2>Acknowledgement</h2>\n @if (d.alert.acknowledgedAt) {\n <p>By <strong>{{ d.alert.acknowledgedBy }}</strong> {{ d.alert.acknowledgedAt | ago }}@if (d.acknowledgeComment) {: “{{ d.acknowledgeComment }}”}</p>\n } @else if (d.alert.state !== 'Resolved') {\n <form (ngSubmit)=\"acknowledge()\" class=\"jc-filter-form\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Comment</mat-label><input matInput name=\"comment\" [(ngModel)]=\"comment\" maxlength=\"1000\"></mat-form-field>\n <button mat-flat-button type=\"submit\" [disabled]=\"sending()\">Acknowledge</button>\n </form>\n @if (ackError()) { <p class=\"jc-error\">{{ ackError() }}</p> }\n } @else { <p class=\"jc-muted\">Resolved without acknowledgement.</p> }\n </section>\n }`,\n})\nexport class AlertPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n readonly id = input.required<string>();\n protected comment = '';\n protected readonly sending = signal(false);\n protected readonly ackError = signal('');\n\n protected readonly detail = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.alert(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n protected readonly related = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.relatedToAlert(params) });\n protected readonly relatedError = computed(() => problemText(this.related.error()));\n protected readonly notifications = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.alertNotifications(params) });\n protected readonly notificationsError = computed(() => problemText(this.notifications.error()));\n\n incidentLink(alert: string, rule: string, subject: string) { return this.ctx.keep({ alert, title: `${rule} on ${subject}` }); }\n\n /** The new-silence form, filled in for this alert's subject. */\n silenceLink(subject: string, environment: string | null, type: string) {\n const name = type === 'service' ? subject.replace(/^service:/, '').replace(/@[^@]*$/, '') : null;\n const host = type === 'host' ? subject.replace(/^host:/, '') : null;\n return this.ctx.keep({ service: name, environment, host });\n }\n\n /** The service page over the alert's environment, from shortly before the breach. */\n /** The service's timeline from 2 hours before the breach to 1 hour after. */\n timelineLink(service: string, environment: string | null, breach: string) {\n const at = new Date(breach).getTime();\n return this.ctx.keep({ service, env: environment, range: null, from: new Date(at - 2 * 3_600_000).toISOString(), to: new Date(at + 3_600_000).toISOString() });\n }\n\n investigate(environment: string | null, extra: Record<string, string> = {}) {\n const alert = this.detail.value()?.alert;\n const start = alert?.breachStartedAt ? new Date(alert.breachStartedAt).getTime() - 15 * 60_000 : null;\n const end = alert?.resolvedAt ? new Date(alert.resolvedAt).getTime() + 5 * 60_000 : Date.now();\n const window = start && end - start <= 24 * 3_600_000\n ? { from: new Date(start).toISOString(), to: new Date(end).toISOString(), range: null } : {};\n return this.ctx.keep({ env: environment, ...window, ...extra });\n }\n\n acknowledge() {\n this.sending.set(true);\n this.ackError.set('');\n this.api.acknowledge(this.id(), this.comment).subscribe({\n next: () => { this.sending.set(false); this.detail.reload(); this.notifications.reload(); },\n error: e => {\n this.sending.set(false);\n this.ackError.set((e as { status?: number }).status === 403 ? 'Acknowledging needs the operator or admin role.' : problemText(e));\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkIA,IAAa,YAAb,MAAa,UAAS;CACD,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CAC/B,KAAK,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAC5B,UAAU;CACD,UAAU,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACvB,WAAW,OAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAErB,SAAS,YAAY;EAAE,cAAc,KAAK,GAAE;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,MAAM,MAAM;CAAC,CAAE;CAChG,QAAQ,eAAe,YAAY,KAAK,OAAO,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACxD,UAAU,YAAY;EAAE,cAAc,KAAK,GAAE;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,eAAe,MAAM;CAAC,CAAE;CAC1G,eAAe,eAAe,YAAY,KAAK,QAAQ,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+B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IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,cAAA;IAAA,UAAA,CAAA,gBAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAC7I;IAAU,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAW,UAAA;IAAA,QAAA,CAAA,SAAA,OAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAa,UAAA;IAAA,QAAA,CAAA,UAAA,OAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAD9B;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAc;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAa,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MACb;IAAO,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAU,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AA2GlD,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EA9GrB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAU;IAAe;IAAa;IAAiB;IAAoB;IAAgB;IACzH;IAAY;IAAa;IAAe;IAAS;GAAU;GAC7D,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyGX,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"juice-js-observability-incident.page-C2ZK3MRh.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/incident.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { DatePipe } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { Observable } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { IncidentEvent } from '../core/models';\nimport { apiResource } from '../shared/resource';\nimport { problemText } from '../shared/telemetry';\nimport { ContextBar } from '../shared/ui';\n\nconst MOVES: Record<string, string[]> = {\n Open: ['Investigating', 'Mitigated', 'Resolved'],\n Investigating: ['Mitigated', 'Resolved'],\n Mitigated: ['Investigating', 'Resolved'],\n Resolved: ['Investigating'],\n};\n\n/** One incident: its state and the moves from it, its alerts, and who did what. Resolving it changes no alert, and says so if some are still open. */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule, ContextBar],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['incidents'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Incidents</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.incident?.title ?? '…' }}</h1>\n </jc-context-bar>\n @if (detail.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <div class=\"jc-summary\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"d.incident.severity === 'Critical'\" [class.jc-health-degraded]=\"d.incident.severity === 'Warning'\">{{ d.incident.severity }}</span>\n <strong data-testid=\"incident-state\">{{ d.incident.state }}</strong>\n <span class=\"jc-muted\">Opened by {{ d.incident.createdBy }} {{ d.incident.createdAt | date: 'MMM d, HH:mm' }}</span>\n </div>\n @if (d.incident.state !== 'Resolved' && d.openAlerts > 0) {\n <p class=\"jc-notice\" data-testid=\"incident-open-alerts\">{{ d.openAlerts }} of its alerts {{ d.openAlerts === 1 ? 'is' : 'are' }} still open. Resolving the incident won't change them.</p>\n }\n <section class=\"jc-card\">\n <h2>Move or note</h2>\n <form class=\"jc-form\" (ngSubmit)=\"note()\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Comment or note</mat-label><input matInput name=\"text\" data-testid=\"incident-text\" [(ngModel)]=\"text\" maxlength=\"2000\"></mat-form-field>\n <button mat-stroked-button type=\"submit\" data-testid=\"incident-note\" [disabled]=\"sending()\">Add note</button>\n @for (m of moves(d.incident.state); track m) {\n <button mat-flat-button type=\"button\" [attr.data-testid]=\"'incident-move-' + m\" [disabled]=\"sending()\" (click)=\"move(m)\">{{ d.incident.state === 'Resolved' ? 'Reopen' : m }}</button>\n }\n @if (actionError()) { <span class=\"jc-error\" data-testid=\"incident-action-error\">{{ actionError() }}</span> }\n </form>\n </section>\n <section class=\"jc-card\" data-testid=\"incident-alerts\">\n <h2>Alerts</h2>\n <table class=\"jc-table\"><tbody>\n @for (a of d.alerts; track a.id) {\n <tr>\n <td><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a></td>\n <td>{{ a.subjectKey }}</td><td>{{ a.severity }}</td><td>{{ a.state }}</td>\n <td class=\"jc-row-actions\"><button mat-button type=\"button\" (click)=\"removeAlert(a.id)\">Remove</button></td>\n </tr>\n } @empty { <tr><td class=\"jc-muted\">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }\n </tbody></table>\n </section>\n <section class=\"jc-card\" data-testid=\"incident-events\">\n <h2>What happened</h2>\n <table class=\"jc-table\"><tbody>\n @for (e of d.events; track $index) {\n <tr>\n <td class=\"jc-nowrap\">{{ e.at | date: 'MMM d, HH:mm:ss' }}</td>\n <td>{{ e.actor }}</td>\n <td><strong>{{ describe(e) }}</strong>@if (e.text) { <div>{{ e.text }}</div> }</td>\n </tr>\n }\n </tbody></table>\n </section>\n }`,\n})\nexport class IncidentPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n readonly id = input.required<string>();\n protected text = '';\n protected readonly sending = signal(false);\n protected readonly actionError = signal('');\n\n protected readonly detail = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.incident(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n\n protected moves(state: string): string[] { return MOVES[state] ?? []; }\n\n protected describe(e: IncidentEvent): string {\n switch (e.type) {\n case 'created': return 'Opened';\n case 'state': return `${e.from} → ${e.to}`;\n case 'note': return 'Note';\n case 'alert_added': return 'Alert added';\n case 'alert_removed': return 'Alert removed';\n default: return e.type;\n }\n }\n\n private run<T>(request: Observable<T>) {\n this.sending.set(true);\n this.actionError.set('');\n request.subscribe({\n next: () => { this.sending.set(false); this.text = ''; this.detail.reload(); },\n error: e => { this.sending.set(false); this.actionError.set((e as { status?: number }).status === 403 ? 'This needs the operator or admin role.' : problemText(e)); },\n });\n }\n\n protected move(to: string) { this.run(this.api.moveIncident(this.id(), to, this.text)); }\n protected note() { this.run(this.api.addIncidentNote(this.id(), this.text)); }\n protected removeAlert(alertId: string) { this.run(this.api.removeIncidentAlert(this.id(), alertId)); }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,QAAkC;CACtC,MAAM;EAAC;EAAiB;EAAa;CAAU;CAC/C,eAAe,CAAC,aAAa,UAAU;CACvC,WAAW,CAAC,iBAAiB,UAAU;CACvC,UAAU,CAAC,eAAe;AAC3B;AA2DD,IAAa,eAAb,MAAa,aAAY;CACJ,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CAC/B,KAAK,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAC5B,OAAO;CACE,UAAU,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACvB,cAAc,OAAO,IAAG,GA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ources":["../../../../projects/juice-js/observability/src/lib/pages/rules.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatCheckboxModule } from '@angular/material/checkbox';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { MatSelectModule } from '@angular/material/select';\nimport { apiResource } from '../shared/resource';\nimport { RouterLink } from '@angular/router';\nimport { Observable, forkJoin, map } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { Rule } from '../core/models';\nimport { AgoPipe } from '../shared/format';\nimport { ContextBar } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\n\nconst TEMPLATES: Record<string, string> = {\n ErrorRate: 'Ratio of failed requests, 0 to 1. Fires above the threshold.',\n LatencyP95: 'Milliseconds at the 95th percentile. Fires above the threshold.',\n ThroughputAbsent: 'Requests in the window, for a service that had traffic. Fires at or below the threshold.',\n DeliveryFailureRate: 'Ratio of failed deliveries, 0 to 1. Fires above the threshold.',\n HostMemory: 'Ratio of host memory used, 0 to 1. Fires above the threshold.',\n MediatorErrors: 'Mediator errors in the window. Fires above the threshold.',\n ConsumerFailures: 'Failed consumer messages in the window. Fires above the threshold.',\n};\n\n/** A TimeSpan as the API writes it (`1.02:03:04`) in seconds. */\nfunction seconds(value: unknown): number {\n const match = /^(?:(\\d+)\\.)?(\\d+):(\\d+):(\\d+)/.exec(String(value ?? ''));\n return match ? (+(match[1] ?? 0)) * 86400 + +match[2] * 3600 + +match[3] * 60 + +match[4] : 0;\n}\n\nfunction span(total: number): string {\n const s = Math.max(0, Math.round(total || 0));\n const pad = (n: number) => String(n).padStart(2, '0');\n const days = Math.floor(s / 86400);\n return `${days ? `${days}.` : ''}${pad(Math.floor(s / 3600) % 24)}:${pad(Math.floor(s / 60) % 60)}:${pad(s % 60)}`;\n}\n\ninterface RuleForm {\n key: string; name: string; template: string; severity: string; service: string; environment: string; host: string; threshold: number | null; recoveryThreshold: number | null;\n minimumSamples: number; scheduleSeconds: number; windowSeconds: number; forSeconds: number; recoverySeconds: number; cooldownSeconds: number; enabled: boolean;\n}\n\nconst NEW_RULE: RuleForm = {\n key: '', name: '', template: 'ErrorRate', severity: 'Warning', service: '', environment: '', host: '', threshold: null, recoveryThreshold: null,\n minimumSamples: 10, scheduleSeconds: 60, windowSeconds: 300, forSeconds: 120, recoverySeconds: 120, cooldownSeconds: 600, enabled: true,\n};\n\n/**\n * Rules and their current state (Console requirements §14), and changing them for admins. They stay typed templates (D5): this page never takes a query.\n * A rule in the deployment's file is shown but changed there. Disabling one, or changing what it watches, closes its open alerts, which the form says first.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, FormsModule, MatButtonModule, MatCheckboxModule, MatFormFieldModule, MatInputModule, MatProgressBarModule, MatSelectModule, ContextBar, AgoPipe],\n template: `\n <jc-context-bar>\n <h1>Rules</h1>\n <span class=\"jc-spacer\"></span>\n <button mat-flat-button type=\"button\" data-testid=\"rule-new\" (click)=\"startNew()\">New rule</button>\n </jc-context-bar>\n @if (data.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (data.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (form(); as f) {\n <section class=\"jc-card\" data-testid=\"rule-form\">\n <h2>{{ editing() ? 'Change ' + editing()!.key : 'New rule' }}</h2>\n <form class=\"jc-form\" (ngSubmit)=\"save(f)\">\n @if (!editing()) { <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Key</mat-label><input matInput name=\"key\" [(ngModel)]=\"f.key\" required></mat-form-field> }\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Name</mat-label><input matInput name=\"name\" [(ngModel)]=\"f.name\" required></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Template</mat-label>\n <mat-select name=\"template\" [(ngModel)]=\"f.template\">@for (t of templates; track t) { <mat-option [value]=\"t\">{{ t }}</mat-option> }</mat-select>\n </mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Severity</mat-label>\n <mat-select name=\"severity\" [(ngModel)]=\"f.severity\"><mat-option value=\"Info\">Info</mat-option><mat-option value=\"Warning\">Warning</mat-option><mat-option value=\"Critical\">Critical</mat-option></mat-select>\n </mat-form-field>\n @if (f.template === 'HostMemory') {\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Host (all if empty)</mat-label><input matInput name=\"host\" [(ngModel)]=\"f.host\"></mat-form-field>\n } @else {\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Service (all if empty)</mat-label><input matInput name=\"service\" [(ngModel)]=\"f.service\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Environment (all if empty)</mat-label><input matInput name=\"environment\" [(ngModel)]=\"f.environment\"></mat-form-field>\n }\n <p class=\"jc-muted jc-small jc-form-actions\">{{ hint(f.template) }}</p>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Threshold</mat-label><input matInput type=\"number\" step=\"any\" name=\"threshold\" [(ngModel)]=\"f.threshold\" required></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Recovery threshold</mat-label><input matInput type=\"number\" step=\"any\" name=\"recoveryThreshold\" [(ngModel)]=\"f.recoveryThreshold\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Minimum samples</mat-label><input matInput type=\"number\" name=\"minimumSamples\" [(ngModel)]=\"f.minimumSamples\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Every (s)</mat-label><input matInput type=\"number\" name=\"schedule\" [(ngModel)]=\"f.scheduleSeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Window (s)</mat-label><input matInput type=\"number\" name=\"window\" [(ngModel)]=\"f.windowSeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Fire after (s)</mat-label><input matInput type=\"number\" name=\"for\" [(ngModel)]=\"f.forSeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Recover after (s)</mat-label><input matInput type=\"number\" name=\"recovery\" [(ngModel)]=\"f.recoverySeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Cooldown (s)</mat-label><input matInput type=\"number\" name=\"cooldown\" [(ngModel)]=\"f.cooldownSeconds\"></mat-form-field>\n <mat-checkbox name=\"enabled\" [(ngModel)]=\"f.enabled\">Enabled</mat-checkbox>\n @if (editing()) { <p class=\"jc-muted jc-small jc-form-actions\">Disabling this rule, or changing its template or scope, resolves its open alerts: nothing would be watching them any more.</p> }\n <div class=\"jc-form-actions\">\n <button mat-flat-button type=\"submit\" data-testid=\"rule-save\" [disabled]=\"saving()\">Save</button>\n <button mat-button type=\"button\" (click)=\"form.set(null)\">Cancel</button>\n @if (saveError()) { <span class=\"jc-error\" data-testid=\"rule-error\">{{ saveError() }}</span> }\n </div>\n </form>\n </section>\n }\n <table class=\"jc-table\" data-testid=\"rules\">\n <thead><tr><th>Rule</th><th>Template</th><th>Severity</th><th>Threshold</th><th>Recovery</th><th>Wait</th><th>Open alerts</th><th>Last evaluation</th><th></th></tr></thead>\n <tbody>\n @for (r of rows(); track r.key) {\n <tr [class.jc-muted]=\"!r.enabled\">\n <td><strong>{{ r.name }}</strong><div class=\"jc-muted jc-small\">{{ r.key }}@if (!r.enabled) { · disabled }@if (r.managedBy === 'config') { · from the rules file }</div></td>\n <td>{{ r.template }}</td>\n <td>{{ r.severity }}</td>\n <td>{{ r.definition['threshold'] ?? '—' }}</td>\n <td>{{ r.definition['recoveryThreshold'] ?? '—' }}</td>\n <td>{{ r.definition['forDuration'] ?? '—' }}</td>\n <td>\n @for (a of r.open; track a.id) {\n <div><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.state }}</a> {{ a.subjectKey }} = {{ a.lastValue ?? 'no data' }}</div>\n } @empty { <span class=\"jc-muted\">none</span> }\n </td>\n <td>{{ r.lastEvaluatedAt | ago }}</td>\n <td class=\"jc-row-actions\">@if (r.managedBy !== 'config') { <button mat-button type=\"button\" [attr.data-testid]=\"'rule-edit-' + r.key\" (click)=\"edit(r)\">Change</button> }</td>\n </tr>\n }\n </tbody>\n </table>`,\n})\nexport class RulesPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly templates = Object.keys(TEMPLATES);\n protected readonly form = signal<RuleForm | null>(null);\n protected readonly editing = signal<Rule | null>(null);\n protected readonly saving = signal(false);\n protected readonly saveError = signal('');\n protected readonly data = apiResource({\n stream: () => forkJoin({\n rules: this.api.rules().pipe(map(p => p.items)),\n firing: this.api.allAlerts({ state: 'firing' }).pipe(map(p => p.items)),\n pending: this.api.allAlerts({ state: 'pending' }).pipe(map(p => p.items)),\n }),\n });\n protected readonly error = computed(() => problemText(this.data.error()));\n protected readonly rows = computed(() => {\n const d = this.data.value();\n if (!d) return [];\n const open = [...d.firing, ...d.pending];\n return d.rules.map(r => {\n const mine = open.filter(a => a.rule === r.key);\n const last = mine.map(a => a.lastEvaluatedAt).sort().at(-1) ?? null;\n return { ...r, open: mine, lastEvaluatedAt: last };\n });\n });\n\n protected hint(template: string): string { return TEMPLATES[template] ?? ''; }\n\n protected startNew() { this.editing.set(null); this.saveError.set(''); this.form.set({ ...NEW_RULE }); }\n\n protected edit(rule: Rule) {\n const d = rule.definition;\n this.editing.set(rule);\n this.saveError.set('');\n this.form.set({\n key: rule.key, name: rule.name, template: rule.template, severity: rule.severity, service: String(d['service'] ?? ''), environment: String(d['environment'] ?? ''), host: String(d['host'] ?? ''),\n threshold: d['threshold'] as number, recoveryThreshold: (d['recoveryThreshold'] as number | null) ?? null, minimumSamples: d['minimumSamples'] as number, scheduleSeconds: seconds(d['schedule']), windowSeconds: seconds(d['window']),\n forSeconds: seconds(d['forDuration']), recoverySeconds: seconds(d['recoveryDuration']), cooldownSeconds: seconds(d['cooldown']), enabled: rule.enabled,\n });\n }\n\n protected save(f: RuleForm) {\n const host = f.template === 'HostMemory';\n const body = {\n key: f.key, name: f.name, template: f.template, severity: f.severity, service: host ? '' : f.service.trim(), environment: host ? '' : f.environment.trim().toLowerCase(), host: host ? f.host.trim() : '',\n threshold: f.threshold, recoveryThreshold: f.recoveryThreshold, minimumSamples: f.minimumSamples, schedule: span(f.scheduleSeconds), window: span(f.windowSeconds), forDuration: span(f.forSeconds),\n recoveryDuration: span(f.recoverySeconds), cooldown: span(f.cooldownSeconds), enabled: f.enabled,\n };\n const editing = this.editing();\n const request: Observable<Rule> = editing ? this.api.updateRule(editing.key, body, editing.etag) : this.api.createRule(body);\n this.saving.set(true);\n this.saveError.set('');\n request.subscribe({\n next: () => { this.saving.set(false); this.form.set(null); this.data.reload(); },\n error: e => { this.saving.set(false); this.saveError.set(problemText(e)); },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,YAAoC;CACxC,WAAW;CACX,YAAY;CACZ,kBAAkB;CAClB,qBAAqB;CACrB,YAAY;CACZ,gBAAgB;CAChB,kBAAkB;AACnB;AAGD,SAAS,QAAQ,OAAc;CAC7B,MAAM,QAAQ,iCAAiC,KAAK,OAAO,SAAS,EAAE,CAAC;CACvE,OAAO,QAAS,EAAE,MAAM,MAAM,KAAM,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,KAAK;AAC9F;AAEA,SAAS,KAAK,OAAa;CACzB,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,SAAS,CA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AAA;IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,mBAAA;IAAA,UAAA,CAAA,WAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAU,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAA5J;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAsJ;IAAO,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAqEpK,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EAvErB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAa;IAAiB;IAAmB;IAAoB;IAAgB;IAAsB;IAAiB;IAAY;GAAO;GAC/K,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmEX,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"juice-js-observability-slo.page-DZGsui_P.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/slo.page.ts"],"sourcesContent":["import { DatePipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { SloDay, SloDefinition, SloSummary } from '../core/models';\nimport { LinkPipe } from '../core/options';\nimport { apiResource } from '../shared/resource';\nimport { problemText } from '../shared/telemetry';\nimport { ContextBar } from '../shared/ui';\nimport { burnText, objective, percent, sloState, times } from './slos.page';\n\nconst WINDOWS: Record<string, string> = { '5m': '5 minutes', '30m': '30 minutes', '1h': '1 hour', '6h': '6 hours', '3d': '3 days' };\n\n/**\n * One SLO (roadmap Phase 9): its budget over the last 30 days, how fast it burns in each window, its days, what counts as a request, and its versions.\n * A window with too few requests, or too many minutes that weren't counted, says so instead of a figure.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [RouterLink, LinkPipe, DatePipe, MatProgressBarModule, ContextBar],\n template: `\n <jc-context-bar>\n <a class=\"jc-crumb\" [routerLink]=\"['slos'] | jcLink\" [queryParams]=\"ctx.keep()\">SLOs</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.slo?.name ?? key() }}</h1>\n </jc-context-bar>\n @if (detail.isLoading() && !detail.value()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <p class=\"jc-summary\">\n <span class=\"jc-badge\" [class]=\"state(d.slo.state).css\" data-testid=\"slo-state\">{{ state(d.slo.state).text }}</span>\n <strong>{{ objective(d.slo) }}</strong> · {{ d.slo.category }} · {{ d.slo.service }} in {{ d.slo.environment }} · version {{ d.slo.version }}\n @if (d.slo.pendingVersion) { <span class=\"jc-muted\"> (version {{ d.slo.pendingVersion }} pending)</span> }\n @if (d.slo.retired) { <span class=\"jc-muted\"> · retired</span> }\n </p>\n\n <section class=\"jc-card\" data-testid=\"slo-budget\">\n <h2>Error budget, last 30 days</h2>\n @switch (d.slo.state) {\n @case ('Unknown') {\n <p data-testid=\"slo-budget-unknown\">Only {{ percent(d.slo.coverage, 1) }} of the last 30 days' minutes are counted, so there's no budget to show yet. Minutes that weren't\n read are never taken as good: either counting is still catching up, or telemetry didn't arrive.</p>\n }\n @case ('InsufficientData') {\n <p>{{ d.slo.total.toLocaleString() }} requests in 30 days: too few to say whether the objective is met.</p>\n }\n @default {\n <p><strong>{{ percent(d.slo.attainment, 3) }}</strong> of {{ d.slo.total.toLocaleString() }} requests were good, against an objective of {{ d.slo.target }}%.</p>\n @if ((d.slo.budgetUsed ?? 0) <= 1) {\n <p>{{ percent(d.slo.budgetUsed, 1) }} of the budget is used ({{ d.slo.bad.toLocaleString() }} bad of {{ allowed(d.slo).toLocaleString() }} allowed),\n {{ percent(d.slo.budgetRemaining, 1) }} left.</p>\n } @else {\n <p class=\"jc-bad\">The budget is overspent: {{ d.slo.bad.toLocaleString() }} bad requests against {{ allowed(d.slo).toLocaleString() }} allowed, {{ times(d.slo.budgetUsed!) }} the budget.</p>\n }\n }\n }\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-burn\">\n <h2>Burn rate</h2>\n <p class=\"jc-muted jc-small\">How fast the budget is being spent: 1× spends it exactly over 30 days. A window needs enough requests, and nearly all its minutes counted.</p>\n <table class=\"jc-table\">\n <thead><tr><th>Window</th><th>Requests</th><th>Good</th><th>Burn rate</th></tr></thead>\n <tbody>\n @for (w of d.slo.burn; track w.name) {\n <tr [attr.data-testid]=\"'slo-burn-' + w.name\">\n <td>{{ windowName(w.name) }}</td><td>{{ w.total.toLocaleString() }}</td><td>{{ percent(w.attainment, 2) }}</td><td>{{ burn(w) }}</td>\n </tr>\n }\n </tbody>\n </table>\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-days\">\n <h2>By day</h2>\n @if (d.days.length) {\n <table class=\"jc-table\">\n <thead><tr><th>Day</th><th>Requests</th><th>Good</th><th>Left out</th><th>Minutes counted</th></tr></thead>\n <tbody>\n @for (day of daysNewestFirst(d.days); track day.day) {\n <tr>\n <td class=\"jc-nowrap\">{{ day.day | date: 'MMM d' : 'UTC' }}</td>\n <td>{{ day.total.toLocaleString() }}</td>\n <td [class.jc-bad]=\"day.attainment !== null && day.attainment * 100 < d.slo.target\">{{ percent(day.attainment, 3) }}</td>\n <td class=\"jc-small\">{{ excluded(day) }}</td>\n <td [class.jc-bad]=\"day.minutes < day.expectedMinutes && !isToday(day)\">{{ day.minutes }} of {{ day.expectedMinutes }}</td>\n </tr>\n }\n </tbody>\n </table>\n } @else { <p class=\"jc-muted\">Nothing counted yet.</p> }\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-eligibility\">\n <h2>What counts</h2>\n <ul class=\"jc-small\">\n <li>Requests to <strong>{{ d.definition.service }}</strong> in {{ d.definition.environment }}: its server and consumer spans,\n {{ d.definition.operations.length ? 'only ' + d.definition.operations.join(', ') : 'every operation' }}.</li>\n <li>Never counted: {{ d.definition.excludeOperations.join(', ') || 'nothing' }} (health checks and the like).</li>\n <li>5xx, 429, a failed span and a failed message are bad.</li>\n <li>Other 4xx (the client's mistake): {{ clientErrors(d.definition) }}.</li>\n <li>408 and 499 (the client gave up): {{ d.definition.cancellations === 'Bad' ? 'counted as bad' : 'not counted' }}.</li>\n <li>Retries: each attempt the service received is its own request.</li>\n @if (d.definition.sli === 'Latency') { <li>Latency counts requests that succeeded: good at {{ d.definition.thresholdMs }} ms or less.</li> }\n </ul>\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-versions\">\n <h2>Versions</h2>\n <table class=\"jc-table\">\n <thead><tr><th>Version</th><th>Objective</th><th>From</th><th>Status</th><th>Loaded</th></tr></thead>\n <tbody>\n @for (v of d.versions; track v.version) {\n <tr [attr.data-testid]=\"'slo-version-' + v.version\">\n <td>{{ v.version }}</td><td>{{ objective(v.definition) }}</td><td class=\"jc-nowrap\">{{ v.effectiveFrom | date: 'MMM d, HH:mm' }}</td>\n <td>{{ v.status }}</td><td class=\"jc-small\">{{ v.createdAt | date: 'MMM d, HH:mm' }} by {{ v.createdBy }}</td>\n </tr>\n }\n </tbody>\n </table>\n <p class=\"jc-muted jc-small\">Each minute is counted under the version in effect then, so a new objective doesn't rewrite the past.</p>\n </section>\n }\n `,\n})\nexport class SloPage {\n readonly key = input.required<string>();\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly detail = apiResource({ params: () => this.key(), stream: ({ params }) => this.api.slo(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n protected readonly objective = objective;\n protected readonly percent = percent;\n protected readonly burn = burnText;\n\n protected readonly state = sloState;\n protected readonly times = times;\n protected windowName(name: string) { return WINDOWS[name] ?? name; }\n /** The API's allowance: each version's requests at its own target, so it agrees with the budget used. */\n protected allowed(s: SloSummary) { return Math.round(s.budgetAllowed); }\n protected daysNewestFirst(days: SloDay[]) { return [...days].reverse(); }\n protected isToday(day: SloDay) { return day.day.slice(0, 10) === new Date().toISOString().slice(0, 10); }\n protected excluded(day: SloDay) {\n const parts = [[day.excludedHealth, 'health checks'], [day.excludedCancelled, 'given up'], [day.excludedClientErrors, 'client errors']]\n .filter(([n]) => (n as number) > 0).map(([n, what]) => `${(n as number).toLocaleString()} ${what}`);\n return parts.length ? parts.join(', ') : '—';\n }\n protected clientErrors(d: SloDefinition) { return d.clientErrors === 'Bad' ? 'bad' : d.clientErrors === 'Exclude' ? 'not counted' : 'counted as good'; }\n}\n"],"mappings":";;;;;;;;;AAaA,MAAM,UAAkC;CAAE,MAAM;CAAa,OAAO;CAAc,MAAM;CAAU,MAAM;CAAW,MAAM;AAAQ;AAiHjI,IAAa,UAAb,MAAa,QAAO;CACT,MAAM,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,MAAA,CAAA,+BAAA,CAAA,CAAA;CACpB,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CACrB,SAAS,YAAY;EAAE,cAAc,KAAK,IAAG;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,IAAI,MAAM;CAAC,CAAE;CAC/F,QAAQ,eAAe,YAAY,KAAK,OAAO,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACxD,YAAY;CACZ,UAAU;CACV,OAAO;CAEP,QAAQ;CACR,QAAQ;CACjB,WAAW,MAAY;EAAI,OAAO,QAAQ,SAAS;CAAM;CAEzD,QAAQ,GAAa;EAAI,OAAO,KAAK,MAAM,EAAE,aAAa;CAAG;CAC7D,gBAAgB,MAAc;EAAI,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,QAAO;CAAI;CAC9D,QAAQ,KAAW;EAAI,OAAO,IAAI,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