@oneuptime/common 10.0.71 → 10.0.72
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/Alert.ts +55 -0
- package/Models/DatabaseModels/Incident.ts +55 -0
- package/Models/DatabaseModels/StatusPage.ts +80 -0
- package/Server/API/StatusPageAPI.ts +4 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776940714709-MigrationName.ts +41 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1776971364783-AddStatusPageLanguageSettings.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/AnalyticsDatabaseService.ts +17 -7
- package/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.ts +175 -29
- package/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +71 -0
- package/Server/Utils/Monitor/MonitorAlert.ts +91 -7
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +171 -2
- package/Server/Utils/Monitor/MonitorIncident.ts +133 -8
- package/Server/Utils/Monitor/MonitorMetricUtil.ts +423 -1
- package/Server/Utils/Monitor/MonitorResource.ts +2 -0
- package/Server/Utils/Monitor/MonitorTemplateUtil.ts +99 -0
- package/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.ts +268 -0
- package/Types/Infrastructure/BasicMetrics.ts +75 -0
- package/Types/Metrics/MetricQueryData.ts +11 -0
- package/Types/Monitor/CriteriaFilter.ts +10 -0
- package/Types/Monitor/MetricMonitor/MetricCriteriaContext.ts +11 -0
- package/Types/Monitor/MetricMonitor/MetricMonitorResponse.ts +10 -0
- package/Types/Monitor/MetricMonitor/MetricSeriesResult.ts +20 -0
- package/Types/Monitor/MonitorMetricType.ts +34 -0
- package/Types/Monitor/ServerMonitor/ServerMonitorResponse.ts +8 -0
- package/Types/Probe/ProbeApiIngestResponse.ts +25 -0
- package/Types/StatusPage/StatusPageLanguage.ts +29 -0
- package/UI/Components/Charts/Area/AreaChart.tsx +17 -12
- package/UI/Components/Charts/Bar/BarChart.tsx +16 -11
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +23 -0
- package/UI/Components/Charts/Line/LineChart.tsx +16 -11
- package/UI/Components/Filters/FiltersForm.tsx +26 -2
- package/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.ts +453 -0
- package/UI/Components/MonitorTemplateVariables/TemplateVariablesModal.tsx +229 -0
- package/Utils/Metrics/MetricSeriesFingerprint.ts +97 -0
- package/Utils/Monitor/MonitorMetricType.ts +309 -19
- package/build/dist/Models/DatabaseModels/Alert.js +57 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js +57 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +82 -0
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +4 -0
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776940714709-MigrationName.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776940714709-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776971364783-AddStatusPageLanguageSettings.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1776971364783-AddStatusPageLanguageSettings.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +14 -4
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js +132 -30
- package/build/dist/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js +58 -7
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +66 -12
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +112 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +91 -15
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js +373 -0
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +2 -0
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +65 -0
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
- package/build/dist/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.js +199 -0
- package/build/dist/Tests/Server/Utils/Monitor/Criteria/MetricMonitorCriteria.test.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +10 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MetricMonitor/MetricSeriesResult.js +2 -0
- package/build/dist/Types/Monitor/MetricMonitor/MetricSeriesResult.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorMetricType.js +28 -0
- package/build/dist/Types/Monitor/MonitorMetricType.js.map +1 -1
- package/build/dist/Types/StatusPage/StatusPageLanguage.js +21 -0
- package/build/dist/Types/StatusPage/StatusPageLanguage.js.map +1 -0
- package/build/dist/UI/Components/Charts/Area/AreaChart.js +13 -12
- package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js +12 -11
- package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +11 -3
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js +12 -11
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Filters/FiltersForm.js +6 -2
- package/build/dist/UI/Components/Filters/FiltersForm.js.map +1 -1
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js +383 -0
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.js.map +1 -0
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesModal.js +109 -0
- package/build/dist/UI/Components/MonitorTemplateVariables/TemplateVariablesModal.js.map +1 -0
- package/build/dist/Utils/Metrics/MetricSeriesFingerprint.js +81 -0
- package/build/dist/Utils/Metrics/MetricSeriesFingerprint.js.map +1 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js +287 -19
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/package.json +1 -1
|
@@ -208,6 +208,77 @@ export default class ServerMonitorCriteria {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
if (
|
|
212
|
+
!(input.dataToProcess as ServerMonitorResponse)
|
|
213
|
+
.onlyCheckRequestReceivedAt &&
|
|
214
|
+
(input.criteriaFilter.checkOn === CheckOn.LoadAverage1Min ||
|
|
215
|
+
input.criteriaFilter.checkOn === CheckOn.LoadAverage5Min ||
|
|
216
|
+
input.criteriaFilter.checkOn === CheckOn.LoadAverage15Min)
|
|
217
|
+
) {
|
|
218
|
+
threshold = CompareCriteria.convertToNumber(threshold);
|
|
219
|
+
|
|
220
|
+
const loadMetrics:
|
|
221
|
+
| { load1: number; load5: number; load15: number }
|
|
222
|
+
| undefined = (input.dataToProcess as ServerMonitorResponse)
|
|
223
|
+
.basicInfrastructureMetrics?.loadMetrics;
|
|
224
|
+
|
|
225
|
+
let currentLoad: number | undefined = undefined;
|
|
226
|
+
if (input.criteriaFilter.checkOn === CheckOn.LoadAverage1Min) {
|
|
227
|
+
currentLoad = loadMetrics?.load1;
|
|
228
|
+
} else if (input.criteriaFilter.checkOn === CheckOn.LoadAverage5Min) {
|
|
229
|
+
currentLoad = loadMetrics?.load5;
|
|
230
|
+
} else if (input.criteriaFilter.checkOn === CheckOn.LoadAverage15Min) {
|
|
231
|
+
currentLoad = loadMetrics?.load15;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const value: number | Array<number> =
|
|
235
|
+
(overTimeValue as Array<number>) || currentLoad || 0;
|
|
236
|
+
|
|
237
|
+
return CompareCriteria.compareCriteriaNumbers({
|
|
238
|
+
value: value,
|
|
239
|
+
threshold: threshold as number,
|
|
240
|
+
criteriaFilter: input.criteriaFilter,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (
|
|
245
|
+
input.criteriaFilter.checkOn === CheckOn.SwapUsagePercent &&
|
|
246
|
+
!(input.dataToProcess as ServerMonitorResponse).onlyCheckRequestReceivedAt
|
|
247
|
+
) {
|
|
248
|
+
threshold = CompareCriteria.convertToNumber(threshold);
|
|
249
|
+
|
|
250
|
+
const swapPercent: number | Array<number> =
|
|
251
|
+
(overTimeValue as Array<number>) ||
|
|
252
|
+
(input.dataToProcess as ServerMonitorResponse)
|
|
253
|
+
.basicInfrastructureMetrics?.memoryMetrics?.swapPercentUsed ||
|
|
254
|
+
0;
|
|
255
|
+
|
|
256
|
+
return CompareCriteria.compareCriteriaNumbers({
|
|
257
|
+
value: swapPercent,
|
|
258
|
+
threshold: threshold as number,
|
|
259
|
+
criteriaFilter: input.criteriaFilter,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (
|
|
264
|
+
input.criteriaFilter.checkOn === CheckOn.CPUIoWaitPercent &&
|
|
265
|
+
!(input.dataToProcess as ServerMonitorResponse).onlyCheckRequestReceivedAt
|
|
266
|
+
) {
|
|
267
|
+
threshold = CompareCriteria.convertToNumber(threshold);
|
|
268
|
+
|
|
269
|
+
const ioWaitPercent: number | Array<number> =
|
|
270
|
+
(overTimeValue as Array<number>) ||
|
|
271
|
+
(input.dataToProcess as ServerMonitorResponse)
|
|
272
|
+
.basicInfrastructureMetrics?.cpuMetrics?.timeIoWaitPercent ||
|
|
273
|
+
0;
|
|
274
|
+
|
|
275
|
+
return CompareCriteria.compareCriteriaNumbers({
|
|
276
|
+
value: ioWaitPercent,
|
|
277
|
+
threshold: threshold as number,
|
|
278
|
+
criteriaFilter: input.criteriaFilter,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
211
282
|
if (
|
|
212
283
|
input.criteriaFilter.checkOn === CheckOn.ServerProcessName &&
|
|
213
284
|
threshold &&
|
|
@@ -26,6 +26,7 @@ import MonitorTemplateUtil from "./MonitorTemplateUtil";
|
|
|
26
26
|
import { JSONObject } from "../../../Types/JSON";
|
|
27
27
|
import OneUptimeDate from "../../../Types/Date";
|
|
28
28
|
import MonitorEvaluationSummary from "../../../Types/Monitor/MonitorEvaluationSummary";
|
|
29
|
+
import { PerSeriesCriteriaMatch } from "../../../Types/Probe/ProbeApiIngestResponse";
|
|
29
30
|
|
|
30
31
|
export default class MonitorAlert {
|
|
31
32
|
@CaptureSpan()
|
|
@@ -36,6 +37,7 @@ export default class MonitorAlert {
|
|
|
36
37
|
criteriaInstance: MonitorCriteriaInstance | null;
|
|
37
38
|
dataToProcess: DataToProcess;
|
|
38
39
|
evaluationSummary?: MonitorEvaluationSummary | undefined;
|
|
40
|
+
breachingSeriesFingerprints?: Set<string> | undefined;
|
|
39
41
|
}): Promise<Array<Alert>> {
|
|
40
42
|
// check active alerts and if there are open alerts, do not cretae anothr alert.
|
|
41
43
|
const openAlerts: Array<Alert> = await AlertService.findBy({
|
|
@@ -49,11 +51,14 @@ export default class MonitorAlert {
|
|
|
49
51
|
limit: LIMIT_PER_PROJECT,
|
|
50
52
|
select: {
|
|
51
53
|
_id: true,
|
|
54
|
+
title: true,
|
|
52
55
|
createdCriteriaId: true,
|
|
53
56
|
projectId: true,
|
|
54
57
|
alertNumber: true,
|
|
55
58
|
alertNumberWithPrefix: true,
|
|
56
59
|
currentAlertStateId: true,
|
|
60
|
+
seriesFingerprint: true,
|
|
61
|
+
seriesLabels: true,
|
|
57
62
|
},
|
|
58
63
|
props: {
|
|
59
64
|
isRoot: true,
|
|
@@ -68,6 +73,7 @@ export default class MonitorAlert {
|
|
|
68
73
|
autoResolveCriteriaInstanceIdAlertIdsDictionary:
|
|
69
74
|
input.autoResolveCriteriaInstanceIdAlertIdsDictionary,
|
|
70
75
|
criteriaInstance: input.criteriaInstance,
|
|
76
|
+
breachingSeriesFingerprints: input.breachingSeriesFingerprints,
|
|
71
77
|
});
|
|
72
78
|
|
|
73
79
|
if (shouldClose) {
|
|
@@ -106,6 +112,7 @@ export default class MonitorAlert {
|
|
|
106
112
|
props: {
|
|
107
113
|
telemetryQuery?: TelemetryQuery | undefined;
|
|
108
114
|
};
|
|
115
|
+
matchesPerSeries?: Array<PerSeriesCriteriaMatch> | undefined;
|
|
109
116
|
}): Promise<void> {
|
|
110
117
|
const alertLogAttributes: LogAttributes = {
|
|
111
118
|
projectId: input.monitor.projectId?.toString(),
|
|
@@ -116,6 +123,16 @@ export default class MonitorAlert {
|
|
|
116
123
|
`${input.monitor.id?.toString()} - Check open alerts.`,
|
|
117
124
|
alertLogAttributes,
|
|
118
125
|
);
|
|
126
|
+
|
|
127
|
+
const breachingSeriesFingerprints: Set<string> | undefined =
|
|
128
|
+
input.matchesPerSeries
|
|
129
|
+
? new Set<string>(
|
|
130
|
+
input.matchesPerSeries.map((m: PerSeriesCriteriaMatch) => {
|
|
131
|
+
return m.fingerprint;
|
|
132
|
+
}),
|
|
133
|
+
)
|
|
134
|
+
: undefined;
|
|
135
|
+
|
|
119
136
|
// check active alerts and if there are open alerts, do not cretae anothr alert.
|
|
120
137
|
const openAlerts: Array<Alert> =
|
|
121
138
|
await this.checkOpenAlertsAndCloseIfResolved({
|
|
@@ -126,19 +143,31 @@ export default class MonitorAlert {
|
|
|
126
143
|
criteriaInstance: input.criteriaInstance,
|
|
127
144
|
dataToProcess: input.dataToProcess,
|
|
128
145
|
evaluationSummary: input.evaluationSummary,
|
|
146
|
+
breachingSeriesFingerprints,
|
|
129
147
|
});
|
|
130
148
|
|
|
131
|
-
if (input.criteriaInstance.data?.createAlerts) {
|
|
132
|
-
|
|
149
|
+
if (!input.criteriaInstance.data?.createAlerts) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
133
152
|
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
const seriesToProcess: Array<PerSeriesCriteriaMatch | undefined> =
|
|
154
|
+
input.matchesPerSeries && input.matchesPerSeries.length > 0
|
|
155
|
+
? input.matchesPerSeries
|
|
156
|
+
: [undefined];
|
|
157
|
+
|
|
158
|
+
for (const criteriaAlert of input.criteriaInstance.data?.alerts || []) {
|
|
159
|
+
for (const seriesMatch of seriesToProcess) {
|
|
160
|
+
const seriesFingerprint: string | undefined = seriesMatch?.fingerprint;
|
|
161
|
+
const seriesLabels: JSONObject | undefined = seriesMatch?.labels;
|
|
162
|
+
const seriesRootCause: string =
|
|
163
|
+
seriesMatch?.rootCause || input.rootCause;
|
|
136
164
|
|
|
137
165
|
const alreadyOpenAlert: Alert | undefined = openAlerts.find(
|
|
138
166
|
(alert: Alert) => {
|
|
139
167
|
return (
|
|
140
168
|
alert.createdCriteriaId ===
|
|
141
|
-
|
|
169
|
+
input.criteriaInstance.data?.id.toString() &&
|
|
170
|
+
(alert.seriesFingerprint || undefined) === seriesFingerprint
|
|
142
171
|
);
|
|
143
172
|
},
|
|
144
173
|
);
|
|
@@ -156,9 +185,12 @@ export default class MonitorAlert {
|
|
|
156
185
|
);
|
|
157
186
|
|
|
158
187
|
if (hasAlreadyOpenAlert) {
|
|
188
|
+
const renderedAlertTitle: string =
|
|
189
|
+
alreadyOpenAlert?.title || criteriaAlert.title;
|
|
190
|
+
|
|
159
191
|
input.evaluationSummary?.events.push({
|
|
160
192
|
type: "alert-skipped",
|
|
161
|
-
title: `Alert already active: ${
|
|
193
|
+
title: `Alert already active: ${renderedAlertTitle}`,
|
|
162
194
|
message:
|
|
163
195
|
"Skipped creating a new alert because an active alert exists for this criteria.",
|
|
164
196
|
relatedCriteriaId: input.criteriaInstance.data?.id,
|
|
@@ -183,6 +215,8 @@ export default class MonitorAlert {
|
|
|
183
215
|
MonitorTemplateUtil.buildTemplateStorageMap({
|
|
184
216
|
monitorType: input.monitor.monitorType!,
|
|
185
217
|
dataToProcess: input.dataToProcess,
|
|
218
|
+
monitor: input.monitor,
|
|
219
|
+
seriesLabels,
|
|
186
220
|
});
|
|
187
221
|
|
|
188
222
|
alert.title = MonitorTemplateUtil.processTemplateString({
|
|
@@ -224,13 +258,20 @@ export default class MonitorAlert {
|
|
|
224
258
|
|
|
225
259
|
alert.monitor = input.monitor;
|
|
226
260
|
alert.projectId = input.monitor.projectId!;
|
|
227
|
-
alert.rootCause =
|
|
261
|
+
alert.rootCause = seriesRootCause;
|
|
228
262
|
alert.createdStateLog = JSON.parse(
|
|
229
263
|
JSON.stringify(input.dataToProcess, null, 2),
|
|
230
264
|
);
|
|
231
265
|
|
|
232
266
|
alert.createdCriteriaId = input.criteriaInstance.data.id.toString();
|
|
233
267
|
|
|
268
|
+
if (seriesFingerprint) {
|
|
269
|
+
alert.seriesFingerprint = seriesFingerprint;
|
|
270
|
+
}
|
|
271
|
+
if (seriesLabels && Object.keys(seriesLabels).length > 0) {
|
|
272
|
+
alert.seriesLabels = seriesLabels;
|
|
273
|
+
}
|
|
274
|
+
|
|
234
275
|
alert.onCallDutyPolicies =
|
|
235
276
|
criteriaAlert.onCallPolicyIds?.map((id: ObjectID) => {
|
|
236
277
|
const onCallPolicy: OnCallDutyPolicy = new OnCallDutyPolicy();
|
|
@@ -436,7 +477,50 @@ export default class MonitorAlert {
|
|
|
436
477
|
openAlert: Alert;
|
|
437
478
|
autoResolveCriteriaInstanceIdAlertIdsDictionary: Dictionary<Array<string>>;
|
|
438
479
|
criteriaInstance: MonitorCriteriaInstance | null; // null if no criteia met.
|
|
480
|
+
breachingSeriesFingerprints?: Set<string> | undefined;
|
|
439
481
|
}): boolean {
|
|
482
|
+
const openSeriesFingerprint: string | undefined =
|
|
483
|
+
input.openAlert.seriesFingerprint || undefined;
|
|
484
|
+
|
|
485
|
+
/*
|
|
486
|
+
* Per-series auto-resolve: when a breaching-series set is given and
|
|
487
|
+
* this alert has a fingerprint, resolve whenever the fingerprint is
|
|
488
|
+
* no longer in the set, independent of whether other series on the
|
|
489
|
+
* same monitor are still breaching.
|
|
490
|
+
*/
|
|
491
|
+
if (
|
|
492
|
+
input.breachingSeriesFingerprints !== undefined &&
|
|
493
|
+
openSeriesFingerprint
|
|
494
|
+
) {
|
|
495
|
+
const stillBreaching: boolean = input.breachingSeriesFingerprints.has(
|
|
496
|
+
openSeriesFingerprint,
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
if (stillBreaching) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (!input.openAlert.createdCriteriaId?.toString()) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const autoResolveTemplates: Array<string> | undefined =
|
|
508
|
+
input.autoResolveCriteriaInstanceIdAlertIdsDictionary[
|
|
509
|
+
input.openAlert.createdCriteriaId.toString()
|
|
510
|
+
];
|
|
511
|
+
|
|
512
|
+
/*
|
|
513
|
+
* Alert auto-resolve lists templates by criteria; presence of any
|
|
514
|
+
* template for this criteria means "this criteria's alerts are
|
|
515
|
+
* configured to auto-resolve", so resolve this series.
|
|
516
|
+
*/
|
|
517
|
+
if (autoResolveTemplates && autoResolveTemplates.length > 0) {
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
|
|
440
524
|
if (
|
|
441
525
|
input.openAlert.createdCriteriaId?.toString() ===
|
|
442
526
|
input.criteriaInstance?.data?.id.toString()
|
|
@@ -9,7 +9,9 @@ import SSLMonitorCriteria from "./Criteria/SSLMonitorCriteria";
|
|
|
9
9
|
import ServerMonitorCriteria from "./Criteria/ServerMonitorCriteria";
|
|
10
10
|
import SyntheticMonitoringCriteria from "./Criteria/SyntheticMonitor";
|
|
11
11
|
import LogMonitorCriteria from "./Criteria/LogMonitorCriteria";
|
|
12
|
-
import MetricMonitorCriteria
|
|
12
|
+
import MetricMonitorCriteria, {
|
|
13
|
+
MetricSeriesEvaluationResult,
|
|
14
|
+
} from "./Criteria/MetricMonitorCriteria";
|
|
13
15
|
import TraceMonitorCriteria from "./Criteria/TraceMonitorCriteria";
|
|
14
16
|
import ExceptionMonitorCriteria from "./Criteria/ExceptionMonitorCriteria";
|
|
15
17
|
import ProfileMonitorCriteria from "./Criteria/ProfileMonitorCriteria";
|
|
@@ -31,7 +33,9 @@ import MonitorEvaluationSummary, {
|
|
|
31
33
|
MonitorEvaluationEvent,
|
|
32
34
|
MonitorEvaluationFilterResult,
|
|
33
35
|
} from "../../../Types/Monitor/MonitorEvaluationSummary";
|
|
34
|
-
import ProbeApiIngestResponse
|
|
36
|
+
import ProbeApiIngestResponse, {
|
|
37
|
+
PerSeriesCriteriaMatch,
|
|
38
|
+
} from "../../../Types/Probe/ProbeApiIngestResponse";
|
|
35
39
|
import ProbeMonitorResponse from "../../../Types/Probe/ProbeMonitorResponse";
|
|
36
40
|
import RequestFailedDetails from "../../../Types/Probe/RequestFailedDetails";
|
|
37
41
|
import IncomingMonitorRequest from "../../../Types/Monitor/IncomingMonitor/IncomingMonitorRequest";
|
|
@@ -50,6 +54,7 @@ import MetricMonitorResponse, {
|
|
|
50
54
|
KubernetesAffectedResource,
|
|
51
55
|
KubernetesResourceBreakdown,
|
|
52
56
|
} from "../../../Types/Monitor/MetricMonitor/MetricMonitorResponse";
|
|
57
|
+
import MetricSeriesResult from "../../../Types/Monitor/MetricMonitor/MetricSeriesResult";
|
|
53
58
|
import MetricCriteriaContext, {
|
|
54
59
|
MetricBreachingSample,
|
|
55
60
|
MetricComponent,
|
|
@@ -156,6 +161,26 @@ ${contextBlock}
|
|
|
156
161
|
**Cause**: ${(input.dataToProcess as ProbeMonitorResponse).failureCause || ""}
|
|
157
162
|
`;
|
|
158
163
|
}
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
* When this is a metric-style monitor with per-series results,
|
|
167
|
+
* compute the per-series match list so MonitorResource can fan
|
|
168
|
+
* out one incident per affected series. We do this *after* the
|
|
169
|
+
* scalar criteriaMetId/rootCause is populated so legacy readers
|
|
170
|
+
* still see a usable response if perSeriesMatches is ignored.
|
|
171
|
+
*/
|
|
172
|
+
const perSeriesMatches: Array<PerSeriesCriteriaMatch> =
|
|
173
|
+
MonitorCriteriaEvaluator.collectPerSeriesMatches({
|
|
174
|
+
dataToProcess: input.dataToProcess,
|
|
175
|
+
monitor: input.monitor,
|
|
176
|
+
monitorStep: input.monitorStep,
|
|
177
|
+
criteriaInstance,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (perSeriesMatches.length > 0) {
|
|
181
|
+
input.probeApiIngestResponse.perSeriesMatches = perSeriesMatches;
|
|
182
|
+
}
|
|
183
|
+
|
|
159
184
|
break;
|
|
160
185
|
}
|
|
161
186
|
}
|
|
@@ -163,6 +188,150 @@ ${contextBlock}
|
|
|
163
188
|
return input.probeApiIngestResponse;
|
|
164
189
|
}
|
|
165
190
|
|
|
191
|
+
/**
|
|
192
|
+
* For metric-backed monitors (Metrics/Kubernetes/Docker) with
|
|
193
|
+
* per-series aggregated results, re-evaluate the matched criteria
|
|
194
|
+
* once per series and return one entry per series that breached.
|
|
195
|
+
* Returns an empty array when the monitor is not series-aware or
|
|
196
|
+
* no series matched — the caller falls back to the single-incident
|
|
197
|
+
* path in that case.
|
|
198
|
+
*/
|
|
199
|
+
private static collectPerSeriesMatches(input: {
|
|
200
|
+
dataToProcess: DataToProcess;
|
|
201
|
+
monitor: Monitor;
|
|
202
|
+
monitorStep: MonitorStep;
|
|
203
|
+
criteriaInstance: MonitorCriteriaInstance;
|
|
204
|
+
}): Array<PerSeriesCriteriaMatch> {
|
|
205
|
+
if (
|
|
206
|
+
input.monitor.monitorType !== MonitorType.Metrics &&
|
|
207
|
+
input.monitor.monitorType !== MonitorType.Kubernetes &&
|
|
208
|
+
input.monitor.monitorType !== MonitorType.Docker
|
|
209
|
+
) {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const metricResponse: MetricMonitorResponse =
|
|
214
|
+
input.dataToProcess as MetricMonitorResponse;
|
|
215
|
+
|
|
216
|
+
const seriesBreakdown: Array<MetricSeriesResult> | undefined =
|
|
217
|
+
metricResponse.seriesBreakdown;
|
|
218
|
+
|
|
219
|
+
if (!seriesBreakdown || seriesBreakdown.length === 0) {
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const criteriaId: string | undefined = input.criteriaInstance.data?.id;
|
|
224
|
+
if (!criteriaId) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const filterCondition: FilterCondition =
|
|
229
|
+
input.criteriaInstance.data?.filterCondition || FilterCondition.All;
|
|
230
|
+
|
|
231
|
+
const filters: Array<CriteriaFilter> =
|
|
232
|
+
input.criteriaInstance.data?.filters || [];
|
|
233
|
+
|
|
234
|
+
/*
|
|
235
|
+
* Evaluate every metric-value filter against every series. We only
|
|
236
|
+
* handle CheckOn.MetricValue for now — the criteria evaluator's
|
|
237
|
+
* other filter types don't carry series information.
|
|
238
|
+
*/
|
|
239
|
+
const metricFilters: Array<CriteriaFilter> = filters.filter(
|
|
240
|
+
(f: CriteriaFilter) => {
|
|
241
|
+
return f.checkOn === CheckOn.MetricValue;
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
if (metricFilters.length === 0) {
|
|
246
|
+
return [];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
* Key: fingerprint. Value: results of each metric filter for that
|
|
251
|
+
* series, tracked so we can apply FilterCondition.All/Any per series.
|
|
252
|
+
*/
|
|
253
|
+
const resultsByFingerprint: Map<
|
|
254
|
+
string,
|
|
255
|
+
{
|
|
256
|
+
labels: JSONObject;
|
|
257
|
+
filterResults: Array<MetricSeriesEvaluationResult>;
|
|
258
|
+
}
|
|
259
|
+
> = new Map();
|
|
260
|
+
|
|
261
|
+
for (const criteriaFilter of metricFilters) {
|
|
262
|
+
const evaluations: Array<MetricSeriesEvaluationResult> =
|
|
263
|
+
MetricMonitorCriteria.evaluateAllSeries({
|
|
264
|
+
dataToProcess: input.dataToProcess,
|
|
265
|
+
criteriaFilter,
|
|
266
|
+
monitorStep: input.monitorStep,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
for (const evaluation of evaluations) {
|
|
270
|
+
const fingerprint: string | undefined = evaluation.fingerprint;
|
|
271
|
+
if (!fingerprint) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const existing:
|
|
276
|
+
| {
|
|
277
|
+
labels: JSONObject;
|
|
278
|
+
filterResults: Array<MetricSeriesEvaluationResult>;
|
|
279
|
+
}
|
|
280
|
+
| undefined = resultsByFingerprint.get(fingerprint);
|
|
281
|
+
|
|
282
|
+
if (existing) {
|
|
283
|
+
existing.filterResults.push(evaluation);
|
|
284
|
+
} else {
|
|
285
|
+
resultsByFingerprint.set(fingerprint, {
|
|
286
|
+
labels: evaluation.labels,
|
|
287
|
+
filterResults: [evaluation],
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const matches: Array<PerSeriesCriteriaMatch> = [];
|
|
294
|
+
|
|
295
|
+
for (const [fingerprint, entry] of resultsByFingerprint) {
|
|
296
|
+
// Were all/any of the metric filters met for this series?
|
|
297
|
+
const matched: Array<MetricSeriesEvaluationResult> =
|
|
298
|
+
entry.filterResults.filter((r: MetricSeriesEvaluationResult) => {
|
|
299
|
+
return r.rootCause !== null;
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const seriesMatched: boolean =
|
|
303
|
+
filterCondition === FilterCondition.All
|
|
304
|
+
? matched.length === entry.filterResults.length &&
|
|
305
|
+
entry.filterResults.length > 0
|
|
306
|
+
: matched.length > 0;
|
|
307
|
+
|
|
308
|
+
if (!seriesMatched) {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/*
|
|
313
|
+
* For the per-series rootCause, concatenate the matched filter
|
|
314
|
+
* messages so the incident message reflects exactly what
|
|
315
|
+
* breached on this specific series.
|
|
316
|
+
*/
|
|
317
|
+
const rootCauseLines: Array<string> = matched.map(
|
|
318
|
+
(r: MetricSeriesEvaluationResult) => {
|
|
319
|
+
return `- ${r.rootCause}`;
|
|
320
|
+
},
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
matches.push({
|
|
324
|
+
criteriaMetId: criteriaId,
|
|
325
|
+
fingerprint,
|
|
326
|
+
labels: entry.labels,
|
|
327
|
+
rootCause: rootCauseLines.join("\n"),
|
|
328
|
+
metricContext: matched[0]?.context,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return matches;
|
|
333
|
+
}
|
|
334
|
+
|
|
166
335
|
private static async processMonitorCriteriaInstance(input: {
|
|
167
336
|
dataToProcess: DataToProcess;
|
|
168
337
|
monitorStep: MonitorStep;
|