@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getRemediationChangeKey = getRemediationChangeKey;
|
|
7
|
+
const AiRemediationCommandPlan_1 = require("../../Types/AutoRemediation/AiRemediationCommandPlan");
|
|
8
|
+
const RunbookStepType_1 = __importDefault(require("../../Types/Runbook/RunbookStepType"));
|
|
9
|
+
const KubectlPolicy_1 = __importDefault(require("./KubectlPolicy"));
|
|
10
|
+
const CloudOperationCatalog_1 = require("./Resource/CloudOperationCatalog");
|
|
11
|
+
const ResourceCommandPolicyCore_1 = require("./Resource/ResourceCommandPolicyCore");
|
|
12
|
+
/*
|
|
13
|
+
* WHICH CHANGE A COMMAND MAKES, so the same fix can be told apart from
|
|
14
|
+
* another across incidents (Types/AutoRemediation/RemediationTrackRecord).
|
|
15
|
+
*
|
|
16
|
+
* Two commands make the same change when they do the same thing to the same
|
|
17
|
+
* object of the same cluster or resource - whatever their numbers:
|
|
18
|
+
*
|
|
19
|
+
* - kubectl: the verb (and its subcommand) on the one object it names, in
|
|
20
|
+
* its namespace, on its cluster. `kubectl scale deployment/web
|
|
21
|
+
* --replicas=6 -n shop` and `--replicas=8` are one change; a rollout
|
|
22
|
+
* restart of the same deployment is another. A command that names no
|
|
23
|
+
* single object (a selector, --all) is compared as written.
|
|
24
|
+
* - a cloud change: the catalog's operation on the one resource it names,
|
|
25
|
+
* in its account (`cloud scale-out <arn> --count 8` and `--count 4` are
|
|
26
|
+
* one change), read by the catalog's own grammar.
|
|
27
|
+
* - any other command (Docker, Podman, Swarm, Proxmox, VMware, Ceph, a
|
|
28
|
+
* database or a host): the command as written, word for word, on its
|
|
29
|
+
* resource - their words carry their meaning (`govc vm.power -on` and
|
|
30
|
+
* `-off` are two changes).
|
|
31
|
+
*
|
|
32
|
+
* Null for a command that cannot be read: it is compared with nothing.
|
|
33
|
+
* Pure, and never throws.
|
|
34
|
+
*/
|
|
35
|
+
// A key never grows past this, whatever a command holds.
|
|
36
|
+
const MAX_KEY_LENGTH = 1200;
|
|
37
|
+
function capped(key) {
|
|
38
|
+
return key.length > MAX_KEY_LENGTH ? key.slice(0, MAX_KEY_LENGTH) : key;
|
|
39
|
+
}
|
|
40
|
+
function lower(value) {
|
|
41
|
+
return (value || "").trim().toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
// The words of a command, single-spaced, as its tokenizer reads them.
|
|
44
|
+
function wordsOf(argv) {
|
|
45
|
+
if (!argv || argv.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return argv.join(" ");
|
|
49
|
+
}
|
|
50
|
+
function getKubectlChangeKey(command) {
|
|
51
|
+
const cluster = lower(command.kubernetesClusterId);
|
|
52
|
+
if (!cluster) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
// The argv without "kubectl", which the model may or may not write.
|
|
56
|
+
const tokens = KubectlPolicy_1.default.tokenize(command.command);
|
|
57
|
+
if (!tokens.args || tokens.args.length === 0) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const args = tokens.args;
|
|
61
|
+
const named = KubectlPolicy_1.default.getNamedObject(args);
|
|
62
|
+
if (!named) {
|
|
63
|
+
const words = wordsOf(args);
|
|
64
|
+
return words ? capped(`kubectl|${cluster}|${words}`) : null;
|
|
65
|
+
}
|
|
66
|
+
let namespace = "";
|
|
67
|
+
try {
|
|
68
|
+
const policy = KubectlPolicy_1.default.evaluateArgs(args);
|
|
69
|
+
namespace = policy.namespace || "";
|
|
70
|
+
}
|
|
71
|
+
catch (_a) {
|
|
72
|
+
namespace = "";
|
|
73
|
+
}
|
|
74
|
+
const verb = named.subcommand
|
|
75
|
+
? `${named.verb} ${named.subcommand}`
|
|
76
|
+
: named.verb;
|
|
77
|
+
return capped(`kubectl|${cluster}|${verb}|${named.kind}/${named.name}|${namespace}`);
|
|
78
|
+
}
|
|
79
|
+
function getResourceChangeKey(command) {
|
|
80
|
+
const resourceId = lower(command.resourceId);
|
|
81
|
+
if (!command.resourceType || !resourceId) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const tokens = (0, ResourceCommandPolicyCore_1.tokenizeResourceCommand)(command.command);
|
|
85
|
+
if (!tokens.argv || tokens.argv.length === 0) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const provider = (0, CloudOperationCatalog_1.getCloudCatalogProvider)(command.resourceType);
|
|
89
|
+
if (provider) {
|
|
90
|
+
const parse = (0, CloudOperationCatalog_1.parseCloudCommand)(provider, tokens.argv);
|
|
91
|
+
if (!parse.ok || !parse.command.resource) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/*
|
|
95
|
+
* Azure ids compare without case (as the inventory compares them); the
|
|
96
|
+
* other clouds' ids are exact.
|
|
97
|
+
*/
|
|
98
|
+
const target = provider === "azure"
|
|
99
|
+
? parse.command.resource.id.toLowerCase()
|
|
100
|
+
: parse.command.resource.id;
|
|
101
|
+
return capped(`cloud|${command.resourceType}|${resourceId}|${parse.command.operation.name}|${target}`);
|
|
102
|
+
}
|
|
103
|
+
const words = wordsOf(tokens.argv);
|
|
104
|
+
return words
|
|
105
|
+
? capped(`resource|${command.resourceType}|${resourceId}|${words}`)
|
|
106
|
+
: null;
|
|
107
|
+
}
|
|
108
|
+
function getRemediationChangeKey(command) {
|
|
109
|
+
try {
|
|
110
|
+
if (!command ||
|
|
111
|
+
typeof command.command !== "string" ||
|
|
112
|
+
!AiRemediationCommandPlan_1.STORED_AI_COMMAND_STEP_TYPES.includes(command.stepType)) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
if (command.stepType === RunbookStepType_1.default.Kubectl) {
|
|
116
|
+
return getKubectlChangeKey(command);
|
|
117
|
+
}
|
|
118
|
+
if (command.stepType === RunbookStepType_1.default.ResourceCommand) {
|
|
119
|
+
return getResourceChangeKey(command);
|
|
120
|
+
}
|
|
121
|
+
// A Bash step on a Runner: the command as written, on that Runner.
|
|
122
|
+
const runner = lower(command.runnerId);
|
|
123
|
+
const tokens = (0, ResourceCommandPolicyCore_1.tokenizeResourceCommand)(command.command);
|
|
124
|
+
const words = wordsOf(tokens.argv);
|
|
125
|
+
return runner && words
|
|
126
|
+
? capped(`${lower(command.stepType)}|${runner}|${words}`)
|
|
127
|
+
: null;
|
|
128
|
+
}
|
|
129
|
+
catch (_a) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
package/package.json
CHANGED