@oneuptime/common 14.0.100 → 14.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/NetworkTrafficUsage.js +30 -10
- package/Models/DatabaseModels/KubernetesResource.d.mts +1 -0
- package/Models/DatabaseModels/KubernetesResource.d.ts +1 -0
- package/Models/DatabaseModels/KubernetesResource.js +36 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.d.mts +3 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.d.ts +3 -0
- package/Types/AutoRemediation/AiRemediationCommandPlan.js +11 -2
- package/Types/AutoRemediation/RemediationTrackRecord.d.mts +26 -0
- package/Types/AutoRemediation/RemediationTrackRecord.d.ts +26 -0
- package/Types/AutoRemediation/RemediationTrackRecord.js +137 -0
- package/Types/AutoRemediation/RemediationTrackRecord.mjs +8 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.d.mts +10 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.d.ts +10 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.js +86 -0
- package/Types/AutoRemediation/RemediationTrackRecordWords.mjs +9 -0
- package/Types/Kubernetes/KubernetesHealth.d.mts +92 -0
- package/Types/Kubernetes/KubernetesHealth.d.ts +92 -0
- package/Types/Kubernetes/KubernetesHealth.js +1273 -0
- package/Types/Kubernetes/KubernetesHealth.mjs +32 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.d.mts +2 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.d.ts +2 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.js +7 -0
- package/Types/Kubernetes/KubernetesObjectParser.d.mts +30 -0
- package/Types/Kubernetes/KubernetesObjectParser.d.ts +30 -0
- package/Types/Kubernetes/KubernetesObjectParser.js +164 -38
- package/Types/Kubernetes/KubernetesObjectParser.mjs +3 -0
- package/Types/Monitor/KubernetesAlertTemplates.js +238 -0
- package/Types/Monitor/KubernetesMetricCatalog.js +57 -0
- package/Types/Monitor/MetricMonitor/MetricMonitorResponse.d.mts +1 -0
- package/Types/Monitor/MetricMonitor/MetricMonitorResponse.d.ts +1 -0
- package/Types/NetFlow/NetworkTrafficUsage.d.mts +40 -1
- package/Types/NetFlow/NetworkTrafficUsage.d.ts +40 -1
- package/Types/NetFlow/NetworkTrafficUsage.js +58 -6
- package/Types/NetFlow/NetworkTrafficUsage.mjs +1 -0
- package/Utils/AI/InvestigationReport.d.mts +9 -0
- package/Utils/AI/InvestigationReport.d.ts +9 -0
- package/Utils/AI/InvestigationReport.js +122 -10
- package/Utils/AI/InvestigationReport.mjs +3 -0
- package/Utils/AiRemediation/CloudChangeWords.d.mts +32 -0
- package/Utils/AiRemediation/CloudChangeWords.d.ts +32 -0
- package/Utils/AiRemediation/CloudChangeWords.js +242 -0
- package/Utils/AiRemediation/CloudChangeWords.mjs +8 -0
- package/Utils/AiRemediation/RemediationChangeKey.d.mts +2 -0
- package/Utils/AiRemediation/RemediationChangeKey.d.ts +2 -0
- package/Utils/AiRemediation/RemediationChangeKey.js +132 -0
- package/Utils/AiRemediation/RemediationChangeKey.mjs +2 -0
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ const Permission_1 = __importDefault(require("../../Types/Permission"));
|
|
|
24
24
|
* Traffic a network's controller reported - today the Meraki dashboard API
|
|
25
25
|
* (OneUptime issue #5140) - read on a schedule by a
|
|
26
26
|
* NetworkControllerConnection. Unlike a NetworkFlow, a row is a TOTAL over
|
|
27
|
-
* a window the read covered, of one of
|
|
27
|
+
* a window the read covered, of one of four kinds
|
|
28
28
|
* (Types/NetFlow/NetworkTrafficUsage):
|
|
29
29
|
*
|
|
30
30
|
* uplink the bytes one appliance sent and received on one uplink
|
|
@@ -34,7 +34,9 @@ const Permission_1 = __importDefault(require("../../Types/Permission"));
|
|
|
34
34
|
* Meraki's own aggregation; the rest of a busy window
|
|
35
35
|
* summed into one row whose application is empty;
|
|
36
36
|
* client the bytes one client sent and received on one network,
|
|
37
|
-
* read with the applications
|
|
37
|
+
* read with the applications;
|
|
38
|
+
* uplinkHealth the packet loss and latency Meraki measured on one uplink
|
|
39
|
+
* of one appliance - five-minute windows, no bytes.
|
|
38
40
|
*
|
|
39
41
|
* Every row carries the window it covers, so a page counts each window's
|
|
40
42
|
* share of its range. A window that was read again replaces nothing: the
|
|
@@ -43,8 +45,8 @@ const Permission_1 = __importDefault(require("../../Types/Permission"));
|
|
|
43
45
|
*
|
|
44
46
|
* Read through the device the traffic belongs to, exactly as flows are:
|
|
45
47
|
* an appliance that is a device in OneUptime (matched by serial number or
|
|
46
|
-
* MAC address when the row was written) owns its uplinks
|
|
47
|
-
* applications and clients; everything else carries the project's ID in
|
|
48
|
+
* MAC address when the row was written) owns its uplinks, their health and
|
|
49
|
+
* its network's applications and clients; everything else carries the project's ID in
|
|
48
50
|
* its place - the project's bucket, which a project-wide or Owned grant
|
|
49
51
|
* reads and a grant limited to labels does not.
|
|
50
52
|
*
|
|
@@ -113,7 +115,7 @@ let NetworkTrafficUsage = class NetworkTrafficUsage extends AnalyticsBaseModel_1
|
|
|
113
115
|
column({
|
|
114
116
|
key: "kind",
|
|
115
117
|
title: "Kind",
|
|
116
|
-
description: "What the row totals: 'uplink' (one uplink of one appliance), 'application' (one application and destination of one network)
|
|
118
|
+
description: "What the row totals: 'uplink' (one uplink of one appliance), 'application' (one application and destination of one network), 'client' (one client of one network) or 'uplinkHealth' (the loss and latency of one uplink of one appliance)",
|
|
117
119
|
type: TableColumnType_1.default.Text,
|
|
118
120
|
isLowCardinality: true,
|
|
119
121
|
}),
|
|
@@ -134,21 +136,21 @@ let NetworkTrafficUsage = class NetworkTrafficUsage extends AnalyticsBaseModel_1
|
|
|
134
136
|
column({
|
|
135
137
|
key: "deviceSerial",
|
|
136
138
|
title: "Device Serial",
|
|
137
|
-
description: "Uplink rows: the appliance's serial number. Empty on other rows",
|
|
139
|
+
description: "Uplink and uplink health rows: the appliance's serial number. Empty on other rows",
|
|
138
140
|
type: TableColumnType_1.default.Text,
|
|
139
141
|
isLowCardinality: true,
|
|
140
142
|
}),
|
|
141
143
|
column({
|
|
142
144
|
key: "deviceName",
|
|
143
145
|
title: "Device Name",
|
|
144
|
-
description: "Uplink rows: the appliance's name in the controller. Empty on other rows",
|
|
146
|
+
description: "Uplink and uplink health rows: the appliance's name in the controller. Empty on other rows",
|
|
145
147
|
type: TableColumnType_1.default.Text,
|
|
146
148
|
isLowCardinality: true,
|
|
147
149
|
}),
|
|
148
150
|
column({
|
|
149
151
|
key: "interfaceName",
|
|
150
152
|
title: "Interface Name",
|
|
151
|
-
description: "Uplink rows: the uplink (wan1, wan2, wan3, cellular). Empty on other rows",
|
|
153
|
+
description: "Uplink and uplink health rows: the uplink (wan1, wan2, wan3, cellular). Empty on other rows",
|
|
152
154
|
type: TableColumnType_1.default.Text,
|
|
153
155
|
isLowCardinality: true,
|
|
154
156
|
}),
|
|
@@ -233,6 +235,24 @@ let NetworkTrafficUsage = class NetworkTrafficUsage extends AnalyticsBaseModel_1
|
|
|
233
235
|
description: "Application rows: how many clients used the application. 0 on other rows",
|
|
234
236
|
type: TableColumnType_1.default.Number,
|
|
235
237
|
}),
|
|
238
|
+
/*
|
|
239
|
+
* Nullable: a row of any other kind measures neither, and an uplink
|
|
240
|
+
* that is down can lose every packet with no latency to report.
|
|
241
|
+
*/
|
|
242
|
+
column({
|
|
243
|
+
key: "lossPercent",
|
|
244
|
+
title: "Loss Percent",
|
|
245
|
+
description: "Uplink health rows: the average packet loss the controller measured over the window, 0 to 100. Empty on other rows",
|
|
246
|
+
type: TableColumnType_1.default.Decimal,
|
|
247
|
+
required: false,
|
|
248
|
+
}),
|
|
249
|
+
column({
|
|
250
|
+
key: "latencyMs",
|
|
251
|
+
title: "Latency",
|
|
252
|
+
description: "Uplink health rows: the average latency the controller measured over the window, in milliseconds. Empty on other rows",
|
|
253
|
+
type: TableColumnType_1.default.Decimal,
|
|
254
|
+
required: false,
|
|
255
|
+
}),
|
|
236
256
|
column({
|
|
237
257
|
key: "windowStartAt",
|
|
238
258
|
title: "Window Start",
|
|
@@ -255,8 +275,8 @@ let NetworkTrafficUsage = class NetworkTrafficUsage extends AnalyticsBaseModel_1
|
|
|
255
275
|
projections: [],
|
|
256
276
|
/*
|
|
257
277
|
* Every read is one kind over a time range of one project, so the key
|
|
258
|
-
* leads with those: a page's
|
|
259
|
-
*
|
|
278
|
+
* leads with those: each of a page's reads touches only the parts of
|
|
279
|
+
* its kind and its window.
|
|
260
280
|
*/
|
|
261
281
|
sortKeys: ["projectId", "kind", "windowStartAt"],
|
|
262
282
|
primaryKeys: ["projectId", "kind", "windowStartAt"],
|
|
@@ -24,6 +24,7 @@ export default class KubernetesResource extends BaseModel {
|
|
|
24
24
|
spec?: JSONObject;
|
|
25
25
|
containerCount?: number;
|
|
26
26
|
status?: JSONObject;
|
|
27
|
+
healthSeverity?: string;
|
|
27
28
|
controllerDeploymentName?: string;
|
|
28
29
|
controllerCronJobName?: string;
|
|
29
30
|
latestCpuPercent?: number;
|
|
@@ -24,6 +24,7 @@ export default class KubernetesResource extends BaseModel {
|
|
|
24
24
|
spec?: JSONObject;
|
|
25
25
|
containerCount?: number;
|
|
26
26
|
status?: JSONObject;
|
|
27
|
+
healthSeverity?: string;
|
|
27
28
|
controllerDeploymentName?: string;
|
|
28
29
|
controllerCronJobName?: string;
|
|
29
30
|
latestCpuPercent?: number;
|
|
@@ -83,6 +83,12 @@ let KubernetesResource = class KubernetesResource extends DatabaseBaseModel_1.de
|
|
|
83
83
|
this.spec = undefined;
|
|
84
84
|
this.containerCount = undefined;
|
|
85
85
|
this.status = undefined;
|
|
86
|
+
/*
|
|
87
|
+
* The object's verdict when it was last seen, by
|
|
88
|
+
* Common/Types/Kubernetes/KubernetesHealth: what the Overview's Needs
|
|
89
|
+
* attention reads, and lists can sort by. Written by ingest only.
|
|
90
|
+
*/
|
|
91
|
+
this.healthSeverity = undefined;
|
|
86
92
|
this.controllerDeploymentName = undefined;
|
|
87
93
|
this.controllerCronJobName = undefined;
|
|
88
94
|
this.latestCpuPercent = undefined;
|
|
@@ -473,6 +479,26 @@ __decorate([
|
|
|
473
479
|
}),
|
|
474
480
|
__metadata("design:type", Object)
|
|
475
481
|
], KubernetesResource.prototype, "status", void 0);
|
|
482
|
+
__decorate([
|
|
483
|
+
(0, ColumnAccessControl_1.default)({
|
|
484
|
+
create: [],
|
|
485
|
+
read: READ_PERMISSIONS,
|
|
486
|
+
update: [],
|
|
487
|
+
}),
|
|
488
|
+
(0, TableColumn_1.default)({
|
|
489
|
+
required: false,
|
|
490
|
+
type: TableColumnType_1.default.ShortText,
|
|
491
|
+
canReadOnRelationQuery: true,
|
|
492
|
+
title: "Health Severity",
|
|
493
|
+
description: "Whether the object needed attention when last seen: critical or warning, empty when it did not.",
|
|
494
|
+
}),
|
|
495
|
+
(0, typeorm_1.Column)({
|
|
496
|
+
nullable: true,
|
|
497
|
+
type: ColumnType_1.default.ShortText,
|
|
498
|
+
length: ColumnLength_1.default.ShortText,
|
|
499
|
+
}),
|
|
500
|
+
__metadata("design:type", String)
|
|
501
|
+
], KubernetesResource.prototype, "healthSeverity", void 0);
|
|
476
502
|
__decorate([
|
|
477
503
|
(0, ColumnAccessControl_1.default)({
|
|
478
504
|
create: [],
|
|
@@ -780,6 +806,16 @@ KubernetesResource = __decorate([
|
|
|
780
806
|
}),
|
|
781
807
|
(0, typeorm_1.Index)(["projectId", "kubernetesClusterId", "kind", "namespaceKey", "name"], {
|
|
782
808
|
unique: true,
|
|
809
|
+
})
|
|
810
|
+
/*
|
|
811
|
+
* What needs attention in a cluster (healthSeverity set): what its Overview
|
|
812
|
+
* reads every time it refreshes. Partial, so it holds the few objects that
|
|
813
|
+
* need someone rather than the whole inventory; "deletedAt" IS NULL as the
|
|
814
|
+
* read always carries it. Built online in its own migration (OnlineDdl).
|
|
815
|
+
*/
|
|
816
|
+
,
|
|
817
|
+
(0, typeorm_1.Index)(["kubernetesClusterId"], {
|
|
818
|
+
where: '"healthSeverity" IS NOT NULL AND "deletedAt" IS NULL',
|
|
783
819
|
}),
|
|
784
820
|
(0, typeorm_1.Entity)({
|
|
785
821
|
name: "KubernetesResource",
|
|
@@ -5,6 +5,7 @@ import { AiRemediationCommandPolicyVerdict, MAX_COMMAND_LENGTH_CHARS } from "./A
|
|
|
5
5
|
import AiResourceType from "../ResourceAiAgent/AiResourceType.mjs";
|
|
6
6
|
import { ResourceCommandTier } from "../ResourceAiAgent/ResourceAiAccess.mjs";
|
|
7
7
|
import { AiRemediationCommandGitOps, AiRemediationRevertWatch } from "./AiRemediationGitOps.mjs";
|
|
8
|
+
import { RemediationTrackRecord } from "./RemediationTrackRecord.mjs";
|
|
8
9
|
export { AiRemediationCommandPolicyVerdict, MAX_COMMAND_LENGTH_CHARS };
|
|
9
10
|
export declare const AI_COMMAND_STEP_TYPES: Array<RunbookStepType>;
|
|
10
11
|
export declare const STORED_AI_COMMAND_STEP_TYPES: Array<RunbookStepType>;
|
|
@@ -79,6 +80,7 @@ export interface AiRemediationCommand {
|
|
|
79
80
|
gitOps?: AiRemediationCommandGitOps | undefined;
|
|
80
81
|
revertWatch?: AiRemediationRevertWatch | undefined;
|
|
81
82
|
dryRun?: AiRemediationCommandDryRun | undefined;
|
|
83
|
+
trackRecord?: RemediationTrackRecord | undefined;
|
|
82
84
|
execution?: AiRemediationCommandExecutionState | undefined;
|
|
83
85
|
rollbackExecution?: AiRemediationCommandExecutionState | undefined;
|
|
84
86
|
}
|
|
@@ -131,6 +133,7 @@ export declare class AiRemediationCommandPlanUtil {
|
|
|
131
133
|
private static parseResourceFields;
|
|
132
134
|
private static parseKubectlFacts;
|
|
133
135
|
static parseDryRunFact(value: unknown): Pick<AiRemediationCommand, "dryRun">;
|
|
136
|
+
static parseTrackRecordFact(value: unknown): Pick<AiRemediationCommand, "trackRecord">;
|
|
134
137
|
static toJSON(plan: AiRemediationCommandPlan): JSONObject;
|
|
135
138
|
private static parseExecutionState;
|
|
136
139
|
}
|
|
@@ -5,6 +5,7 @@ import { AiRemediationCommandPolicyVerdict, MAX_COMMAND_LENGTH_CHARS } from "./A
|
|
|
5
5
|
import AiResourceType from "../ResourceAiAgent/AiResourceType";
|
|
6
6
|
import { ResourceCommandTier } from "../ResourceAiAgent/ResourceAiAccess";
|
|
7
7
|
import { AiRemediationCommandGitOps, AiRemediationRevertWatch } from "./AiRemediationGitOps";
|
|
8
|
+
import { RemediationTrackRecord } from "./RemediationTrackRecord";
|
|
8
9
|
export { AiRemediationCommandPolicyVerdict, MAX_COMMAND_LENGTH_CHARS };
|
|
9
10
|
export declare const AI_COMMAND_STEP_TYPES: Array<RunbookStepType>;
|
|
10
11
|
export declare const STORED_AI_COMMAND_STEP_TYPES: Array<RunbookStepType>;
|
|
@@ -79,6 +80,7 @@ export interface AiRemediationCommand {
|
|
|
79
80
|
gitOps?: AiRemediationCommandGitOps | undefined;
|
|
80
81
|
revertWatch?: AiRemediationRevertWatch | undefined;
|
|
81
82
|
dryRun?: AiRemediationCommandDryRun | undefined;
|
|
83
|
+
trackRecord?: RemediationTrackRecord | undefined;
|
|
82
84
|
execution?: AiRemediationCommandExecutionState | undefined;
|
|
83
85
|
rollbackExecution?: AiRemediationCommandExecutionState | undefined;
|
|
84
86
|
}
|
|
@@ -131,6 +133,7 @@ export declare class AiRemediationCommandPlanUtil {
|
|
|
131
133
|
private static parseResourceFields;
|
|
132
134
|
private static parseKubectlFacts;
|
|
133
135
|
static parseDryRunFact(value: unknown): Pick<AiRemediationCommand, "dryRun">;
|
|
136
|
+
static parseTrackRecordFact(value: unknown): Pick<AiRemediationCommand, "trackRecord">;
|
|
134
137
|
static toJSON(plan: AiRemediationCommandPlan): JSONObject;
|
|
135
138
|
private static parseExecutionState;
|
|
136
139
|
}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "MAX_COMMAND_LENGTH_CHARS", { enumerable: true, g
|
|
|
21
21
|
const AiResourceType_1 = require("../ResourceAiAgent/AiResourceType");
|
|
22
22
|
const ResourceAiAccess_1 = require("../ResourceAiAgent/ResourceAiAccess");
|
|
23
23
|
const AiRemediationGitOps_1 = require("./AiRemediationGitOps");
|
|
24
|
+
const RemediationTrackRecord_1 = require("./RemediationTrackRecord");
|
|
24
25
|
/*
|
|
25
26
|
* The AI-composed command plan stored on
|
|
26
27
|
* AutoRemediationSuggestion.commandPlan (jsonb). Everything in here is
|
|
@@ -329,7 +330,7 @@ class AiRemediationCommandPlanUtil {
|
|
|
329
330
|
const timeoutInMs = typeof timeoutRaw === "number" && Number.isFinite(timeoutRaw)
|
|
330
331
|
? Math.min(exports.MAX_COMMAND_TIMEOUT_MS, Math.max(exports.MIN_COMMAND_TIMEOUT_MS, Math.floor(timeoutRaw)))
|
|
331
332
|
: exports.DEFAULT_COMMAND_TIMEOUT_MS;
|
|
332
|
-
commands.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sequence: typeof obj["sequence"] === "number"
|
|
333
|
+
commands.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sequence: typeof obj["sequence"] === "number"
|
|
333
334
|
? obj["sequence"]
|
|
334
335
|
: commands.length + 1, stepType: stepType, runnerId: runnerId, runnerNameSnapshot: typeof obj["runnerNameSnapshot"] === "string"
|
|
335
336
|
? obj["runnerNameSnapshot"]
|
|
@@ -350,7 +351,7 @@ class AiRemediationCommandPlanUtil {
|
|
|
350
351
|
? { rolledBackChangeId: obj["rolledBackChangeId"] }
|
|
351
352
|
: {})), { wasAutoExecuted: obj["wasAutoExecuted"] === true }), (stepType === RunbookStepType_1.default.Kubectl
|
|
352
353
|
? AiRemediationCommandPlanUtil.parseKubectlFacts(obj)
|
|
353
|
-
: {})), AiRemediationCommandPlanUtil.parseDryRunFact(obj["dryRun"])), { execution: AiRemediationCommandPlanUtil.parseExecutionState(obj["execution"]), rollbackExecution: AiRemediationCommandPlanUtil.parseExecutionState(obj["rollbackExecution"]) }));
|
|
354
|
+
: {})), AiRemediationCommandPlanUtil.parseDryRunFact(obj["dryRun"])), AiRemediationCommandPlanUtil.parseTrackRecordFact(obj["trackRecord"])), { execution: AiRemediationCommandPlanUtil.parseExecutionState(obj["execution"]), rollbackExecution: AiRemediationCommandPlanUtil.parseExecutionState(obj["rollbackExecution"]) }));
|
|
354
355
|
}
|
|
355
356
|
// Execution order must be unambiguous.
|
|
356
357
|
commands.sort((a, b) => {
|
|
@@ -470,6 +471,14 @@ class AiRemediationCommandPlanUtil {
|
|
|
470
471
|
}
|
|
471
472
|
return { dryRun };
|
|
472
473
|
}
|
|
474
|
+
/*
|
|
475
|
+
* A stored track record, when well-formed (parseRemediationTrackRecord);
|
|
476
|
+
* dropped otherwise - a fact, never what decides a run.
|
|
477
|
+
*/
|
|
478
|
+
static parseTrackRecordFact(value) {
|
|
479
|
+
const trackRecord = (0, RemediationTrackRecord_1.parseRemediationTrackRecord)(value);
|
|
480
|
+
return trackRecord ? { trackRecord } : {};
|
|
481
|
+
}
|
|
473
482
|
static toJSON(plan) {
|
|
474
483
|
return JSON.parse(JSON.stringify(plan));
|
|
475
484
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const REMEDIATION_TRACK_RECORD_LOOKBACK_DAYS: number;
|
|
2
|
+
export declare const REMEDIATION_TRACK_RECORD_MAX_FIXES_READ: number;
|
|
3
|
+
export declare const MAX_TRACK_RECORD_RUNS: number;
|
|
4
|
+
export declare enum RemediationTrackRecordOutcome {
|
|
5
|
+
Worked = "Worked",
|
|
6
|
+
DidNotWork = "DidNotWork"
|
|
7
|
+
}
|
|
8
|
+
export interface RemediationTrackRecordRun {
|
|
9
|
+
subjectKind: "incident" | "alert";
|
|
10
|
+
subjectId: string;
|
|
11
|
+
subjectNumber?: string | undefined;
|
|
12
|
+
ranAt: string;
|
|
13
|
+
outcome: RemediationTrackRecordOutcome;
|
|
14
|
+
}
|
|
15
|
+
export interface RemediationTrackRecord {
|
|
16
|
+
workedCount: number;
|
|
17
|
+
didNotWorkCount: number;
|
|
18
|
+
runs: Array<RemediationTrackRecordRun>;
|
|
19
|
+
}
|
|
20
|
+
export declare enum RemediationTrackRecordTone {
|
|
21
|
+
Worked = "Worked",
|
|
22
|
+
Mixed = "Mixed",
|
|
23
|
+
DidNotWork = "DidNotWork"
|
|
24
|
+
}
|
|
25
|
+
export declare function parseRemediationTrackRecord(value: unknown): RemediationTrackRecord | undefined;
|
|
26
|
+
export declare function getRemediationTrackRecordTone(record: RemediationTrackRecord): RemediationTrackRecordTone;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const REMEDIATION_TRACK_RECORD_LOOKBACK_DAYS: number;
|
|
2
|
+
export declare const REMEDIATION_TRACK_RECORD_MAX_FIXES_READ: number;
|
|
3
|
+
export declare const MAX_TRACK_RECORD_RUNS: number;
|
|
4
|
+
export declare enum RemediationTrackRecordOutcome {
|
|
5
|
+
Worked = "Worked",
|
|
6
|
+
DidNotWork = "DidNotWork"
|
|
7
|
+
}
|
|
8
|
+
export interface RemediationTrackRecordRun {
|
|
9
|
+
subjectKind: "incident" | "alert";
|
|
10
|
+
subjectId: string;
|
|
11
|
+
subjectNumber?: string | undefined;
|
|
12
|
+
ranAt: string;
|
|
13
|
+
outcome: RemediationTrackRecordOutcome;
|
|
14
|
+
}
|
|
15
|
+
export interface RemediationTrackRecord {
|
|
16
|
+
workedCount: number;
|
|
17
|
+
didNotWorkCount: number;
|
|
18
|
+
runs: Array<RemediationTrackRecordRun>;
|
|
19
|
+
}
|
|
20
|
+
export declare enum RemediationTrackRecordTone {
|
|
21
|
+
Worked = "Worked",
|
|
22
|
+
Mixed = "Mixed",
|
|
23
|
+
DidNotWork = "DidNotWork"
|
|
24
|
+
}
|
|
25
|
+
export declare function parseRemediationTrackRecord(value: unknown): RemediationTrackRecord | undefined;
|
|
26
|
+
export declare function getRemediationTrackRecordTone(record: RemediationTrackRecord): RemediationTrackRecordTone;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* WHAT A CHANGE DID THE LAST TIMES ONEUPTIME AI MADE IT.
|
|
4
|
+
*
|
|
5
|
+
* A fix OneUptime AI proposes for approval says, under each change, how the
|
|
6
|
+
* same change went before on the same cluster or resource: how many of the
|
|
7
|
+
* fixes it was part of worked - their verification found the monitors back
|
|
8
|
+
* up, or the incident or alert resolved, in time - and how many did not,
|
|
9
|
+
* with the newest ones named. The best responders reach for what worked last
|
|
10
|
+
* time, and the person approving decides faster when they can see it; so
|
|
11
|
+
* OneUptime AI reads the same record before it plans
|
|
12
|
+
* (Server/Utils/AI/Remediation/RemediationTrackRecordReader) and each
|
|
13
|
+
* proposed change carries it (AiRemediationCommand.trackRecord), for the
|
|
14
|
+
* Remediation step and the Slack and Microsoft Teams message to show.
|
|
15
|
+
*
|
|
16
|
+
* "The same change" is RemediationChangeKey's: the same action on the same
|
|
17
|
+
* object of the same cluster or resource, whatever its numbers (a scale to 6
|
|
18
|
+
* or to 8 is one change). A fix is judged as a whole, so a change counts as
|
|
19
|
+
* having worked when the fix it was part of was verified fixed; a change
|
|
20
|
+
* that did not run (it failed, or was never reached) says nothing about
|
|
21
|
+
* itself and is not counted.
|
|
22
|
+
*
|
|
23
|
+
* Pure and React-free: the server writes it, the Dashboard and the chat
|
|
24
|
+
* messages read it back with parseRemediationTrackRecord, which drops what
|
|
25
|
+
* is malformed - a fact, never what decides anything. Its sentences are
|
|
26
|
+
* RemediationTrackRecordWords'.
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.RemediationTrackRecordTone = exports.RemediationTrackRecordOutcome = exports.MAX_TRACK_RECORD_RUNS = exports.REMEDIATION_TRACK_RECORD_MAX_FIXES_READ = exports.REMEDIATION_TRACK_RECORD_LOOKBACK_DAYS = void 0;
|
|
30
|
+
exports.parseRemediationTrackRecord = parseRemediationTrackRecord;
|
|
31
|
+
exports.getRemediationTrackRecordTone = getRemediationTrackRecordTone;
|
|
32
|
+
// How far back the record reaches.
|
|
33
|
+
exports.REMEDIATION_TRACK_RECORD_LOOKBACK_DAYS = 90;
|
|
34
|
+
// The earlier fixes read per cluster or resource, at most.
|
|
35
|
+
exports.REMEDIATION_TRACK_RECORD_MAX_FIXES_READ = 25;
|
|
36
|
+
// The runs a record names (the newest), at most.
|
|
37
|
+
exports.MAX_TRACK_RECORD_RUNS = 3;
|
|
38
|
+
// The count a record keeps, at most (a number, never a list).
|
|
39
|
+
const MAX_TRACK_RECORD_COUNT = 1000;
|
|
40
|
+
var RemediationTrackRecordOutcome;
|
|
41
|
+
(function (RemediationTrackRecordOutcome) {
|
|
42
|
+
// The fix it was part of was verified fixed.
|
|
43
|
+
RemediationTrackRecordOutcome["Worked"] = "Worked";
|
|
44
|
+
// Its verification failed: the monitors did not recover in time.
|
|
45
|
+
RemediationTrackRecordOutcome["DidNotWork"] = "DidNotWork";
|
|
46
|
+
})(RemediationTrackRecordOutcome || (exports.RemediationTrackRecordOutcome = RemediationTrackRecordOutcome = {}));
|
|
47
|
+
// How a record reads at a glance: what a dot's colour says.
|
|
48
|
+
var RemediationTrackRecordTone;
|
|
49
|
+
(function (RemediationTrackRecordTone) {
|
|
50
|
+
// Every run worked.
|
|
51
|
+
RemediationTrackRecordTone["Worked"] = "Worked";
|
|
52
|
+
// Some did, some did not.
|
|
53
|
+
RemediationTrackRecordTone["Mixed"] = "Mixed";
|
|
54
|
+
// None did.
|
|
55
|
+
RemediationTrackRecordTone["DidNotWork"] = "DidNotWork";
|
|
56
|
+
})(RemediationTrackRecordTone || (exports.RemediationTrackRecordTone = RemediationTrackRecordTone = {}));
|
|
57
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
58
|
+
// An incident's or alert's number as a project shows it: a prefix and digits.
|
|
59
|
+
const SUBJECT_NUMBER_PATTERN = /^[A-Za-z0-9_-]{0,20}#?[0-9]{1,12}$/;
|
|
60
|
+
function readCount(value) {
|
|
61
|
+
return typeof value === "number" &&
|
|
62
|
+
Number.isInteger(value) &&
|
|
63
|
+
value >= 0 &&
|
|
64
|
+
value <= MAX_TRACK_RECORD_COUNT
|
|
65
|
+
? value
|
|
66
|
+
: null;
|
|
67
|
+
}
|
|
68
|
+
function readRun(value) {
|
|
69
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const run = value;
|
|
73
|
+
const subjectKind = run["subjectKind"];
|
|
74
|
+
const subjectId = run["subjectId"];
|
|
75
|
+
const ranAt = run["ranAt"];
|
|
76
|
+
const outcome = run["outcome"];
|
|
77
|
+
const subjectNumber = run["subjectNumber"];
|
|
78
|
+
if ((subjectKind !== "incident" && subjectKind !== "alert") ||
|
|
79
|
+
typeof subjectId !== "string" ||
|
|
80
|
+
!UUID_PATTERN.test(subjectId) ||
|
|
81
|
+
typeof ranAt !== "string" ||
|
|
82
|
+
!Number.isFinite(Date.parse(ranAt)) ||
|
|
83
|
+
(outcome !== RemediationTrackRecordOutcome.Worked &&
|
|
84
|
+
outcome !== RemediationTrackRecordOutcome.DidNotWork)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return Object.assign(Object.assign({ subjectKind, subjectId: subjectId.toLowerCase() }, (typeof subjectNumber === "string" &&
|
|
88
|
+
SUBJECT_NUMBER_PATTERN.test(subjectNumber)
|
|
89
|
+
? { subjectNumber }
|
|
90
|
+
: {})), { ranAt,
|
|
91
|
+
outcome });
|
|
92
|
+
}
|
|
93
|
+
/*
|
|
94
|
+
* A stored record, when well-formed: two counts and at most three runs, the
|
|
95
|
+
* runs no more than the counts. Undefined for anything else, and for a
|
|
96
|
+
* record of nothing (the change never ran before).
|
|
97
|
+
*/
|
|
98
|
+
function parseRemediationTrackRecord(value) {
|
|
99
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const record = value;
|
|
103
|
+
const workedCount = readCount(record["workedCount"]);
|
|
104
|
+
const didNotWorkCount = readCount(record["didNotWorkCount"]);
|
|
105
|
+
if (workedCount === null ||
|
|
106
|
+
didNotWorkCount === null ||
|
|
107
|
+
workedCount + didNotWorkCount === 0) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const rawRuns = record["runs"];
|
|
111
|
+
const runs = [];
|
|
112
|
+
if (Array.isArray(rawRuns)) {
|
|
113
|
+
for (const rawRun of rawRuns.slice(0, exports.MAX_TRACK_RECORD_RUNS)) {
|
|
114
|
+
const run = readRun(rawRun);
|
|
115
|
+
if (run) {
|
|
116
|
+
runs.push(run);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const worked = runs.filter((run) => {
|
|
121
|
+
return run.outcome === RemediationTrackRecordOutcome.Worked;
|
|
122
|
+
}).length;
|
|
123
|
+
// A record that names more runs of an outcome than it counts is not one.
|
|
124
|
+
if (worked > workedCount || runs.length - worked > didNotWorkCount) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
return { workedCount, didNotWorkCount, runs };
|
|
128
|
+
}
|
|
129
|
+
function getRemediationTrackRecordTone(record) {
|
|
130
|
+
if (record.didNotWorkCount === 0) {
|
|
131
|
+
return RemediationTrackRecordTone.Worked;
|
|
132
|
+
}
|
|
133
|
+
if (record.workedCount === 0) {
|
|
134
|
+
return RemediationTrackRecordTone.DidNotWork;
|
|
135
|
+
}
|
|
136
|
+
return RemediationTrackRecordTone.Mixed;
|
|
137
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import commonJsModule from "./RemediationTrackRecord.js";
|
|
2
|
+
export const MAX_TRACK_RECORD_RUNS = commonJsModule.MAX_TRACK_RECORD_RUNS;
|
|
3
|
+
export const REMEDIATION_TRACK_RECORD_LOOKBACK_DAYS = commonJsModule.REMEDIATION_TRACK_RECORD_LOOKBACK_DAYS;
|
|
4
|
+
export const REMEDIATION_TRACK_RECORD_MAX_FIXES_READ = commonJsModule.REMEDIATION_TRACK_RECORD_MAX_FIXES_READ;
|
|
5
|
+
export const RemediationTrackRecordOutcome = commonJsModule.RemediationTrackRecordOutcome;
|
|
6
|
+
export const RemediationTrackRecordTone = commonJsModule.RemediationTrackRecordTone;
|
|
7
|
+
export const getRemediationTrackRecordTone = commonJsModule.getRemediationTrackRecordTone;
|
|
8
|
+
export const parseRemediationTrackRecord = commonJsModule.parseRemediationTrackRecord;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluralTemplate, Translator } from "../Translator.mjs";
|
|
2
|
+
import { RemediationTrackRecord, RemediationTrackRecordRun } from "./RemediationTrackRecord.mjs";
|
|
3
|
+
export declare const TRACK_RECORD_WORKED: PluralTemplate;
|
|
4
|
+
export declare const TRACK_RECORD_WORKED_BOTH: string;
|
|
5
|
+
export declare const TRACK_RECORD_DID_NOT_WORK: PluralTemplate;
|
|
6
|
+
export declare const TRACK_RECORD_DID_NOT_WORK_EITHER: string;
|
|
7
|
+
export declare const TRACK_RECORD_MIXED: PluralTemplate;
|
|
8
|
+
export declare function describeRemediationTrackRecord(record: RemediationTrackRecord, translator?: Translator): string;
|
|
9
|
+
export declare function describeRemediationTrackRecordLine(record: RemediationTrackRecord): string;
|
|
10
|
+
export declare function describeTrackRecordRunSubject(run: RemediationTrackRecordRun): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluralTemplate, Translator } from "../Translator";
|
|
2
|
+
import { RemediationTrackRecord, RemediationTrackRecordRun } from "./RemediationTrackRecord";
|
|
3
|
+
export declare const TRACK_RECORD_WORKED: PluralTemplate;
|
|
4
|
+
export declare const TRACK_RECORD_WORKED_BOTH: string;
|
|
5
|
+
export declare const TRACK_RECORD_DID_NOT_WORK: PluralTemplate;
|
|
6
|
+
export declare const TRACK_RECORD_DID_NOT_WORK_EITHER: string;
|
|
7
|
+
export declare const TRACK_RECORD_MIXED: PluralTemplate;
|
|
8
|
+
export declare function describeRemediationTrackRecord(record: RemediationTrackRecord, translator?: Translator): string;
|
|
9
|
+
export declare function describeRemediationTrackRecordLine(record: RemediationTrackRecord): string;
|
|
10
|
+
export declare function describeTrackRecordRunSubject(run: RemediationTrackRecordRun): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRACK_RECORD_MIXED = exports.TRACK_RECORD_DID_NOT_WORK_EITHER = exports.TRACK_RECORD_DID_NOT_WORK = exports.TRACK_RECORD_WORKED_BOTH = exports.TRACK_RECORD_WORKED = void 0;
|
|
4
|
+
exports.describeRemediationTrackRecord = describeRemediationTrackRecord;
|
|
5
|
+
exports.describeRemediationTrackRecordLine = describeRemediationTrackRecordLine;
|
|
6
|
+
exports.describeTrackRecordRunSubject = describeTrackRecordRunSubject;
|
|
7
|
+
const Translator_1 = require("../Translator");
|
|
8
|
+
const RemediationTrackRecord_1 = require("./RemediationTrackRecord");
|
|
9
|
+
/*
|
|
10
|
+
* HOW A CHANGE'S TRACK RECORD READS (Types/AutoRemediation/
|
|
11
|
+
* RemediationTrackRecord): one short sentence per tone, about the runs of
|
|
12
|
+
* the same change on the same cluster or resource before - never a promise.
|
|
13
|
+
* The Remediation step reads them in the reader's language; the Slack and
|
|
14
|
+
* Microsoft Teams messages and OneUptime AI's own context read them in
|
|
15
|
+
* English.
|
|
16
|
+
*/
|
|
17
|
+
/*
|
|
18
|
+
* What a record says, in one short sentence, for each tone. Every one is
|
|
19
|
+
* about the past runs on the same cluster or resource, never a promise.
|
|
20
|
+
*/
|
|
21
|
+
exports.TRACK_RECORD_WORKED = {
|
|
22
|
+
one: "Worked the one time it ran here before",
|
|
23
|
+
other: "Worked all {{count}} times it ran here before",
|
|
24
|
+
};
|
|
25
|
+
/*
|
|
26
|
+
* Exactly two runs are "both" and "either", as a person says it - never
|
|
27
|
+
* "all 2 times". A language's plural forms cannot say it (English has only
|
|
28
|
+
* "one" and "other"), so it is a sentence of its own.
|
|
29
|
+
*/
|
|
30
|
+
exports.TRACK_RECORD_WORKED_BOTH = (0, Translator_1.translationKey)("Worked both times it ran here before");
|
|
31
|
+
exports.TRACK_RECORD_DID_NOT_WORK = {
|
|
32
|
+
one: "Didn't work the one time it ran here before",
|
|
33
|
+
other: "Didn't work any of the {{count}} times it ran here before",
|
|
34
|
+
};
|
|
35
|
+
exports.TRACK_RECORD_DID_NOT_WORK_EITHER = (0, Translator_1.translationKey)("Didn't work either time it ran here before");
|
|
36
|
+
exports.TRACK_RECORD_MIXED = {
|
|
37
|
+
one: "Worked {{worked}} of the {{count}} times it ran here before",
|
|
38
|
+
other: "Worked {{worked}} of the {{count}} times it ran here before",
|
|
39
|
+
};
|
|
40
|
+
/*
|
|
41
|
+
* The record's sentence, in the translator's language (English when none
|
|
42
|
+
* is given, as the server, the chat messages and OneUptime AI read it).
|
|
43
|
+
*/
|
|
44
|
+
function describeRemediationTrackRecord(record, translator = (0, Translator_1.createTranslator)(undefined, Translator_1.DEFAULT_LANGUAGE)) {
|
|
45
|
+
const total = record.workedCount + record.didNotWorkCount;
|
|
46
|
+
switch ((0, RemediationTrackRecord_1.getRemediationTrackRecordTone)(record)) {
|
|
47
|
+
case RemediationTrackRecord_1.RemediationTrackRecordTone.Worked:
|
|
48
|
+
return total === 2
|
|
49
|
+
? translator.translateText(exports.TRACK_RECORD_WORKED_BOTH) ||
|
|
50
|
+
exports.TRACK_RECORD_WORKED_BOTH
|
|
51
|
+
: translator.translatePlural(exports.TRACK_RECORD_WORKED, total);
|
|
52
|
+
case RemediationTrackRecord_1.RemediationTrackRecordTone.DidNotWork:
|
|
53
|
+
return total === 2
|
|
54
|
+
? translator.translateText(exports.TRACK_RECORD_DID_NOT_WORK_EITHER) ||
|
|
55
|
+
exports.TRACK_RECORD_DID_NOT_WORK_EITHER
|
|
56
|
+
: translator.translatePlural(exports.TRACK_RECORD_DID_NOT_WORK, total);
|
|
57
|
+
default:
|
|
58
|
+
return translator.translatePlural(exports.TRACK_RECORD_MIXED, total, {
|
|
59
|
+
worked: translator.formatNumber(record.workedCount),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/*
|
|
64
|
+
* A record in one English line, with the incidents and alerts it names:
|
|
65
|
+
* "Worked both times it ran here before (INC-41, INC-57)." - for a chat
|
|
66
|
+
* message.
|
|
67
|
+
*/
|
|
68
|
+
function describeRemediationTrackRecordLine(record) {
|
|
69
|
+
const named = record.runs
|
|
70
|
+
.map((run) => {
|
|
71
|
+
return run.subjectNumber || "";
|
|
72
|
+
})
|
|
73
|
+
.filter((name) => {
|
|
74
|
+
return Boolean(name);
|
|
75
|
+
});
|
|
76
|
+
return named.length > 0
|
|
77
|
+
? `${describeRemediationTrackRecord(record)} (${named.join(", ")}).`
|
|
78
|
+
: `${describeRemediationTrackRecord(record)}.`;
|
|
79
|
+
}
|
|
80
|
+
// How a run's subject is named: its number, or what it is when it has none.
|
|
81
|
+
function describeTrackRecordRunSubject(run) {
|
|
82
|
+
if (run.subjectNumber) {
|
|
83
|
+
return run.subjectNumber;
|
|
84
|
+
}
|
|
85
|
+
return run.subjectKind === "incident" ? "an incident" : "an alert";
|
|
86
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import commonJsModule from "./RemediationTrackRecordWords.js";
|
|
2
|
+
export const TRACK_RECORD_DID_NOT_WORK = commonJsModule.TRACK_RECORD_DID_NOT_WORK;
|
|
3
|
+
export const TRACK_RECORD_DID_NOT_WORK_EITHER = commonJsModule.TRACK_RECORD_DID_NOT_WORK_EITHER;
|
|
4
|
+
export const TRACK_RECORD_MIXED = commonJsModule.TRACK_RECORD_MIXED;
|
|
5
|
+
export const TRACK_RECORD_WORKED = commonJsModule.TRACK_RECORD_WORKED;
|
|
6
|
+
export const TRACK_RECORD_WORKED_BOTH = commonJsModule.TRACK_RECORD_WORKED_BOTH;
|
|
7
|
+
export const describeRemediationTrackRecord = commonJsModule.describeRemediationTrackRecord;
|
|
8
|
+
export const describeRemediationTrackRecordLine = commonJsModule.describeRemediationTrackRecordLine;
|
|
9
|
+
export const describeTrackRecordRunSubject = commonJsModule.describeTrackRecordRunSubject;
|