@juice-js/observability 1.1.0 → 1.2.0-alpha.37

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.
Files changed (66) hide show
  1. package/README.md +4 -2
  2. package/fesm2022/juice-js-observability-agent.page-Vb7LDThl.mjs +1144 -0
  3. package/fesm2022/juice-js-observability-agent.page-Vb7LDThl.mjs.map +1 -0
  4. package/fesm2022/juice-js-observability-agents.page-Ch-tBwQO.mjs +413 -0
  5. package/fesm2022/juice-js-observability-agents.page-Ch-tBwQO.mjs.map +1 -0
  6. package/fesm2022/{juice-js-observability-alert.page-nEy5Gc6j.mjs → juice-js-observability-alert.page-2kfKksIG.mjs} +200 -4
  7. package/fesm2022/juice-js-observability-alert.page-2kfKksIG.mjs.map +1 -0
  8. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs → juice-js-observability-alerts.page-BNmez0Ak.mjs} +2 -2
  9. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs.map → juice-js-observability-alerts.page-BNmez0Ak.mjs.map} +1 -1
  10. package/fesm2022/juice-js-observability-approvals.page-DBLw-vl1.mjs +387 -0
  11. package/fesm2022/juice-js-observability-approvals.page-DBLw-vl1.mjs.map +1 -0
  12. package/fesm2022/juice-js-observability-incident.page-D2GvuIft.mjs +436 -0
  13. package/fesm2022/juice-js-observability-incident.page-D2GvuIft.mjs.map +1 -0
  14. package/fesm2022/juice-js-observability-incidents.page-DhC3BkBo.mjs +438 -0
  15. package/fesm2022/juice-js-observability-incidents.page-DhC3BkBo.mjs.map +1 -0
  16. package/fesm2022/juice-js-observability-load-runs.page-DVuO4zFp.mjs +349 -0
  17. package/fesm2022/juice-js-observability-load-runs.page-DVuO4zFp.mjs.map +1 -0
  18. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs → juice-js-observability-logs.page-PXWQMcvL.mjs} +3 -3
  19. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs.map → juice-js-observability-logs.page-PXWQMcvL.mjs.map} +1 -1
  20. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs → juice-js-observability-metrics.page-Ctm_EEFb.mjs} +3 -3
  21. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs.map → juice-js-observability-metrics.page-Ctm_EEFb.mjs.map} +1 -1
  22. package/fesm2022/juice-js-observability-notifications.page-CtcV3Ei4.mjs +758 -0
  23. package/fesm2022/juice-js-observability-notifications.page-CtcV3Ei4.mjs.map +1 -0
  24. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs → juice-js-observability-overview.page-BRGpTOyc.mjs} +3 -3
  25. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs.map → juice-js-observability-overview.page-BRGpTOyc.mjs.map} +1 -1
  26. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs → juice-js-observability-resource.page-O4GGdirR.mjs} +2 -2
  27. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs.map → juice-js-observability-resource.page-O4GGdirR.mjs.map} +1 -1
  28. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs → juice-js-observability-resources.page-B_AVPpes.mjs} +2 -2
  29. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs.map → juice-js-observability-resources.page-B_AVPpes.mjs.map} +1 -1
  30. package/fesm2022/juice-js-observability-rules.page-CARCWaw_.mjs +581 -0
  31. package/fesm2022/juice-js-observability-rules.page-CARCWaw_.mjs.map +1 -0
  32. package/fesm2022/juice-js-observability-service.page-DRj1GO0Q.mjs +1257 -0
  33. package/fesm2022/juice-js-observability-service.page-DRj1GO0Q.mjs.map +1 -0
  34. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs → juice-js-observability-services.page-BbFbbvyH.mjs} +3 -3
  35. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs.map → juice-js-observability-services.page-BbFbbvyH.mjs.map} +1 -1
  36. package/fesm2022/juice-js-observability-silences.page-CoTqfGxY.mjs +523 -0
  37. package/fesm2022/juice-js-observability-silences.page-CoTqfGxY.mjs.map +1 -0
  38. package/fesm2022/juice-js-observability-slo.page-l7TOat-D.mjs +414 -0
  39. package/fesm2022/juice-js-observability-slo.page-l7TOat-D.mjs.map +1 -0
  40. package/fesm2022/juice-js-observability-slos.page-DNG6g6_R.mjs +267 -0
  41. package/fesm2022/juice-js-observability-slos.page-DNG6g6_R.mjs.map +1 -0
  42. package/fesm2022/juice-js-observability-suggestions-eQK_z0Nd.mjs +367 -0
  43. package/fesm2022/juice-js-observability-suggestions-eQK_z0Nd.mjs.map +1 -0
  44. package/fesm2022/{juice-js-observability-telemetry-BftWSOaQ.mjs → juice-js-observability-telemetry-DVwUTHSz.mjs} +101 -91
  45. package/fesm2022/juice-js-observability-telemetry-DVwUTHSz.mjs.map +1 -0
  46. package/fesm2022/juice-js-observability-timeline.page-CFSigOgk.mjs +213 -0
  47. package/fesm2022/juice-js-observability-timeline.page-CFSigOgk.mjs.map +1 -0
  48. package/fesm2022/{juice-js-observability-topology.page-aMWEXyMB.mjs → juice-js-observability-topology.page-BDfNpiql.mjs} +56 -4
  49. package/fesm2022/juice-js-observability-topology.page-BDfNpiql.mjs.map +1 -0
  50. package/fesm2022/{juice-js-observability-trace.page-DUCWnZL5.mjs → juice-js-observability-trace.page-CdW09ADY.mjs} +10 -8
  51. package/fesm2022/juice-js-observability-trace.page-CdW09ADY.mjs.map +1 -0
  52. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs → juice-js-observability-traces.page-CMuItN_m.mjs} +3 -3
  53. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs.map → juice-js-observability-traces.page-CMuItN_m.mjs.map} +1 -1
  54. package/fesm2022/juice-js-observability.mjs +507 -110
  55. package/fesm2022/juice-js-observability.mjs.map +1 -1
  56. package/package.json +1 -1
  57. package/styles/_observability.scss +26 -3
  58. package/types/juice-js-observability.d.ts +623 -1
  59. package/fesm2022/juice-js-observability-alert.page-nEy5Gc6j.mjs.map +0 -1
  60. package/fesm2022/juice-js-observability-rules.page-Crb07uWm.mjs +0 -175
  61. package/fesm2022/juice-js-observability-rules.page-Crb07uWm.mjs.map +0 -1
  62. package/fesm2022/juice-js-observability-service.page-Dt8bN2Ry.mjs +0 -726
  63. package/fesm2022/juice-js-observability-service.page-Dt8bN2Ry.mjs.map +0 -1
  64. package/fesm2022/juice-js-observability-telemetry-BftWSOaQ.mjs.map +0 -1
  65. package/fesm2022/juice-js-observability-topology.page-aMWEXyMB.mjs.map +0 -1
  66. package/fesm2022/juice-js-observability-trace.page-DUCWnZL5.mjs.map +0 -1
