@oneuptime/common 10.0.65 → 10.0.66
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/DatabaseModels/DockerHostOwnerTeam.ts +464 -0
- package/Models/DatabaseModels/DockerHostOwnerUser.ts +463 -0
- package/Models/DatabaseModels/Index.ts +24 -0
- package/Models/DatabaseModels/KubernetesClusterOwnerTeam.ts +464 -0
- package/Models/DatabaseModels/KubernetesClusterOwnerUser.ts +463 -0
- package/Models/DatabaseModels/KubernetesResource.ts +548 -0
- package/Models/DatabaseModels/MetricPipelineRule.ts +804 -0
- package/Models/DatabaseModels/MetricRecordingRule.ts +470 -0
- package/Models/DatabaseModels/Monitor.ts +2 -0
- package/Models/DatabaseModels/Project.ts +53 -0
- package/Models/DatabaseModels/Service.ts +79 -0
- package/Models/DatabaseModels/TraceDropFilter.ts +508 -0
- package/Models/DatabaseModels/TracePipeline.ts +436 -0
- package/Models/DatabaseModels/TracePipelineProcessor.ts +454 -0
- package/Models/DatabaseModels/TraceRecordingRule.ts +470 -0
- package/Models/DatabaseModels/TraceScrubRule.ts +546 -0
- package/Server/API/KubernetesResourceAPI.ts +129 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776504277320-MigrationName.ts +399 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776505976155-AddTracePipelineTables.ts +205 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776509413763-MigrationName.ts +335 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776541018853-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776544084793-MigrationName.ts +53 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -1
- package/Server/Services/DockerHostOwnerTeamService.ts +10 -0
- package/Server/Services/DockerHostOwnerUserService.ts +10 -0
- package/Server/Services/KubernetesClusterOwnerTeamService.ts +10 -0
- package/Server/Services/KubernetesClusterOwnerUserService.ts +10 -0
- package/Server/Services/KubernetesResourceService.ts +351 -0
- package/Server/Services/MetricPipelineRuleService.ts +10 -0
- package/Server/Services/MetricRecordingRuleService.ts +10 -0
- package/Server/Services/TraceDropFilterService.ts +10 -0
- package/Server/Services/TracePipelineProcessorService.ts +10 -0
- package/Server/Services/TracePipelineService.ts +10 -0
- package/Server/Services/TraceRecordingRuleService.ts +10 -0
- package/Server/Services/TraceScrubRuleService.ts +10 -0
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +71 -9
- package/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.ts +483 -75
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +379 -6
- package/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.ts +502 -0
- package/Tests/Utils/MetricUnitUtil.test.ts +216 -0
- package/Tests/Utils/Metrics/MetricFormulaEvaluator.test.ts +269 -0
- package/Tests/Utils/Metrics/MetricResultUnitConverter.test.ts +231 -0
- package/Tests/Utils/RecordingRuleExpression.test.ts +177 -0
- package/Types/Kubernetes/KubernetesInventoryExtractor.ts +327 -0
- package/Types/Kubernetes/KubernetesObjectParser.ts +1949 -0
- package/Types/Metrics/MetricDownsamplingRetentionDays.ts +49 -0
- package/Types/Metrics/MetricFormulaConfigData.ts +4 -0
- package/Types/Metrics/MetricPipelineRuleFilterCondition.ts +136 -0
- package/Types/Metrics/MetricPipelineRuleType.ts +27 -0
- package/Types/Metrics/RecordingRuleDefinition.ts +180 -0
- package/Types/Monitor/CriteriaFilter.ts +43 -0
- package/Types/Monitor/MetricMonitor/MetricCriteriaContext.ts +70 -0
- package/Types/Permission.ts +520 -0
- package/Types/Trace/TraceAggregationType.ts +17 -0
- package/Types/Trace/TraceDropFilterAction.ts +6 -0
- package/Types/Trace/TracePipelineProcessorType.ts +56 -0
- package/Types/Trace/TraceRecordingRuleDefinition.ts +218 -0
- package/Types/Trace/TraceScrubAction.ts +7 -0
- package/Types/Trace/TraceScrubField.ts +8 -0
- package/Types/Trace/TraceScrubPatternType.ts +10 -0
- package/UI/Components/CardSelect/CardSelect.tsx +9 -1
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +6 -10
- package/UI/Components/Forms/Fields/FormField.tsx +1 -0
- package/UI/Components/Forms/Types/Field.ts +1 -0
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +57 -0
- package/UI/Components/Page/Page.tsx +6 -0
- package/Utils/MetricUnitUtil.ts +289 -0
- package/Utils/Metrics/MetricFormulaEvaluator.ts +610 -0
- package/Utils/Metrics/MetricResultUnitConverter.ts +91 -0
- package/Utils/Metrics/RecordingRuleExpression.ts +359 -0
- package/Utils/ValueFormatter.ts +137 -13
- package/build/dist/Models/DatabaseModels/DockerHostOwnerTeam.js +480 -0
- package/build/dist/Models/DatabaseModels/DockerHostOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/DockerHostOwnerUser.js +479 -0
- package/build/dist/Models/DatabaseModels/DockerHostOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +24 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/KubernetesClusterOwnerTeam.js +480 -0
- package/build/dist/Models/DatabaseModels/KubernetesClusterOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/KubernetesClusterOwnerUser.js +479 -0
- package/build/dist/Models/DatabaseModels/KubernetesClusterOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/KubernetesResource.js +590 -0
- package/build/dist/Models/DatabaseModels/KubernetesResource.js.map +1 -0
- package/build/dist/Models/DatabaseModels/MetricPipelineRule.js +836 -0
- package/build/dist/Models/DatabaseModels/MetricPipelineRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/MetricRecordingRule.js +497 -0
- package/build/dist/Models/DatabaseModels/MetricRecordingRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Monitor.js +2 -0
- package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +53 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Service.js +79 -0
- package/build/dist/Models/DatabaseModels/Service.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TraceDropFilter.js +536 -0
- package/build/dist/Models/DatabaseModels/TraceDropFilter.js.map +1 -0
- package/build/dist/Models/DatabaseModels/TracePipeline.js +462 -0
- package/build/dist/Models/DatabaseModels/TracePipeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/TracePipelineProcessor.js +476 -0
- package/build/dist/Models/DatabaseModels/TracePipelineProcessor.js.map +1 -0
- package/build/dist/Models/DatabaseModels/TraceRecordingRule.js +497 -0
- package/build/dist/Models/DatabaseModels/TraceRecordingRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/TraceScrubRule.js +575 -0
- package/build/dist/Models/DatabaseModels/TraceScrubRule.js.map +1 -0
- package/build/dist/Server/API/KubernetesResourceAPI.js +98 -0
- package/build/dist/Server/API/KubernetesResourceAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776504277320-MigrationName.js +144 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776504277320-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776505976155-AddTracePipelineTables.js +82 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776505976155-AddTracePipelineTables.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776509413763-MigrationName.js +118 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776509413763-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776541018853-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776541018853-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776544084793-MigrationName.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776544084793-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +10 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/DockerHostOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/DockerHostOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/DockerHostOwnerUserService.js +9 -0
- package/build/dist/Server/Services/DockerHostOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/KubernetesClusterOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/KubernetesClusterOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/KubernetesClusterOwnerUserService.js +9 -0
- package/build/dist/Server/Services/KubernetesClusterOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/KubernetesResourceService.js +237 -0
- package/build/dist/Server/Services/KubernetesResourceService.js.map +1 -0
- package/build/dist/Server/Services/MetricPipelineRuleService.js +9 -0
- package/build/dist/Server/Services/MetricPipelineRuleService.js.map +1 -0
- package/build/dist/Server/Services/MetricRecordingRuleService.js +9 -0
- package/build/dist/Server/Services/MetricRecordingRuleService.js.map +1 -0
- package/build/dist/Server/Services/TraceDropFilterService.js +9 -0
- package/build/dist/Server/Services/TraceDropFilterService.js.map +1 -0
- package/build/dist/Server/Services/TracePipelineProcessorService.js +9 -0
- package/build/dist/Server/Services/TracePipelineProcessorService.js.map +1 -0
- package/build/dist/Server/Services/TracePipelineService.js +9 -0
- package/build/dist/Server/Services/TracePipelineService.js.map +1 -0
- package/build/dist/Server/Services/TraceRecordingRuleService.js +9 -0
- package/build/dist/Server/Services/TraceRecordingRuleService.js.map +1 -0
- package/build/dist/Server/Services/TraceScrubRuleService.js +9 -0
- package/build/dist/Server/Services/TraceScrubRuleService.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +56 -9
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js +335 -53
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +277 -5
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.js +407 -0
- package/build/dist/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.js.map +1 -0
- package/build/dist/Tests/Utils/MetricUnitUtil.test.js +159 -0
- package/build/dist/Tests/Utils/MetricUnitUtil.test.js.map +1 -0
- package/build/dist/Tests/Utils/Metrics/MetricFormulaEvaluator.test.js +224 -0
- package/build/dist/Tests/Utils/Metrics/MetricFormulaEvaluator.test.js.map +1 -0
- package/build/dist/Tests/Utils/Metrics/MetricResultUnitConverter.test.js +180 -0
- package/build/dist/Tests/Utils/Metrics/MetricResultUnitConverter.test.js.map +1 -0
- package/build/dist/Tests/Utils/RecordingRuleExpression.test.js +142 -0
- package/build/dist/Tests/Utils/RecordingRuleExpression.test.js.map +1 -0
- package/build/dist/Types/Kubernetes/KubernetesInventoryExtractor.js +200 -0
- package/build/dist/Types/Kubernetes/KubernetesInventoryExtractor.js.map +1 -0
- package/build/dist/Types/Kubernetes/KubernetesObjectParser.js +1205 -0
- package/build/dist/Types/Kubernetes/KubernetesObjectParser.js.map +1 -0
- package/build/dist/Types/Metrics/MetricDownsamplingRetentionDays.js +32 -0
- package/build/dist/Types/Metrics/MetricDownsamplingRetentionDays.js.map +1 -0
- package/build/dist/Types/Metrics/MetricPipelineRuleFilterCondition.js +103 -0
- package/build/dist/Types/Metrics/MetricPipelineRuleFilterCondition.js.map +1 -0
- package/build/dist/Types/Metrics/MetricPipelineRuleType.js +27 -0
- package/build/dist/Types/Metrics/MetricPipelineRuleType.js.map +1 -0
- package/build/dist/Types/Metrics/RecordingRuleDefinition.js +110 -0
- package/build/dist/Types/Metrics/RecordingRuleDefinition.js.map +1 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js +22 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MetricMonitor/MetricCriteriaContext.js +2 -0
- package/build/dist/Types/Monitor/MetricMonitor/MetricCriteriaContext.js.map +1 -0
- package/build/dist/Types/Permission.js +454 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Trace/TraceAggregationType.js +18 -0
- package/build/dist/Types/Trace/TraceAggregationType.js.map +1 -0
- package/build/dist/Types/Trace/TraceDropFilterAction.js +7 -0
- package/build/dist/Types/Trace/TraceDropFilterAction.js.map +1 -0
- package/build/dist/Types/Trace/TracePipelineProcessorType.js +10 -0
- package/build/dist/Types/Trace/TracePipelineProcessorType.js.map +1 -0
- package/build/dist/Types/Trace/TraceRecordingRuleDefinition.js +145 -0
- package/build/dist/Types/Trace/TraceRecordingRuleDefinition.js.map +1 -0
- package/build/dist/Types/Trace/TraceScrubAction.js +8 -0
- package/build/dist/Types/Trace/TraceScrubAction.js.map +1 -0
- package/build/dist/Types/Trace/TraceScrubField.js +9 -0
- package/build/dist/Types/Trace/TraceScrubField.js.map +1 -0
- package/build/dist/Types/Trace/TraceScrubPatternType.js +11 -0
- package/build/dist/Types/Trace/TraceScrubPatternType.js.map +1 -0
- package/build/dist/UI/Components/CardSelect/CardSelect.js +3 -1
- package/build/dist/UI/Components/CardSelect/CardSelect.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +6 -9
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +30 -0
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Page/Page.js +1 -0
- package/build/dist/UI/Components/Page/Page.js.map +1 -1
- package/build/dist/Utils/MetricUnitUtil.js +232 -0
- package/build/dist/Utils/MetricUnitUtil.js.map +1 -0
- package/build/dist/Utils/Metrics/MetricFormulaEvaluator.js +453 -0
- package/build/dist/Utils/Metrics/MetricFormulaEvaluator.js.map +1 -0
- package/build/dist/Utils/Metrics/MetricResultUnitConverter.js +61 -0
- package/build/dist/Utils/Metrics/MetricResultUnitConverter.js.map +1 -0
- package/build/dist/Utils/Metrics/RecordingRuleExpression.js +298 -0
- package/build/dist/Utils/Metrics/RecordingRuleExpression.js.map +1 -0
- package/build/dist/Utils/ValueFormatter.js +123 -13
- package/build/dist/Utils/ValueFormatter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1205 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ============================================================
|
|
3
|
+
* OTLP kvlistValue parsing helpers
|
|
4
|
+
* ============================================================
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Extract a value from an OTLP kvlistValue by key.
|
|
8
|
+
* Returns the string/int value or nested kvlistValue as JSONObject.
|
|
9
|
+
*/
|
|
10
|
+
export function getKvValue(kvList, key) {
|
|
11
|
+
if (!kvList) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const values = kvList["values"];
|
|
15
|
+
if (!values) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
for (const entry of values) {
|
|
19
|
+
if (entry["key"] === key) {
|
|
20
|
+
const val = entry["value"];
|
|
21
|
+
if (!val) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
// Handle both camelCase (JSON encoding) and snake_case (protobuf via protobufjs)
|
|
25
|
+
if (val["stringValue"] !== undefined) {
|
|
26
|
+
return val["stringValue"];
|
|
27
|
+
}
|
|
28
|
+
if (val["string_value"] !== undefined) {
|
|
29
|
+
return val["string_value"];
|
|
30
|
+
}
|
|
31
|
+
if (val["intValue"] !== undefined) {
|
|
32
|
+
return String(val["intValue"]);
|
|
33
|
+
}
|
|
34
|
+
if (val["int_value"] !== undefined) {
|
|
35
|
+
return String(val["int_value"]);
|
|
36
|
+
}
|
|
37
|
+
if (val["boolValue"] !== undefined) {
|
|
38
|
+
return String(val["boolValue"]);
|
|
39
|
+
}
|
|
40
|
+
if (val["bool_value"] !== undefined) {
|
|
41
|
+
return String(val["bool_value"]);
|
|
42
|
+
}
|
|
43
|
+
if (val["kvlistValue"]) {
|
|
44
|
+
return val["kvlistValue"];
|
|
45
|
+
}
|
|
46
|
+
if (val["kvlist_value"]) {
|
|
47
|
+
return val["kvlist_value"];
|
|
48
|
+
}
|
|
49
|
+
if (val["arrayValue"]) {
|
|
50
|
+
return val["arrayValue"];
|
|
51
|
+
}
|
|
52
|
+
if (val["array_value"]) {
|
|
53
|
+
return val["array_value"];
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Extract a string value from an OTLP kvlistValue by key.
|
|
62
|
+
*/
|
|
63
|
+
export function getKvStringValue(kvList, key) {
|
|
64
|
+
const val = getKvValue(kvList, key);
|
|
65
|
+
if (typeof val === "string") {
|
|
66
|
+
return val;
|
|
67
|
+
}
|
|
68
|
+
return "";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extract a nested kvlist value (parent → child).
|
|
72
|
+
*/
|
|
73
|
+
export function getNestedKvValue(kvList, parentKey, childKey) {
|
|
74
|
+
const parent = getKvValue(kvList, parentKey);
|
|
75
|
+
if (!parent || typeof parent === "string") {
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
return getKvStringValue(parent, childKey);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Convert a kvlistValue to a flat Record<string, string> (for labels, annotations, env).
|
|
82
|
+
*/
|
|
83
|
+
export function getKvListAsRecord(kvList) {
|
|
84
|
+
const result = {};
|
|
85
|
+
if (!kvList) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
const values = kvList["values"];
|
|
89
|
+
if (!values) {
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
for (const entry of values) {
|
|
93
|
+
const key = entry["key"] || "";
|
|
94
|
+
const val = entry["value"];
|
|
95
|
+
if (key && val) {
|
|
96
|
+
if (val["stringValue"] !== undefined) {
|
|
97
|
+
result[key] = val["stringValue"];
|
|
98
|
+
}
|
|
99
|
+
else if (val["string_value"] !== undefined) {
|
|
100
|
+
result[key] = val["string_value"];
|
|
101
|
+
}
|
|
102
|
+
else if (val["intValue"] !== undefined) {
|
|
103
|
+
result[key] = String(val["intValue"]);
|
|
104
|
+
}
|
|
105
|
+
else if (val["int_value"] !== undefined) {
|
|
106
|
+
result[key] = String(val["int_value"]);
|
|
107
|
+
}
|
|
108
|
+
else if (val["boolValue"] !== undefined) {
|
|
109
|
+
result[key] = String(val["boolValue"]);
|
|
110
|
+
}
|
|
111
|
+
else if (val["bool_value"] !== undefined) {
|
|
112
|
+
result[key] = String(val["bool_value"]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Convert an OTLP arrayValue to an array of JSONObjects (kvlistValues).
|
|
120
|
+
*/
|
|
121
|
+
export function getArrayValues(arrayValue) {
|
|
122
|
+
if (!arrayValue) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const values = arrayValue["values"];
|
|
126
|
+
if (!values) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
return values
|
|
130
|
+
.map((item) => {
|
|
131
|
+
if (item["kvlistValue"]) {
|
|
132
|
+
return item["kvlistValue"];
|
|
133
|
+
}
|
|
134
|
+
if (item["kvlist_value"]) {
|
|
135
|
+
return item["kvlist_value"];
|
|
136
|
+
}
|
|
137
|
+
if (item["stringValue"]) {
|
|
138
|
+
return item;
|
|
139
|
+
}
|
|
140
|
+
if (item["string_value"]) {
|
|
141
|
+
return item;
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
})
|
|
145
|
+
.filter(Boolean);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Recursively convert an OTLP value wrapper to a plain JavaScript value.
|
|
149
|
+
* Handles stringValue, intValue, boolValue, kvlistValue, and arrayValue.
|
|
150
|
+
*/
|
|
151
|
+
function convertOtlpValue(valueWrapper) {
|
|
152
|
+
// Handle both camelCase (JSON encoding) and snake_case (protobuf via protobufjs)
|
|
153
|
+
if (valueWrapper["stringValue"] !== undefined) {
|
|
154
|
+
return valueWrapper["stringValue"];
|
|
155
|
+
}
|
|
156
|
+
if (valueWrapper["string_value"] !== undefined) {
|
|
157
|
+
return valueWrapper["string_value"];
|
|
158
|
+
}
|
|
159
|
+
if (valueWrapper["intValue"] !== undefined) {
|
|
160
|
+
return Number(valueWrapper["intValue"]);
|
|
161
|
+
}
|
|
162
|
+
if (valueWrapper["int_value"] !== undefined) {
|
|
163
|
+
return Number(valueWrapper["int_value"]);
|
|
164
|
+
}
|
|
165
|
+
if (valueWrapper["boolValue"] !== undefined) {
|
|
166
|
+
return valueWrapper["boolValue"];
|
|
167
|
+
}
|
|
168
|
+
if (valueWrapper["bool_value"] !== undefined) {
|
|
169
|
+
return valueWrapper["bool_value"];
|
|
170
|
+
}
|
|
171
|
+
if (valueWrapper["doubleValue"] !== undefined) {
|
|
172
|
+
return Number(valueWrapper["doubleValue"]);
|
|
173
|
+
}
|
|
174
|
+
if (valueWrapper["double_value"] !== undefined) {
|
|
175
|
+
return Number(valueWrapper["double_value"]);
|
|
176
|
+
}
|
|
177
|
+
if (valueWrapper["kvlistValue"]) {
|
|
178
|
+
return kvListToPlainObject(valueWrapper["kvlistValue"]);
|
|
179
|
+
}
|
|
180
|
+
if (valueWrapper["kvlist_value"]) {
|
|
181
|
+
return kvListToPlainObject(valueWrapper["kvlist_value"]);
|
|
182
|
+
}
|
|
183
|
+
if (valueWrapper["arrayValue"]) {
|
|
184
|
+
return convertOtlpArray(valueWrapper["arrayValue"]);
|
|
185
|
+
}
|
|
186
|
+
if (valueWrapper["array_value"]) {
|
|
187
|
+
return convertOtlpArray(valueWrapper["array_value"]);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Convert an OTLP arrayValue to a plain JavaScript array.
|
|
193
|
+
*/
|
|
194
|
+
function convertOtlpArray(arrayValue) {
|
|
195
|
+
const values = arrayValue["values"];
|
|
196
|
+
if (!values) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
return values.map((item) => {
|
|
200
|
+
// Each item in arrayValue.values is a value wrapper
|
|
201
|
+
return convertOtlpValue(item);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Convert an OTLP kvlistValue (nested key-value structure) to a plain
|
|
206
|
+
* JavaScript object. This preserves the full original K8s manifest structure.
|
|
207
|
+
*/
|
|
208
|
+
export function kvListToPlainObject(kvList) {
|
|
209
|
+
const result = {};
|
|
210
|
+
if (!kvList) {
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
const values = kvList["values"];
|
|
214
|
+
if (!values) {
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
for (const entry of values) {
|
|
218
|
+
const key = entry["key"] || "";
|
|
219
|
+
const val = entry["value"];
|
|
220
|
+
if (key && val) {
|
|
221
|
+
result[key] = convertOtlpValue(val);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
/*
|
|
227
|
+
* ============================================================
|
|
228
|
+
* Parsers
|
|
229
|
+
* ============================================================
|
|
230
|
+
*/
|
|
231
|
+
function parseMetadata(kvList) {
|
|
232
|
+
const labelsKvList = getKvValue(kvList, "labels");
|
|
233
|
+
const annotationsKvList = getKvValue(kvList, "annotations");
|
|
234
|
+
const ownerRefsArrayValue = getKvValue(kvList, "ownerReferences");
|
|
235
|
+
const ownerReferences = [];
|
|
236
|
+
if (ownerRefsArrayValue && typeof ownerRefsArrayValue !== "string") {
|
|
237
|
+
const refs = getArrayValues(ownerRefsArrayValue);
|
|
238
|
+
for (const ref of refs) {
|
|
239
|
+
ownerReferences.push({
|
|
240
|
+
kind: getKvStringValue(ref, "kind"),
|
|
241
|
+
name: getKvStringValue(ref, "name"),
|
|
242
|
+
uid: getKvStringValue(ref, "uid"),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
name: getKvStringValue(kvList, "name"),
|
|
248
|
+
namespace: getKvStringValue(kvList, "namespace"),
|
|
249
|
+
uid: getKvStringValue(kvList, "uid"),
|
|
250
|
+
creationTimestamp: getKvStringValue(kvList, "creationTimestamp"),
|
|
251
|
+
labels: labelsKvList && typeof labelsKvList !== "string"
|
|
252
|
+
? getKvListAsRecord(labelsKvList)
|
|
253
|
+
: {},
|
|
254
|
+
annotations: annotationsKvList && typeof annotationsKvList !== "string"
|
|
255
|
+
? getKvListAsRecord(annotationsKvList)
|
|
256
|
+
: {},
|
|
257
|
+
ownerReferences,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function parseContainerEnv(envArrayValue) {
|
|
261
|
+
if (!envArrayValue || typeof envArrayValue === "string") {
|
|
262
|
+
return [];
|
|
263
|
+
}
|
|
264
|
+
const envItems = getArrayValues(envArrayValue);
|
|
265
|
+
const result = [];
|
|
266
|
+
for (const envKvList of envItems) {
|
|
267
|
+
const name = getKvStringValue(envKvList, "name");
|
|
268
|
+
const directValue = getKvStringValue(envKvList, "value");
|
|
269
|
+
if (directValue) {
|
|
270
|
+
result.push({ name, value: directValue });
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
// Check for valueFrom (secretKeyRef, configMapKeyRef, fieldRef)
|
|
274
|
+
const valueFrom = getKvValue(envKvList, "valueFrom");
|
|
275
|
+
if (valueFrom && typeof valueFrom !== "string") {
|
|
276
|
+
const secretRef = getKvValue(valueFrom, "secretKeyRef");
|
|
277
|
+
const configMapRef = getKvValue(valueFrom, "configMapKeyRef");
|
|
278
|
+
const fieldRef = getKvValue(valueFrom, "fieldRef");
|
|
279
|
+
if (secretRef && typeof secretRef !== "string") {
|
|
280
|
+
const secretName = getKvStringValue(secretRef, "name");
|
|
281
|
+
const secretKey = getKvStringValue(secretRef, "key");
|
|
282
|
+
result.push({
|
|
283
|
+
name,
|
|
284
|
+
value: `<Secret: ${secretName}/${secretKey}>`,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
else if (configMapRef && typeof configMapRef !== "string") {
|
|
288
|
+
const cmName = getKvStringValue(configMapRef, "name");
|
|
289
|
+
const cmKey = getKvStringValue(configMapRef, "key");
|
|
290
|
+
result.push({
|
|
291
|
+
name,
|
|
292
|
+
value: `<ConfigMap: ${cmName}/${cmKey}>`,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
else if (fieldRef && typeof fieldRef !== "string") {
|
|
296
|
+
const fieldPath = getKvStringValue(fieldRef, "fieldPath");
|
|
297
|
+
result.push({ name, value: `<FieldRef: ${fieldPath}>` });
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
result.push({ name, value: "<from valueFrom>" });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
result.push({ name, value: directValue || "" });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
function parseContainerSpec(kvList) {
|
|
311
|
+
const portsArrayValue = getKvValue(kvList, "ports");
|
|
312
|
+
const ports = [];
|
|
313
|
+
if (portsArrayValue && typeof portsArrayValue !== "string") {
|
|
314
|
+
const portItems = getArrayValues(portsArrayValue);
|
|
315
|
+
for (const portKv of portItems) {
|
|
316
|
+
ports.push({
|
|
317
|
+
name: getKvStringValue(portKv, "name"),
|
|
318
|
+
containerPort: parseInt(getKvStringValue(portKv, "containerPort")) || 0,
|
|
319
|
+
protocol: getKvStringValue(portKv, "protocol") || "TCP",
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const envArrayValue = getKvValue(kvList, "env");
|
|
324
|
+
const env = parseContainerEnv(envArrayValue);
|
|
325
|
+
const volumeMountsArray = getKvValue(kvList, "volumeMounts");
|
|
326
|
+
const volumeMounts = [];
|
|
327
|
+
if (volumeMountsArray && typeof volumeMountsArray !== "string") {
|
|
328
|
+
const mountItems = getArrayValues(volumeMountsArray);
|
|
329
|
+
for (const mountKv of mountItems) {
|
|
330
|
+
volumeMounts.push({
|
|
331
|
+
name: getKvStringValue(mountKv, "name"),
|
|
332
|
+
mountPath: getKvStringValue(mountKv, "mountPath"),
|
|
333
|
+
readOnly: getKvStringValue(mountKv, "readOnly") === "true",
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const resourcesKv = getKvValue(kvList, "resources");
|
|
338
|
+
let requests = {};
|
|
339
|
+
let limits = {};
|
|
340
|
+
if (resourcesKv && typeof resourcesKv !== "string") {
|
|
341
|
+
const reqKv = getKvValue(resourcesKv, "requests");
|
|
342
|
+
const limKv = getKvValue(resourcesKv, "limits");
|
|
343
|
+
if (reqKv && typeof reqKv !== "string") {
|
|
344
|
+
requests = getKvListAsRecord(reqKv);
|
|
345
|
+
}
|
|
346
|
+
if (limKv && typeof limKv !== "string") {
|
|
347
|
+
limits = getKvListAsRecord(limKv);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const commandArray = getKvValue(kvList, "command");
|
|
351
|
+
const command = [];
|
|
352
|
+
if (commandArray && typeof commandArray !== "string") {
|
|
353
|
+
const cmdValues = commandArray["values"] || [];
|
|
354
|
+
for (const v of cmdValues) {
|
|
355
|
+
if (v["stringValue"]) {
|
|
356
|
+
command.push(v["stringValue"]);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const argsArray = getKvValue(kvList, "args");
|
|
361
|
+
const args = [];
|
|
362
|
+
if (argsArray && typeof argsArray !== "string") {
|
|
363
|
+
const argValues = argsArray["values"] || [];
|
|
364
|
+
for (const v of argValues) {
|
|
365
|
+
if (v["stringValue"]) {
|
|
366
|
+
args.push(v["stringValue"]);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
name: getKvStringValue(kvList, "name"),
|
|
372
|
+
image: getKvStringValue(kvList, "image"),
|
|
373
|
+
command,
|
|
374
|
+
args,
|
|
375
|
+
env,
|
|
376
|
+
ports,
|
|
377
|
+
resources: { requests, limits },
|
|
378
|
+
volumeMounts,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function parseConditions(conditionsArrayValue) {
|
|
382
|
+
if (!conditionsArrayValue) {
|
|
383
|
+
return [];
|
|
384
|
+
}
|
|
385
|
+
const items = getArrayValues(conditionsArrayValue);
|
|
386
|
+
return items.map((kvList) => {
|
|
387
|
+
return {
|
|
388
|
+
type: getKvStringValue(kvList, "type"),
|
|
389
|
+
status: getKvStringValue(kvList, "status"),
|
|
390
|
+
reason: getKvStringValue(kvList, "reason"),
|
|
391
|
+
message: getKvStringValue(kvList, "message"),
|
|
392
|
+
lastTransitionTime: getKvStringValue(kvList, "lastTransitionTime"),
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
function parseContainerStatuses(statusesArrayValue) {
|
|
397
|
+
if (!statusesArrayValue) {
|
|
398
|
+
return [];
|
|
399
|
+
}
|
|
400
|
+
const items = getArrayValues(statusesArrayValue);
|
|
401
|
+
return items.map((kvList) => {
|
|
402
|
+
// state is a kvlist with one key (running/waiting/terminated)
|
|
403
|
+
const stateKv = getKvValue(kvList, "state");
|
|
404
|
+
let state = "Unknown";
|
|
405
|
+
let reason = "";
|
|
406
|
+
if (stateKv && typeof stateKv !== "string") {
|
|
407
|
+
const stateValues = stateKv["values"];
|
|
408
|
+
if (stateValues && stateValues.length > 0 && stateValues[0]) {
|
|
409
|
+
state = stateValues[0]["key"] || "Unknown";
|
|
410
|
+
// Extract reason from the state's nested kvlist value (e.g., waiting -> { reason: "CrashLoopBackOff" })
|
|
411
|
+
const stateDetail = stateValues[0]["value"];
|
|
412
|
+
if (stateDetail && stateDetail["kvlistValue"]) {
|
|
413
|
+
reason = getKvStringValue(stateDetail["kvlistValue"], "reason");
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
name: getKvStringValue(kvList, "name"),
|
|
419
|
+
ready: getKvStringValue(kvList, "ready") === "true",
|
|
420
|
+
restartCount: parseInt(getKvStringValue(kvList, "restartCount")) || 0,
|
|
421
|
+
state,
|
|
422
|
+
reason,
|
|
423
|
+
image: getKvStringValue(kvList, "image"),
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Parse a raw OTLP log body into a Pod object.
|
|
429
|
+
* The body format: { kvlistValue: { values: [{ key: "type", value: ... }, { key: "object", value: { kvlistValue: ... } }] } }
|
|
430
|
+
*/
|
|
431
|
+
export function parsePodObject(objectKvList) {
|
|
432
|
+
try {
|
|
433
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
434
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
const metadata = parseMetadata(metadataKv);
|
|
438
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
439
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
440
|
+
// Parse containers
|
|
441
|
+
const containers = [];
|
|
442
|
+
const initContainers = [];
|
|
443
|
+
if (specKv && typeof specKv !== "string") {
|
|
444
|
+
const containersArray = getKvValue(specKv, "containers");
|
|
445
|
+
if (containersArray && typeof containersArray !== "string") {
|
|
446
|
+
const containerItems = getArrayValues(containersArray);
|
|
447
|
+
for (const cKv of containerItems) {
|
|
448
|
+
containers.push(parseContainerSpec(cKv));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const initContainersArray = getKvValue(specKv, "initContainers");
|
|
452
|
+
if (initContainersArray && typeof initContainersArray !== "string") {
|
|
453
|
+
const initItems = getArrayValues(initContainersArray);
|
|
454
|
+
for (const cKv of initItems) {
|
|
455
|
+
initContainers.push(parseContainerSpec(cKv));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Parse volumes
|
|
460
|
+
const volumes = [];
|
|
461
|
+
if (specKv && typeof specKv !== "string") {
|
|
462
|
+
const volumesArray = getKvValue(specKv, "volumes");
|
|
463
|
+
if (volumesArray && typeof volumesArray !== "string") {
|
|
464
|
+
const volItems = getArrayValues(volumesArray);
|
|
465
|
+
for (const volKv of volItems) {
|
|
466
|
+
const name = getKvStringValue(volKv, "name");
|
|
467
|
+
// Volume type is one of: configMap, secret, emptyDir, hostPath, persistentVolumeClaim, etc.
|
|
468
|
+
const volValues = volKv["values"];
|
|
469
|
+
let volType = "unknown";
|
|
470
|
+
let volSource = "";
|
|
471
|
+
if (volValues) {
|
|
472
|
+
for (const v of volValues) {
|
|
473
|
+
const k = v["key"] || "";
|
|
474
|
+
if (k !== "name") {
|
|
475
|
+
volType = k;
|
|
476
|
+
const innerVal = v["value"];
|
|
477
|
+
if (innerVal && innerVal["kvlistValue"]) {
|
|
478
|
+
const innerKv = innerVal["kvlistValue"];
|
|
479
|
+
volSource =
|
|
480
|
+
getKvStringValue(innerKv, "name") ||
|
|
481
|
+
getKvStringValue(innerKv, "path") ||
|
|
482
|
+
getKvStringValue(innerKv, "claimName") ||
|
|
483
|
+
volType;
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
volumes.push({ name, type: volType, source: volSource });
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// Parse tolerations
|
|
494
|
+
const tolerations = [];
|
|
495
|
+
if (specKv && typeof specKv !== "string") {
|
|
496
|
+
const tolArray = getKvValue(specKv, "tolerations");
|
|
497
|
+
if (tolArray && typeof tolArray !== "string") {
|
|
498
|
+
const tolItems = getArrayValues(tolArray);
|
|
499
|
+
for (const tolKv of tolItems) {
|
|
500
|
+
tolerations.push({
|
|
501
|
+
key: getKvStringValue(tolKv, "key"),
|
|
502
|
+
operator: getKvStringValue(tolKv, "operator"),
|
|
503
|
+
value: getKvStringValue(tolKv, "value"),
|
|
504
|
+
effect: getKvStringValue(tolKv, "effect"),
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
// Parse nodeSelector
|
|
510
|
+
let nodeSelector = {};
|
|
511
|
+
if (specKv && typeof specKv !== "string") {
|
|
512
|
+
const nsKv = getKvValue(specKv, "nodeSelector");
|
|
513
|
+
if (nsKv && typeof nsKv !== "string") {
|
|
514
|
+
nodeSelector = getKvListAsRecord(nsKv);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
// Parse status
|
|
518
|
+
let phase = "";
|
|
519
|
+
let podIP = "";
|
|
520
|
+
let hostIP = "";
|
|
521
|
+
let qosClass = "";
|
|
522
|
+
let conditions = [];
|
|
523
|
+
let containerStatuses = [];
|
|
524
|
+
let initContainerStatuses = [];
|
|
525
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
526
|
+
phase = getKvStringValue(statusKv, "phase");
|
|
527
|
+
podIP = getKvStringValue(statusKv, "podIP");
|
|
528
|
+
hostIP = getKvStringValue(statusKv, "hostIP");
|
|
529
|
+
qosClass = getKvStringValue(statusKv, "qosClass");
|
|
530
|
+
const condArray = getKvValue(statusKv, "conditions");
|
|
531
|
+
conditions = parseConditions(condArray);
|
|
532
|
+
const csArray = getKvValue(statusKv, "containerStatuses");
|
|
533
|
+
containerStatuses = parseContainerStatuses(csArray);
|
|
534
|
+
const icsArray = getKvValue(statusKv, "initContainerStatuses");
|
|
535
|
+
initContainerStatuses = parseContainerStatuses(icsArray);
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
metadata,
|
|
539
|
+
spec: {
|
|
540
|
+
containers,
|
|
541
|
+
initContainers,
|
|
542
|
+
serviceAccountName: specKv
|
|
543
|
+
? getKvStringValue(specKv, "serviceAccountName")
|
|
544
|
+
: "",
|
|
545
|
+
nodeName: specKv
|
|
546
|
+
? getKvStringValue(specKv, "nodeName")
|
|
547
|
+
: "",
|
|
548
|
+
nodeSelector,
|
|
549
|
+
tolerations,
|
|
550
|
+
volumes,
|
|
551
|
+
},
|
|
552
|
+
status: {
|
|
553
|
+
phase,
|
|
554
|
+
podIP,
|
|
555
|
+
hostIP,
|
|
556
|
+
qosClass,
|
|
557
|
+
conditions,
|
|
558
|
+
containerStatuses,
|
|
559
|
+
initContainerStatuses,
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
catch (_a) {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
export function parseNodeObject(objectKvList) {
|
|
568
|
+
try {
|
|
569
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
570
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
574
|
+
let conditions = [];
|
|
575
|
+
let nodeInfo = {
|
|
576
|
+
osImage: "",
|
|
577
|
+
kernelVersion: "",
|
|
578
|
+
containerRuntimeVersion: "",
|
|
579
|
+
kubeletVersion: "",
|
|
580
|
+
architecture: "",
|
|
581
|
+
operatingSystem: "",
|
|
582
|
+
};
|
|
583
|
+
let allocatable = {};
|
|
584
|
+
let capacity = {};
|
|
585
|
+
let addresses = [];
|
|
586
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
587
|
+
const condArray = getKvValue(statusKv, "conditions");
|
|
588
|
+
conditions = parseConditions(condArray);
|
|
589
|
+
const nodeInfoKv = getKvValue(statusKv, "nodeInfo");
|
|
590
|
+
if (nodeInfoKv && typeof nodeInfoKv !== "string") {
|
|
591
|
+
nodeInfo = {
|
|
592
|
+
osImage: getKvStringValue(nodeInfoKv, "osImage"),
|
|
593
|
+
kernelVersion: getKvStringValue(nodeInfoKv, "kernelVersion"),
|
|
594
|
+
containerRuntimeVersion: getKvStringValue(nodeInfoKv, "containerRuntimeVersion"),
|
|
595
|
+
kubeletVersion: getKvStringValue(nodeInfoKv, "kubeletVersion"),
|
|
596
|
+
architecture: getKvStringValue(nodeInfoKv, "architecture"),
|
|
597
|
+
operatingSystem: getKvStringValue(nodeInfoKv, "operatingSystem"),
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
const allocKv = getKvValue(statusKv, "allocatable");
|
|
601
|
+
if (allocKv && typeof allocKv !== "string") {
|
|
602
|
+
allocatable = getKvListAsRecord(allocKv);
|
|
603
|
+
}
|
|
604
|
+
const capKv = getKvValue(statusKv, "capacity");
|
|
605
|
+
if (capKv && typeof capKv !== "string") {
|
|
606
|
+
capacity = getKvListAsRecord(capKv);
|
|
607
|
+
}
|
|
608
|
+
const addrArray = getKvValue(statusKv, "addresses");
|
|
609
|
+
if (addrArray && typeof addrArray !== "string") {
|
|
610
|
+
const addrItems = getArrayValues(addrArray);
|
|
611
|
+
addresses = addrItems.map((a) => {
|
|
612
|
+
return {
|
|
613
|
+
type: getKvStringValue(a, "type"),
|
|
614
|
+
address: getKvStringValue(a, "address"),
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return {
|
|
620
|
+
metadata: parseMetadata(metadataKv),
|
|
621
|
+
status: {
|
|
622
|
+
conditions,
|
|
623
|
+
nodeInfo,
|
|
624
|
+
allocatable,
|
|
625
|
+
capacity,
|
|
626
|
+
addresses,
|
|
627
|
+
},
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
catch (_a) {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
export function parseDeploymentObject(objectKvList) {
|
|
635
|
+
try {
|
|
636
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
637
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
641
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
642
|
+
let replicas = 0;
|
|
643
|
+
let strategy = "";
|
|
644
|
+
let selector = {};
|
|
645
|
+
if (specKv && typeof specKv !== "string") {
|
|
646
|
+
replicas = parseInt(getKvStringValue(specKv, "replicas")) || 0;
|
|
647
|
+
const strategyKv = getKvValue(specKv, "strategy");
|
|
648
|
+
if (strategyKv && typeof strategyKv !== "string") {
|
|
649
|
+
strategy = getKvStringValue(strategyKv, "type");
|
|
650
|
+
}
|
|
651
|
+
const selectorKv = getKvValue(specKv, "selector");
|
|
652
|
+
if (selectorKv && typeof selectorKv !== "string") {
|
|
653
|
+
const matchLabelsKv = getKvValue(selectorKv, "matchLabels");
|
|
654
|
+
if (matchLabelsKv && typeof matchLabelsKv !== "string") {
|
|
655
|
+
selector = getKvListAsRecord(matchLabelsKv);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
let statusReplicas = 0;
|
|
660
|
+
let readyReplicas = 0;
|
|
661
|
+
let availableReplicas = 0;
|
|
662
|
+
let unavailableReplicas = 0;
|
|
663
|
+
let conditions = [];
|
|
664
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
665
|
+
statusReplicas = parseInt(getKvStringValue(statusKv, "replicas")) || 0;
|
|
666
|
+
readyReplicas =
|
|
667
|
+
parseInt(getKvStringValue(statusKv, "readyReplicas")) || 0;
|
|
668
|
+
availableReplicas =
|
|
669
|
+
parseInt(getKvStringValue(statusKv, "availableReplicas")) || 0;
|
|
670
|
+
unavailableReplicas =
|
|
671
|
+
parseInt(getKvStringValue(statusKv, "unavailableReplicas")) || 0;
|
|
672
|
+
const condArray = getKvValue(statusKv, "conditions");
|
|
673
|
+
conditions = parseConditions(condArray);
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
metadata: parseMetadata(metadataKv),
|
|
677
|
+
spec: { replicas, strategy, selector },
|
|
678
|
+
status: {
|
|
679
|
+
replicas: statusReplicas,
|
|
680
|
+
readyReplicas,
|
|
681
|
+
availableReplicas,
|
|
682
|
+
unavailableReplicas,
|
|
683
|
+
conditions,
|
|
684
|
+
},
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
catch (_a) {
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
export function parseStatefulSetObject(objectKvList) {
|
|
692
|
+
try {
|
|
693
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
694
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
698
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
699
|
+
let replicas = 0;
|
|
700
|
+
let serviceName = "";
|
|
701
|
+
let podManagementPolicy = "";
|
|
702
|
+
let updateStrategy = "";
|
|
703
|
+
if (specKv && typeof specKv !== "string") {
|
|
704
|
+
replicas = parseInt(getKvStringValue(specKv, "replicas")) || 0;
|
|
705
|
+
serviceName = getKvStringValue(specKv, "serviceName");
|
|
706
|
+
podManagementPolicy = getKvStringValue(specKv, "podManagementPolicy");
|
|
707
|
+
const usKv = getKvValue(specKv, "updateStrategy");
|
|
708
|
+
if (usKv && typeof usKv !== "string") {
|
|
709
|
+
updateStrategy = getKvStringValue(usKv, "type");
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
metadata: parseMetadata(metadataKv),
|
|
714
|
+
spec: { replicas, serviceName, podManagementPolicy, updateStrategy },
|
|
715
|
+
status: {
|
|
716
|
+
replicas: statusKv
|
|
717
|
+
? parseInt(getKvStringValue(statusKv, "replicas")) || 0
|
|
718
|
+
: 0,
|
|
719
|
+
readyReplicas: statusKv
|
|
720
|
+
? parseInt(getKvStringValue(statusKv, "readyReplicas")) || 0
|
|
721
|
+
: 0,
|
|
722
|
+
currentReplicas: statusKv
|
|
723
|
+
? parseInt(getKvStringValue(statusKv, "currentReplicas")) || 0
|
|
724
|
+
: 0,
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
catch (_a) {
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
export function parseDaemonSetObject(objectKvList) {
|
|
733
|
+
try {
|
|
734
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
735
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
739
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
740
|
+
let updateStrategy = "";
|
|
741
|
+
if (specKv && typeof specKv !== "string") {
|
|
742
|
+
const usKv = getKvValue(specKv, "updateStrategy");
|
|
743
|
+
if (usKv && typeof usKv !== "string") {
|
|
744
|
+
updateStrategy = getKvStringValue(usKv, "type");
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return {
|
|
748
|
+
metadata: parseMetadata(metadataKv),
|
|
749
|
+
spec: { updateStrategy },
|
|
750
|
+
status: {
|
|
751
|
+
desiredNumberScheduled: statusKv
|
|
752
|
+
? parseInt(getKvStringValue(statusKv, "desiredNumberScheduled")) || 0
|
|
753
|
+
: 0,
|
|
754
|
+
currentNumberScheduled: statusKv
|
|
755
|
+
? parseInt(getKvStringValue(statusKv, "currentNumberScheduled")) || 0
|
|
756
|
+
: 0,
|
|
757
|
+
numberReady: statusKv
|
|
758
|
+
? parseInt(getKvStringValue(statusKv, "numberReady")) ||
|
|
759
|
+
0
|
|
760
|
+
: 0,
|
|
761
|
+
numberMisscheduled: statusKv
|
|
762
|
+
? parseInt(getKvStringValue(statusKv, "numberMisscheduled")) || 0
|
|
763
|
+
: 0,
|
|
764
|
+
numberAvailable: statusKv
|
|
765
|
+
? parseInt(getKvStringValue(statusKv, "numberAvailable")) || 0
|
|
766
|
+
: 0,
|
|
767
|
+
},
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
catch (_a) {
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
export function parseJobObject(objectKvList) {
|
|
775
|
+
try {
|
|
776
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
777
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
781
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
782
|
+
return {
|
|
783
|
+
metadata: parseMetadata(metadataKv),
|
|
784
|
+
spec: {
|
|
785
|
+
completions: specKv
|
|
786
|
+
? parseInt(getKvStringValue(specKv, "completions")) || 0
|
|
787
|
+
: 0,
|
|
788
|
+
parallelism: specKv
|
|
789
|
+
? parseInt(getKvStringValue(specKv, "parallelism")) || 0
|
|
790
|
+
: 0,
|
|
791
|
+
backoffLimit: specKv
|
|
792
|
+
? parseInt(getKvStringValue(specKv, "backoffLimit")) ||
|
|
793
|
+
0
|
|
794
|
+
: 0,
|
|
795
|
+
},
|
|
796
|
+
status: {
|
|
797
|
+
active: statusKv
|
|
798
|
+
? parseInt(getKvStringValue(statusKv, "active")) || 0
|
|
799
|
+
: 0,
|
|
800
|
+
succeeded: statusKv
|
|
801
|
+
? parseInt(getKvStringValue(statusKv, "succeeded")) || 0
|
|
802
|
+
: 0,
|
|
803
|
+
failed: statusKv
|
|
804
|
+
? parseInt(getKvStringValue(statusKv, "failed")) || 0
|
|
805
|
+
: 0,
|
|
806
|
+
startTime: statusKv
|
|
807
|
+
? getKvStringValue(statusKv, "startTime")
|
|
808
|
+
: "",
|
|
809
|
+
completionTime: statusKv
|
|
810
|
+
? getKvStringValue(statusKv, "completionTime")
|
|
811
|
+
: "",
|
|
812
|
+
conditions: statusKv
|
|
813
|
+
? parseConditions(getKvValue(statusKv, "conditions"))
|
|
814
|
+
: [],
|
|
815
|
+
},
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
catch (_a) {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
export function parseCronJobObject(objectKvList) {
|
|
823
|
+
try {
|
|
824
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
825
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
826
|
+
return null;
|
|
827
|
+
}
|
|
828
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
829
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
830
|
+
return {
|
|
831
|
+
metadata: parseMetadata(metadataKv),
|
|
832
|
+
spec: {
|
|
833
|
+
schedule: specKv
|
|
834
|
+
? getKvStringValue(specKv, "schedule")
|
|
835
|
+
: "",
|
|
836
|
+
suspend: specKv
|
|
837
|
+
? getKvStringValue(specKv, "suspend") === "true"
|
|
838
|
+
: false,
|
|
839
|
+
concurrencyPolicy: specKv
|
|
840
|
+
? getKvStringValue(specKv, "concurrencyPolicy")
|
|
841
|
+
: "",
|
|
842
|
+
successfulJobsHistoryLimit: specKv
|
|
843
|
+
? parseInt(getKvStringValue(specKv, "successfulJobsHistoryLimit")) || 0
|
|
844
|
+
: 0,
|
|
845
|
+
failedJobsHistoryLimit: specKv
|
|
846
|
+
? parseInt(getKvStringValue(specKv, "failedJobsHistoryLimit")) || 0
|
|
847
|
+
: 0,
|
|
848
|
+
},
|
|
849
|
+
status: {
|
|
850
|
+
lastScheduleTime: statusKv
|
|
851
|
+
? getKvStringValue(statusKv, "lastScheduleTime")
|
|
852
|
+
: "",
|
|
853
|
+
activeCount: statusKv
|
|
854
|
+
? parseInt(getKvStringValue(statusKv, "active")) || 0
|
|
855
|
+
: 0,
|
|
856
|
+
},
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
catch (_a) {
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
export function parseNamespaceObject(objectKvList) {
|
|
864
|
+
try {
|
|
865
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
866
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
870
|
+
return {
|
|
871
|
+
metadata: parseMetadata(metadataKv),
|
|
872
|
+
status: {
|
|
873
|
+
phase: statusKv
|
|
874
|
+
? getKvStringValue(statusKv, "phase")
|
|
875
|
+
: "",
|
|
876
|
+
},
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
catch (_a) {
|
|
880
|
+
return null;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
export function parsePVCObject(objectKvList) {
|
|
884
|
+
try {
|
|
885
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
886
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
const metadata = parseMetadata(metadataKv);
|
|
890
|
+
if (!metadata.name) {
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
894
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
895
|
+
// Parse spec
|
|
896
|
+
const accessModes = [];
|
|
897
|
+
let storageClassName = "";
|
|
898
|
+
let volumeName = "";
|
|
899
|
+
let requestsStorage = "";
|
|
900
|
+
if (specKv && typeof specKv !== "string") {
|
|
901
|
+
storageClassName = getKvStringValue(specKv, "storageClassName");
|
|
902
|
+
volumeName = getKvStringValue(specKv, "volumeName");
|
|
903
|
+
const accessModesArray = getKvValue(specKv, "accessModes");
|
|
904
|
+
if (accessModesArray && typeof accessModesArray !== "string") {
|
|
905
|
+
const modeValues = accessModesArray["values"] || [];
|
|
906
|
+
for (const v of modeValues) {
|
|
907
|
+
if (v["stringValue"]) {
|
|
908
|
+
accessModes.push(v["stringValue"]);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const resourcesKv = getKvValue(specKv, "resources");
|
|
913
|
+
if (resourcesKv && typeof resourcesKv !== "string") {
|
|
914
|
+
requestsStorage = getNestedKvValue(resourcesKv, "requests", "storage");
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
// Parse status
|
|
918
|
+
let phase = "";
|
|
919
|
+
let capacityStorage = "";
|
|
920
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
921
|
+
phase = getKvStringValue(statusKv, "phase");
|
|
922
|
+
capacityStorage = getNestedKvValue(statusKv, "capacity", "storage");
|
|
923
|
+
}
|
|
924
|
+
return {
|
|
925
|
+
metadata,
|
|
926
|
+
spec: {
|
|
927
|
+
accessModes,
|
|
928
|
+
storageClassName,
|
|
929
|
+
volumeName,
|
|
930
|
+
resources: {
|
|
931
|
+
requests: {
|
|
932
|
+
storage: requestsStorage,
|
|
933
|
+
},
|
|
934
|
+
},
|
|
935
|
+
},
|
|
936
|
+
status: {
|
|
937
|
+
phase,
|
|
938
|
+
capacity: {
|
|
939
|
+
storage: capacityStorage,
|
|
940
|
+
},
|
|
941
|
+
},
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
catch (_a) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
export function parsePVObject(objectKvList) {
|
|
949
|
+
try {
|
|
950
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
951
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
952
|
+
return null;
|
|
953
|
+
}
|
|
954
|
+
const metadata = parseMetadata(metadataKv);
|
|
955
|
+
if (!metadata.name) {
|
|
956
|
+
return null;
|
|
957
|
+
}
|
|
958
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
959
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
960
|
+
// Parse spec
|
|
961
|
+
let capacityStorage = "";
|
|
962
|
+
const accessModes = [];
|
|
963
|
+
let storageClassName = "";
|
|
964
|
+
let persistentVolumeReclaimPolicy = "";
|
|
965
|
+
let claimRefName = "";
|
|
966
|
+
let claimRefNamespace = "";
|
|
967
|
+
if (specKv && typeof specKv !== "string") {
|
|
968
|
+
capacityStorage = getNestedKvValue(specKv, "capacity", "storage");
|
|
969
|
+
storageClassName = getKvStringValue(specKv, "storageClassName");
|
|
970
|
+
persistentVolumeReclaimPolicy = getKvStringValue(specKv, "persistentVolumeReclaimPolicy");
|
|
971
|
+
const accessModesArray = getKvValue(specKv, "accessModes");
|
|
972
|
+
if (accessModesArray && typeof accessModesArray !== "string") {
|
|
973
|
+
const modeValues = accessModesArray["values"] || [];
|
|
974
|
+
for (const v of modeValues) {
|
|
975
|
+
if (v["stringValue"]) {
|
|
976
|
+
accessModes.push(v["stringValue"]);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
const claimRefKv = getKvValue(specKv, "claimRef");
|
|
981
|
+
if (claimRefKv && typeof claimRefKv !== "string") {
|
|
982
|
+
claimRefName = getKvStringValue(claimRefKv, "name");
|
|
983
|
+
claimRefNamespace = getKvStringValue(claimRefKv, "namespace");
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
// Parse status
|
|
987
|
+
let phase = "";
|
|
988
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
989
|
+
phase = getKvStringValue(statusKv, "phase");
|
|
990
|
+
}
|
|
991
|
+
return {
|
|
992
|
+
metadata,
|
|
993
|
+
spec: {
|
|
994
|
+
capacity: {
|
|
995
|
+
storage: capacityStorage,
|
|
996
|
+
},
|
|
997
|
+
accessModes,
|
|
998
|
+
storageClassName,
|
|
999
|
+
persistentVolumeReclaimPolicy,
|
|
1000
|
+
claimRef: {
|
|
1001
|
+
name: claimRefName,
|
|
1002
|
+
namespace: claimRefNamespace,
|
|
1003
|
+
},
|
|
1004
|
+
},
|
|
1005
|
+
status: {
|
|
1006
|
+
phase,
|
|
1007
|
+
},
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
catch (_a) {
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
export function parseHPAObject(objectKvList) {
|
|
1015
|
+
try {
|
|
1016
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
1017
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
1021
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
1022
|
+
let minReplicas = 0;
|
|
1023
|
+
let maxReplicas = 0;
|
|
1024
|
+
let scaleTargetRef = {
|
|
1025
|
+
kind: "",
|
|
1026
|
+
name: "",
|
|
1027
|
+
};
|
|
1028
|
+
const metrics = [];
|
|
1029
|
+
if (specKv && typeof specKv !== "string") {
|
|
1030
|
+
minReplicas = parseInt(getKvStringValue(specKv, "minReplicas")) || 0;
|
|
1031
|
+
maxReplicas = parseInt(getKvStringValue(specKv, "maxReplicas")) || 0;
|
|
1032
|
+
const targetRefKv = getKvValue(specKv, "scaleTargetRef");
|
|
1033
|
+
if (targetRefKv && typeof targetRefKv !== "string") {
|
|
1034
|
+
scaleTargetRef = {
|
|
1035
|
+
kind: getKvStringValue(targetRefKv, "kind"),
|
|
1036
|
+
name: getKvStringValue(targetRefKv, "name"),
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
const metricsArrayKv = getKvValue(specKv, "metrics");
|
|
1040
|
+
if (metricsArrayKv && typeof metricsArrayKv !== "string") {
|
|
1041
|
+
const metricsItems = getArrayValues(metricsArrayKv);
|
|
1042
|
+
for (const metricKv of metricsItems) {
|
|
1043
|
+
const metricType = getKvStringValue(metricKv, "type");
|
|
1044
|
+
let resourceName = "";
|
|
1045
|
+
let targetType = "";
|
|
1046
|
+
let targetValue = "";
|
|
1047
|
+
const resourceKv = getKvValue(metricKv, "resource");
|
|
1048
|
+
if (resourceKv && typeof resourceKv !== "string") {
|
|
1049
|
+
resourceName = getKvStringValue(resourceKv, "name");
|
|
1050
|
+
const targetKv = getKvValue(resourceKv, "target");
|
|
1051
|
+
if (targetKv && typeof targetKv !== "string") {
|
|
1052
|
+
targetType = getKvStringValue(targetKv, "type");
|
|
1053
|
+
targetValue =
|
|
1054
|
+
getKvStringValue(targetKv, "averageUtilization") ||
|
|
1055
|
+
getKvStringValue(targetKv, "averageValue") ||
|
|
1056
|
+
getKvStringValue(targetKv, "value");
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
metrics.push({
|
|
1060
|
+
type: metricType,
|
|
1061
|
+
resourceName,
|
|
1062
|
+
targetType,
|
|
1063
|
+
targetValue,
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
let currentReplicas = 0;
|
|
1069
|
+
let desiredReplicas = 0;
|
|
1070
|
+
let conditions = [];
|
|
1071
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
1072
|
+
currentReplicas =
|
|
1073
|
+
parseInt(getKvStringValue(statusKv, "currentReplicas")) || 0;
|
|
1074
|
+
desiredReplicas =
|
|
1075
|
+
parseInt(getKvStringValue(statusKv, "desiredReplicas")) || 0;
|
|
1076
|
+
const condArray = getKvValue(statusKv, "conditions");
|
|
1077
|
+
if (condArray && typeof condArray !== "string") {
|
|
1078
|
+
const condItems = getArrayValues(condArray);
|
|
1079
|
+
conditions = condItems.map((condKv) => {
|
|
1080
|
+
return {
|
|
1081
|
+
type: getKvStringValue(condKv, "type"),
|
|
1082
|
+
status: getKvStringValue(condKv, "status"),
|
|
1083
|
+
reason: getKvStringValue(condKv, "reason"),
|
|
1084
|
+
message: getKvStringValue(condKv, "message"),
|
|
1085
|
+
lastTransitionTime: getKvStringValue(condKv, "lastTransitionTime"),
|
|
1086
|
+
};
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return {
|
|
1091
|
+
metadata: parseMetadata(metadataKv),
|
|
1092
|
+
spec: { minReplicas, maxReplicas, scaleTargetRef, metrics },
|
|
1093
|
+
status: { currentReplicas, desiredReplicas, conditions },
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
catch (_a) {
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
export function parseVPAObject(objectKvList) {
|
|
1101
|
+
try {
|
|
1102
|
+
const metadataKv = getKvValue(objectKvList, "metadata");
|
|
1103
|
+
if (!metadataKv || typeof metadataKv === "string") {
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
const specKv = getKvValue(objectKvList, "spec");
|
|
1107
|
+
const statusKv = getKvValue(objectKvList, "status");
|
|
1108
|
+
let targetRef = { kind: "", name: "" };
|
|
1109
|
+
let updatePolicy = { updateMode: "" };
|
|
1110
|
+
let resourcePolicy = "";
|
|
1111
|
+
if (specKv && typeof specKv !== "string") {
|
|
1112
|
+
const targetRefKv = getKvValue(specKv, "targetRef");
|
|
1113
|
+
if (targetRefKv && typeof targetRefKv !== "string") {
|
|
1114
|
+
targetRef = {
|
|
1115
|
+
kind: getKvStringValue(targetRefKv, "kind"),
|
|
1116
|
+
name: getKvStringValue(targetRefKv, "name"),
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
const updatePolicyKv = getKvValue(specKv, "updatePolicy");
|
|
1120
|
+
if (updatePolicyKv && typeof updatePolicyKv !== "string") {
|
|
1121
|
+
updatePolicy = {
|
|
1122
|
+
updateMode: getKvStringValue(updatePolicyKv, "updateMode"),
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
resourcePolicy = getKvStringValue(specKv, "resourcePolicy");
|
|
1126
|
+
}
|
|
1127
|
+
const containerRecommendations = [];
|
|
1128
|
+
if (statusKv && typeof statusKv !== "string") {
|
|
1129
|
+
const recommendationKv = getKvValue(statusKv, "recommendation");
|
|
1130
|
+
if (recommendationKv && typeof recommendationKv !== "string") {
|
|
1131
|
+
const containerRecsArrayKv = getKvValue(recommendationKv, "containerRecommendations");
|
|
1132
|
+
if (containerRecsArrayKv && typeof containerRecsArrayKv !== "string") {
|
|
1133
|
+
const recItems = getArrayValues(containerRecsArrayKv);
|
|
1134
|
+
for (const recKv of recItems) {
|
|
1135
|
+
const targetKv = getKvValue(recKv, "target");
|
|
1136
|
+
const lowerBoundKv = getKvValue(recKv, "lowerBound");
|
|
1137
|
+
const upperBoundKv = getKvValue(recKv, "upperBound");
|
|
1138
|
+
containerRecommendations.push({
|
|
1139
|
+
containerName: getKvStringValue(recKv, "containerName"),
|
|
1140
|
+
target: targetKv && typeof targetKv !== "string"
|
|
1141
|
+
? getKvListAsRecord(targetKv)
|
|
1142
|
+
: {},
|
|
1143
|
+
lowerBound: lowerBoundKv && typeof lowerBoundKv !== "string"
|
|
1144
|
+
? getKvListAsRecord(lowerBoundKv)
|
|
1145
|
+
: {},
|
|
1146
|
+
upperBound: upperBoundKv && typeof upperBoundKv !== "string"
|
|
1147
|
+
? getKvListAsRecord(upperBoundKv)
|
|
1148
|
+
: {},
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return {
|
|
1155
|
+
metadata: parseMetadata(metadataKv),
|
|
1156
|
+
spec: { targetRef, updatePolicy, resourcePolicy },
|
|
1157
|
+
status: {
|
|
1158
|
+
recommendation: { containerRecommendations },
|
|
1159
|
+
},
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
catch (_a) {
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Extract the K8s object from a raw OTLP log body string.
|
|
1168
|
+
* For k8sobjects pull mode, the body is:
|
|
1169
|
+
* { kvlistValue: { values: [{ key: "type", value: ... }, { key: "object", value: { kvlistValue: ... } }] } }
|
|
1170
|
+
* OR for some modes, the object may be at the top level.
|
|
1171
|
+
*/
|
|
1172
|
+
export function extractObjectFromLogBody(bodyString) {
|
|
1173
|
+
try {
|
|
1174
|
+
const bodyObj = JSON.parse(bodyString);
|
|
1175
|
+
// Handle both camelCase (JSON encoding) and snake_case (protobuf via protobufjs)
|
|
1176
|
+
const topKvList = (bodyObj["kvlistValue"] ||
|
|
1177
|
+
bodyObj["kvlist_value"]);
|
|
1178
|
+
if (!topKvList) {
|
|
1179
|
+
return null;
|
|
1180
|
+
}
|
|
1181
|
+
// Try to get the "object" key (used in watch mode)
|
|
1182
|
+
const objectVal = getKvValue(topKvList, "object");
|
|
1183
|
+
if (objectVal && typeof objectVal !== "string") {
|
|
1184
|
+
return objectVal;
|
|
1185
|
+
}
|
|
1186
|
+
/*
|
|
1187
|
+
* If no "object" key, the kvlist might BE the object (pull mode)
|
|
1188
|
+
* Check if it has typical K8s fields
|
|
1189
|
+
*/
|
|
1190
|
+
const kind = getKvValue(topKvList, "kind");
|
|
1191
|
+
if (kind) {
|
|
1192
|
+
return topKvList;
|
|
1193
|
+
}
|
|
1194
|
+
// Also check "metadata" as a fallback for objects without "kind"
|
|
1195
|
+
const metadata = getKvValue(topKvList, "metadata");
|
|
1196
|
+
if (metadata && typeof metadata !== "string") {
|
|
1197
|
+
return topKvList;
|
|
1198
|
+
}
|
|
1199
|
+
return null;
|
|
1200
|
+
}
|
|
1201
|
+
catch (_a) {
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
//# sourceMappingURL=KubernetesObjectParser.js.map
|