@@ -0,0 +1,581 @@
1
+ import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
+ import { c as ContextBar, g as AgoPipe, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-DVwUTHSz.mjs";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, computed, inject, signal } from "@angular/core";
5
+ import { RouterLink } from "@angular/router";
6
+ import { forkJoin, map } from "rxjs";
7
+ import * as i1 from "@angular/forms";
8
+ import { FormsModule } from "@angular/forms";
9
+ import * as i2 from "@angular/material/button";
10
+ import { MatButtonModule } from "@angular/material/button";
11
+ import { MatFormFieldModule } from "@angular/material/form-field";
12
+ import * as i5 from "@angular/material/input";
13
+ import { MatInputModule } from "@angular/material/input";
14
+ import * as i6 from "@angular/material/progress-bar";
15
+ import { MatProgressBarModule } from "@angular/material/progress-bar";
16
+ import * as i4 from "@angular/material/select";
17
+ import { MatSelectModule } from "@angular/material/select";
18
+ import * as i3 from "@angular/material/checkbox";
19
+ import { MatCheckboxModule } from "@angular/material/checkbox";
20
+ const TEMPLATES = {
21
+ ErrorRate: "Ratio of failed requests, 0 to 1. Fires above the threshold.",
22
+ LatencyP95: "Milliseconds at the 95th percentile. Fires above the threshold.",
23
+ ThroughputAbsent: "Requests in the window, for a service that had traffic. Fires at or below the threshold.",
24
+ DeliveryFailureRate: "Ratio of failed deliveries, 0 to 1. Fires above the threshold.",
25
+ HostMemory: "Ratio of host memory used, 0 to 1. Fires above the threshold.",
26
+ MediatorErrors: "Mediator errors in the window. Fires above the threshold.",
27
+ ConsumerFailures: "Failed consumer messages in the window. Fires above the threshold.",
28
+ SloBurn: "An SLO's burn rate over a long and a short window. Fires when both reach the rate; one alert per SLO."
29
+ };
30
+ function seconds(value) {
31
+ const match = /^(?:(\d+)\.)?(\d+):(\d+):(\d+)/.exec(String(value ?? ""));
32
+ return match ? +(match[1] ?? 0) * 86400 + +match[2] * 3600 + +match[3] * 60 + +match[4] : 0;
33
+ }
34
+ function span(total) {
35
+ const s = Math.max(0, Math.round(total || 0));
36
+ const pad = (n) => String(n).padStart(2, "0");
37
+ const days = Math.floor(s / 86400);
38
+ return `${days ? `${days}.` : ""}${pad(Math.floor(s / 3600) % 24)}:${pad(Math.floor(s / 60) % 60)}:${pad(s % 60)}`;
39
+ }
40
+ const NEW_RULE = {
41
+ key: "",
42
+ name: "",
43
+ template: "ErrorRate",
44
+ severity: "Warning",
45
+ service: "",
46
+ environment: "",
47
+ host: "",
48
+ threshold: null,
49
+ recoveryThreshold: null,
50
+ minimumSamples: 10,
51
+ scheduleSeconds: 60,
52
+ windowSeconds: 300,
53
+ forSeconds: 120,
54
+ recoverySeconds: 120,
55
+ cooldownSeconds: 600,
56
+ enabled: true
57
+ };
58
+ var RulesPage = class RulesPage {
59
+ ctx = inject(ContextService);
60
+ api = inject(ApiService);
61
+ templates = Object.keys(TEMPLATES).filter((t) => t !== "SloBurn");
62
+ form = signal(null, ...ngDevMode ? [{ debugName: "form" }] : /* istanbul ignore next */ []);
63
+ editing = signal(null, ...ngDevMode ? [{ debugName: "editing" }] : /* istanbul ignore next */ []);
64
+ saving = signal(false, ...ngDevMode ? [{ debugName: "saving" }] : /* istanbul ignore next */ []);
65
+ saveError = signal("", ...ngDevMode ? [{ debugName: "saveError" }] : /* istanbul ignore next */ []);
66
+ data = apiResource({ stream: () => forkJoin({
67
+ rules: this.api.rules().pipe(map((p) => p.items)),
68
+ firing: this.api.allAlerts({ state: "firing" }).pipe(map((p) => p.items)),
69
+ pending: this.api.allAlerts({ state: "pending" }).pipe(map((p) => p.items))
70
+ }) });
71
+ error = computed(() => problemText(this.data.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
72
+ rows = computed(() => {
73
+ const d = this.data.value();
74
+ if (!d) return [];
75
+ const open = [...d.firing, ...d.pending];
76
+ return d.rules.map((r) => {
77
+ const mine = open.filter((a) => a.rule === r.key);
78
+ const last = mine.map((a) => a.lastEvaluatedAt).sort().at(-1) ?? null;
79
+ return {
80
+ ...r,
81
+ open: mine,
82
+ lastEvaluatedAt: last
83
+ };
84
+ });
85
+ }, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
86
+ hint(template) {
87
+ return TEMPLATES[template] ?? "";
88
+ }
89
+ startNew() {
90
+ this.editing.set(null);
91
+ this.saveError.set("");
92
+ this.form.set({ ...NEW_RULE });
93
+ }
94
+ edit(rule) {
95
+ const d = rule.definition;
96
+ this.editing.set(rule);
97
+ this.saveError.set("");
98
+ this.form.set({
99
+ key: rule.key,
100
+ name: rule.name,
101
+ template: rule.template,
102
+ severity: rule.severity,
103
+ service: String(d["service"] ?? ""),
104
+ environment: String(d["environment"] ?? ""),
105
+ host: String(d["host"] ?? ""),
106
+ threshold: d["threshold"],
107
+ recoveryThreshold: d["recoveryThreshold"] ?? null,
108
+ minimumSamples: d["minimumSamples"],
109
+ scheduleSeconds: seconds(d["schedule"]),
110
+ windowSeconds: seconds(d["window"]),
111
+ forSeconds: seconds(d["forDuration"]),
112
+ recoverySeconds: seconds(d["recoveryDuration"]),
113
+ cooldownSeconds: seconds(d["cooldown"]),
114
+ enabled: rule.enabled
115
+ });
116
+ }
117
+ save(f) {
118
+ const host = f.template === "HostMemory";
119
+ const body = {
120
+ key: f.key,
121
+ name: f.name,
122
+ template: f.template,
123
+ severity: f.severity,
124
+ service: host ? "" : f.service.trim(),
125
+ environment: host ? "" : f.environment.trim().toLowerCase(),
126
+ host: host ? f.host.trim() : "",
127
+ threshold: f.threshold,
128
+ recoveryThreshold: f.recoveryThreshold,
129
+ minimumSamples: f.minimumSamples,
130
+ schedule: span(f.scheduleSeconds),
131
+ window: span(f.windowSeconds),
132
+ forDuration: span(f.forSeconds),
133
+ recoveryDuration: span(f.recoverySeconds),
134
+ cooldown: span(f.cooldownSeconds),
135
+ enabled: f.enabled
136
+ };
137
+ const editing = this.editing();
138
+ const request = editing ? this.api.updateRule(editing.key, body, editing.etag) : this.api.createRule(body);
139
+ this.saving.set(true);
140
+ this.saveError.set("");
141
+ request.subscribe({
142
+ next: () => {
143
+ this.saving.set(false);
144
+ this.form.set(null);
145
+ this.data.reload();
146
+ },
147
+ error: (e) => {
148
+ this.saving.set(false);
149
+ this.saveError.set(problemText(e));
150
+ }
151
+ });
152
+ }
153
+ static ɵfac = i0.ɵɵngDeclareFactory({
154
+ minVersion: "12.0.0",
155
+ version: "22.2.4",
156
+ ngImport: i0,
157
+ type: RulesPage,
158
+ deps: [],
159
+ target: i0.ɵɵFactoryTarget.Component
160
+ });
161
+ static ɵcmp = i0.ɵɵngDeclareComponent({
162
+ minVersion: "17.0.0",
163
+ version: "22.2.4",
164
+ type: RulesPage,
165
+ isStandalone: true,
166
+ selector: "ng-component",
167
+ ngImport: i0,
168
+ template: `
169
+ <jc-context-bar>
170
+ <h1>Rules</h1>
171
+ <span class="jc-spacer"></span>
172
+ <button mat-flat-button type="button" data-testid="rule-new" (click)="startNew()">New rule</button>
173
+ </jc-context-bar>
174
+ @if (data.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
175
+ @if (data.error()) { <p class="jc-error">{{ error() }}</p> }
176
+ @if (form(); as f) {
177
+ <section class="jc-card" data-testid="rule-form">
178
+ <h2>{{ editing() ? 'Change ' + editing()!.key : 'New rule' }}</h2>
179
+ <form class="jc-form" (ngSubmit)="save(f)">
180
+ @if (!editing()) { <mat-form-field subscriptSizing="dynamic"><mat-label>Key</mat-label><input matInput name="key" [(ngModel)]="f.key" required></mat-form-field> }
181
+ <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>
182
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Template</mat-label>
183
+ <mat-select name="template" [(ngModel)]="f.template">@for (t of templates; track t) { <mat-option [value]="t">{{ t }}</mat-option> }</mat-select>
184
+ </mat-form-field>
185
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity</mat-label>
186
+ <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>
187
+ </mat-form-field>
188
+ @if (f.template === 'HostMemory') {
189
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Host (all if empty)</mat-label><input matInput name="host" [(ngModel)]="f.host"></mat-form-field>
190
+ } @else {
191
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Service (all if empty)</mat-label><input matInput name="service" [(ngModel)]="f.service"></mat-form-field>
192
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Environment (all if empty)</mat-label><input matInput name="environment" [(ngModel)]="f.environment"></mat-form-field>
193
+ }
194
+ <p class="jc-muted jc-small jc-form-actions">{{ hint(f.template) }}</p>
195
+ <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>
196
+ <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>
197
+ <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>
198
+ <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>
199
+ <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>
200
+ <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>
201
+ <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>
202
+ <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>
203
+ <mat-checkbox name="enabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
204
+ @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> }
205
+ <div class="jc-form-actions">
206
+ <button mat-flat-button type="submit" data-testid="rule-save" [disabled]="saving()">Save</button>
207
+ <button mat-button type="button" (click)="form.set(null)">Cancel</button>
208
+ @if (saveError()) { <span class="jc-error" data-testid="rule-error">{{ saveError() }}</span> }
209
+ </div>
210
+ </form>
211
+ </section>
212
+ }
213
+ <table class="jc-table" data-testid="rules">
214
+ <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>
215
+ <tbody>
216
+ @for (r of rows(); track r.key) {
217
+ <tr [class.jc-muted]="!r.enabled">
218
+ <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 }@if (r.managedBy === 'platform') { · the platform's, for SLOs }</div></td>
219
+ <td>{{ r.template }}</td>
220
+ <td>{{ r.severity }}</td>
221
+ <td>{{ r.definition['threshold'] ?? '—' }}</td>
222
+ <td>{{ r.definition['recoveryThreshold'] ?? '—' }}</td>
223
+ <td>{{ r.definition['forDuration'] ?? '—' }}</td>
224
+ <td>
225
+ @for (a of r.open; track a.id) {
226
+ <div><a [routerLink]="['alerts', a.id] | jcLink" [queryParams]="ctx.keep()">{{ a.state }}</a> {{ a.subjectKey }} = {{ a.lastValue ?? 'no data' }}</div>
227
+ } @empty { <span class="jc-muted">none</span> }
228
+ </td>
229
+ <td>{{ r.lastEvaluatedAt | ago }}</td>
230
+ <td class="jc-row-actions">@if (r.managedBy === 'api') { <button mat-button type="button" [attr.data-testid]="'rule-edit-' + r.key" (click)="edit(r)">Change</button> }</td>
231
+ </tr>
232
+ }
233
+ </tbody>
234
+ </table>`,
235
+ isInline: true,
236
+ dependencies: [
237
+ {
238
+ kind: "directive",
239
+ type: RouterLink,
240
+ selector: "[routerLink]",
241
+ inputs: [
242
+ "target",
243
+ "queryParams",
244
+ "fragment",
245
+ "queryParamsHandling",
246
+ "state",
247
+ "info",
248
+ "relativeTo",
249
+ "preserveFragment",
250
+ "skipLocationChange",
251
+ "replaceUrl",
252
+ "browserUrl",
253
+ "routerLink"
254
+ ]
255
+ },
256
+ {
257
+ kind: "ngmodule",
258
+ type: FormsModule
259
+ },
260
+ {
261
+ kind: "directive",
262
+ type: i1.ɵNgNoValidate,
263
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
264
+ },
265
+ {
266
+ kind: "directive",
267
+ type: i1.DefaultValueAccessor,
268
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
269
+ },
270
+ {
271
+ kind: "directive",
272
+ type: i1.NumberValueAccessor,
273
+ selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]"
274
+ },
275
+ {
276
+ kind: "directive",
277
+ type: i1.NgControlStatus,
278
+ selector: "[formControlName],[ngModel],[formControl]"
279
+ },
280
+ {
281
+ kind: "directive",
282
+ type: i1.NgControlStatusGroup,
283
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
284
+ },
285
+ {
286
+ kind: "directive",
287
+ type: i1.RequiredValidator,
288
+ selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]",
289
+ inputs: ["required"]
290
+ },
291
+ {
292
+ kind: "directive",
293
+ type: i1.NgModel,
294
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
295
+ inputs: [
296
+ "name",
297
+ "disabled",
298
+ "ngModel",
299
+ "ngModelOptions"
300
+ ],
301
+ outputs: ["ngModelChange"],
302
+ exportAs: ["ngModel"]
303
+ },
304
+ {
305
+ kind: "directive",
306
+ type: i1.NgForm,
307
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
308
+ inputs: ["ngFormOptions"],
309
+ outputs: ["ngSubmit"],
310
+ exportAs: ["ngForm"]
311
+ },
312
+ {
313
+ kind: "ngmodule",
314
+ type: MatButtonModule
315
+ },
316
+ {
317
+ kind: "component",
318
+ type: i2.MatButton,
319
+ selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
320
+ inputs: ["matButton"],
321
+ exportAs: ["matButton", "matAnchor"]
322
+ },
323
+ {
324
+ kind: "ngmodule",
325
+ type: MatCheckboxModule
326
+ },
327
+ {
328
+ kind: "component",
329
+ type: i3.MatCheckbox,
330
+ selector: "mat-checkbox",
331
+ inputs: [
332
+ "aria-label",
333
+ "aria-labelledby",
334
+ "aria-describedby",
335
+ "aria-expanded",
336
+ "aria-controls",
337
+ "aria-owns",
338
+ "id",
339
+ "required",
340
+ "labelPosition",
341
+ "name",
342
+ "value",
343
+ "disableRipple",
344
+ "tabIndex",
345
+ "color",
346
+ "disabledInteractive",
347
+ "checked",
348
+ "disabled",
349
+ "indeterminate"
350
+ ],
351
+ outputs: ["change", "indeterminateChange"],
352
+ exportAs: ["matCheckbox"]
353
+ },
354
+ {
355
+ kind: "ngmodule",
356
+ type: MatFormFieldModule
357
+ },
358
+ {
359
+ kind: "component",
360
+ type: i4.MatFormField,
361
+ selector: "mat-form-field",
362
+ inputs: [
363
+ "hideRequiredMarker",
364
+ "color",
365
+ "floatLabel",
366
+ "appearance",
367
+ "subscriptSizing",
368
+ "hintLabel"
369
+ ],
370
+ exportAs: ["matFormField"]
371
+ },
372
+ {
373
+ kind: "directive",
374
+ type: i4.MatLabel,
375
+ selector: "mat-label"
376
+ },
377
+ {
378
+ kind: "ngmodule",
379
+ type: MatInputModule
380
+ },
381
+ {
382
+ kind: "directive",
383
+ type: i5.MatInput,
384
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
385
+ inputs: [
386
+ "disabled",
387
+ "id",
388
+ "placeholder",
389
+ "name",
390
+ "required",
391
+ "type",
392
+ "errorStateMatcher",
393
+ "aria-describedby",
394
+ "value",
395
+ "readonly",
396
+ "disabledInteractive"
397
+ ],
398
+ exportAs: ["matInput"]
399
+ },
400
+ {
401
+ kind: "ngmodule",
402
+ type: MatProgressBarModule
403
+ },
404
+ {
405
+ kind: "component",
406
+ type: i6.MatProgressBar,
407
+ selector: "mat-progress-bar",
408
+ inputs: [
409
+ "color",
410
+ "value",
411
+ "bufferValue",
412
+ "mode"
413
+ ],
414
+ outputs: ["animationEnd"],
415
+ exportAs: ["matProgressBar"]
416
+ },
417
+ {
418
+ kind: "ngmodule",
419
+ type: MatSelectModule
420
+ },
421
+ {
422
+ kind: "component",
423
+ type: i4.MatSelect,
424
+ selector: "mat-select",
425
+ inputs: [
426
+ "aria-describedby",
427
+ "panelClass",
428
+ "disabled",
429
+ "disableRipple",
430
+ "tabIndex",
431
+ "hideSingleSelectionIndicator",
432
+ "placeholder",
433
+ "required",
434
+ "multiple",
435
+ "disableOptionCentering",
436
+ "compareWith",
437
+ "value",
438
+ "aria-label",
439
+ "aria-labelledby",
440
+ "errorStateMatcher",
441
+ "typeaheadDebounceInterval",
442
+ "sortComparator",
443
+ "id",
444
+ "panelWidth",
445
+ "canSelectNullableOptions"
446
+ ],
447
+ outputs: [
448
+ "openedChange",
449
+ "opened",
450
+ "closed",
451
+ "selectionChange",
452
+ "valueChange"
453
+ ],
454
+ exportAs: ["matSelect"]
455
+ },
456
+ {
457
+ kind: "component",
458
+ type: i4.MatOption,
459
+ selector: "mat-option",
460
+ inputs: [
461
+ "value",
462
+ "id",
463
+ "disabled"
464
+ ],
465
+ outputs: ["onSelectionChange"],
466
+ exportAs: ["matOption"]
467
+ },
468
+ {
469
+ kind: "component",
470
+ type: ContextBar,
471
+ selector: "jc-context-bar"
472
+ },
473
+ {
474
+ kind: "pipe",
475
+ type: LinkPipe,
476
+ name: "jcLink"
477
+ },
478
+ {
479
+ kind: "pipe",
480
+ type: AgoPipe,
481
+ name: "ago"
482
+ }
483
+ ],
484
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
485
+ });
486
+ };
487
+ i0.ɵɵngDeclareClassMetadata({
488
+ minVersion: "12.0.0",
489
+ version: "22.2.4",
490
+ ngImport: i0,
491
+ type: RulesPage,
492
+ decorators: [{
493
+ type: Component,
494
+ args: [{
495
+ changeDetection: ChangeDetectionStrategy.OnPush,
496
+ imports: [
497
+ LinkPipe,
498
+ RouterLink,
499
+ FormsModule,
500
+ MatButtonModule,
501
+ MatCheckboxModule,
502
+ MatFormFieldModule,
503
+ MatInputModule,
504
+ MatProgressBarModule,
505
+ MatSelectModule,
506
+ ContextBar,
507
+ AgoPipe
508
+ ],
509
+ template: `
510
+ <jc-context-bar>
511
+ <h1>Rules</h1>
512
+ <span class="jc-spacer"></span>
513
+ <button mat-flat-button type="button" data-testid="rule-new" (click)="startNew()">New rule</button>
514
+ </jc-context-bar>
515
+ @if (data.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
516
+ @if (data.error()) { <p class="jc-error">{{ error() }}</p> }
517
+ @if (form(); as f) {
518
+ <section class="jc-card" data-testid="rule-form">
519
+ <h2>{{ editing() ? 'Change ' + editing()!.key : 'New rule' }}</h2>
520
+ <form class="jc-form" (ngSubmit)="save(f)">
521
+ @if (!editing()) { <mat-form-field subscriptSizing="dynamic"><mat-label>Key</mat-label><input matInput name="key" [(ngModel)]="f.key" required></mat-form-field> }
522
+ <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>
523
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Template</mat-label>
524
+ <mat-select name="template" [(ngModel)]="f.template">@for (t of templates; track t) { <mat-option [value]="t">{{ t }}</mat-option> }</mat-select>
525
+ </mat-form-field>
526
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity</mat-label>
527
+ <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>
528
+ </mat-form-field>
529
+ @if (f.template === 'HostMemory') {
530
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Host (all if empty)</mat-label><input matInput name="host" [(ngModel)]="f.host"></mat-form-field>
531
+ } @else {
532
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Service (all if empty)</mat-label><input matInput name="service" [(ngModel)]="f.service"></mat-form-field>
533
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Environment (all if empty)</mat-label><input matInput name="environment" [(ngModel)]="f.environment"></mat-form-field>
534
+ }
535
+ <p class="jc-muted jc-small jc-form-actions">{{ hint(f.template) }}</p>
536
+ <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>
537
+ <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>
538
+ <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>
539
+ <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>
540
+ <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>
541
+ <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>
542
+ <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>
543
+ <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>
544
+ <mat-checkbox name="enabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
545
+ @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> }
546
+ <div class="jc-form-actions">
547
+ <button mat-flat-button type="submit" data-testid="rule-save" [disabled]="saving()">Save</button>
548
+ <button mat-button type="button" (click)="form.set(null)">Cancel</button>
549
+ @if (saveError()) { <span class="jc-error" data-testid="rule-error">{{ saveError() }}</span> }
550
+ </div>
551
+ </form>
552
+ </section>
553
+ }
554
+ <table class="jc-table" data-testid="rules">
555
+ <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>
556
+ <tbody>
557
+ @for (r of rows(); track r.key) {
558
+ <tr [class.jc-muted]="!r.enabled">
559
+ <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 }@if (r.managedBy === 'platform') { · the platform's, for SLOs }</div></td>
560
+ <td>{{ r.template }}</td>
561
+ <td>{{ r.severity }}</td>
562
+ <td>{{ r.definition['threshold'] ?? '—' }}</td>
563
+ <td>{{ r.definition['recoveryThreshold'] ?? '—' }}</td>
564
+ <td>{{ r.definition['forDuration'] ?? '—' }}</td>
565
+ <td>
566
+ @for (a of r.open; track a.id) {
567
+ <div><a [routerLink]="['alerts', a.id] | jcLink" [queryParams]="ctx.keep()">{{ a.state }}</a> {{ a.subjectKey }} = {{ a.lastValue ?? 'no data' }}</div>
568
+ } @empty { <span class="jc-muted">none</span> }
569
+ </td>
570
+ <td>{{ r.lastEvaluatedAt | ago }}</td>
571
+ <td class="jc-row-actions">@if (r.managedBy === 'api') { <button mat-button type="button" [attr.data-testid]="'rule-edit-' + r.key" (click)="edit(r)">Change</button> }</td>
572
+ </tr>
573
+ }
574
+ </tbody>
575
+ </table>`
576
+ }]
577
+ }]
578
+ });
579
+ export { RulesPage };
580
+
581
+ //# sourceMappingURL=juice-js-observability-rules.page-CARCWaw_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-rules.page-CARCWaw_.mjs","names":[],"sources":["../../../../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 SloBurn: \"An SLO's burn rate over a long and a short window. Fires when both reach the rate; one alert per SLO.\",\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 }@if (r.managedBy === 'platform') { · the platform's, for SLOs }</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 === 'api') { <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 /** What a rule can be made from: SloBurn is described, but its rules are the platform's own, made for SLOs. */\n protected readonly templates = Object.keys(TEMPLATES).filter(t => t !== 'SloBurn');\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;CAClB,SAAS;AACV;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,K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