@oneuptime/common 12.0.14 → 12.0.15
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/GlobalOidc.ts +20 -0
- package/Models/DatabaseModels/GlobalSso.ts +20 -0
- package/Models/DatabaseModels/MarketingConversion.ts +19 -9
- package/Models/DatabaseModels/NetworkDeviceLinkRule.ts +46 -0
- package/Models/DatabaseModels/StatusPage.ts +7 -4
- package/Server/API/StatusPageAPI.ts +29 -4
- package/Server/EnvironmentConfig.ts +7 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787800000000-AddScopeToNetworkDeviceLinkRule.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787900000000-AddRestrictToAttachedProjectsToGlobalSso.ts +40 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Middleware/SlackAuthorization.ts +43 -6
- package/Server/Middleware/UserAuthorization.ts +236 -26
- package/Server/Middleware/WhatsAppAuthorization.ts +43 -3
- package/Server/Services/GlobalOidcProjectService.ts +126 -1
- package/Server/Services/GlobalOidcService.ts +132 -0
- package/Server/Services/GlobalSsoProjectService.ts +126 -1
- package/Server/Services/GlobalSsoService.ts +132 -0
- package/Server/Services/UserEmailService.ts +4 -4
- package/Server/Utils/CronTab.ts +73 -0
- package/Server/Utils/GlobalSsoAuthorization.ts +175 -0
- package/Server/Utils/Marketing/ConversionUploadProvider.ts +35 -5
- package/Server/Utils/Marketing/Providers/GoogleAds.ts +1 -1
- package/Server/Utils/Marketing/Providers/LinkedIn.ts +1 -1
- package/Server/Utils/Marketing/Providers/Meta.ts +1 -1
- package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +1 -1
- package/Server/Utils/Marketing/Providers/Reddit.ts +1 -1
- package/Server/Utils/Monitor/Criteria/APIRequestCriteria.ts +48 -33
- package/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.ts +35 -30
- package/Server/Utils/Monitor/Criteria/DomainMonitorCriteria.ts +33 -28
- package/Server/Utils/Monitor/Criteria/EvaluateOverTime.ts +475 -47
- package/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.ts +35 -30
- package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +34 -28
- package/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.ts +33 -28
- package/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +69 -40
- package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +35 -29
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +8 -0
- package/Server/Utils/Monitor/MonitorResource.ts +161 -21
- package/Server/Utils/StatusPageContentSecurityPolicy.ts +56 -0
- package/Server/Utils/StatusPageCustomizationAccess.ts +117 -0
- package/Tests/Server/API/StatusPageCustomizationOrigin.test.ts +348 -0
- package/Tests/Server/Infrastructure/Postgres/FixTotpOtpUrlAlgorithmMigration.test.ts +9 -59
- package/Tests/Server/Infrastructure/Postgres/SchemaMigrationsOrdering.test.ts +227 -0
- package/Tests/Server/Middleware/SlackAuthorization.test.ts +149 -0
- package/Tests/Server/Middleware/UserAuthorization.test.ts +27 -13
- package/Tests/Server/Middleware/UserAuthorizationGlobalSsoGovernance.test.ts +1455 -0
- package/Tests/Server/Middleware/UserAuthorizationSSOProvider.test.ts +91 -2
- package/Tests/Server/Middleware/WhatsAppAuthorization.test.ts +233 -0
- package/Tests/Server/Services/DiscoveryScanClaimHookFreeSafety.test.ts +21 -8
- package/Tests/Server/Services/GlobalSsoProviderAuthorization.test.ts +1242 -0
- package/Tests/Server/Services/MonitorResourceProbeAgreementHydration.test.ts +459 -0
- package/Tests/Server/Services/MonitorResourceProbeAgreementReuse.test.ts +10 -0
- package/Tests/Server/Types/AnalyticsDatabase/AggregateUtilBucketTimestamp.test.ts +416 -0
- package/Tests/Server/Types/Database/QueryHelperManyToManyAndEmptyValues.test.ts +551 -0
- package/Tests/Server/Types/Database/SelectUtil.test.ts +348 -0
- package/Tests/Server/Utils/CronTab.test.ts +116 -0
- package/Tests/Server/Utils/GlobalSSOToken.test.ts +581 -0
- package/Tests/Server/Utils/GlobalSsoAuthorization.test.ts +1401 -0
- package/Tests/Server/Utils/Marketing/AdUploadableConversionTypes.test.ts +254 -0
- package/Tests/Server/Utils/Marketing/ConversionUploadProvider.test.ts +1 -1
- package/Tests/Server/Utils/Monitor/Criteria/APIRequestCriteriaEvaluateOverTime.test.ts +508 -0
- package/Tests/Server/Utils/Monitor/Criteria/APIRequestCriteriaPortTimings.test.ts +30 -9
- package/Tests/Server/Utils/Monitor/Criteria/EvaluateOverTime.test.ts +987 -0
- package/Tests/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.test.ts +916 -0
- package/Tests/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.test.ts +382 -0
- package/Tests/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.test.ts +1219 -0
- package/Tests/Server/Utils/Monitor/MonitorResourceIngestedStepSelection.test.ts +86 -0
- package/Tests/Server/Utils/StatusPageContentSecurityPolicy.test.ts +136 -0
- package/Tests/Server/Utils/StatusPageCustomizationAccess.test.ts +223 -0
- package/Tests/Types/Monitor/MonitorStepConfigHelpers.test.ts +165 -0
- package/Tests/Types/NetworkDevice/NetworkDeviceLinkRuleScope.test.ts +215 -0
- package/Tests/UI/Components/Forms/FormSubmitAnalytics.test.tsx +206 -0
- package/Tests/UI/Utils/AIChatExport/ConversationMarkdown.test.ts +774 -0
- package/Tests/UI/Utils/AIChatExport/MarkdownBlocks.test.ts +791 -0
- package/Tests/UI/Utils/AIChatExport/MarkdownSafety.test.ts +544 -0
- package/Tests/Utils/Analytics.test.ts +187 -0
- package/Tests/Utils/Monitor/MonitorMetricType.test.ts +80 -0
- package/Tests/Utils/Monitor/NetworkDeviceLinkRuleUtil.test.ts +1291 -0
- package/Tests/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.test.ts +214 -0
- package/Types/Marketing/MarketingConversion.ts +12 -0
- package/Types/Monitor/CriteriaFilter.ts +9 -0
- package/Types/NetworkDevice/NetworkDeviceLinkRuleScope.ts +51 -0
- package/UI/Components/FormModal/BasicFormModal.tsx +12 -0
- package/UI/Components/Forms/BasicForm.tsx +13 -1
- package/UI/Components/Forms/BasicModelForm.tsx +2 -1
- package/UI/Components/Forms/ModelForm.tsx +10 -1
- package/UI/Components/Forms/Utils/FormAnalyticsName.ts +39 -0
- package/UI/Components/ModelFormModal/ModelFormModal.tsx +6 -1
- package/Utils/Analytics.ts +55 -2
- package/Utils/Monitor/MonitorMetricType.ts +40 -0
- package/Utils/Monitor/NetworkDeviceLinkRuleUtil.ts +587 -37
- package/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.ts +115 -0
- package/build/dist/Models/DatabaseModels/GlobalOidc.js +21 -0
- package/build/dist/Models/DatabaseModels/GlobalOidc.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalSso.js +21 -0
- package/build/dist/Models/DatabaseModels/GlobalSso.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MarketingConversion.js +20 -10
- package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDeviceLinkRule.js +47 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceLinkRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +4 -4
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +25 -4
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +6 -0
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787800000000-AddScopeToNetworkDeviceLinkRule.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787800000000-AddScopeToNetworkDeviceLinkRule.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787900000000-AddRestrictToAttachedProjectsToGlobalSso.js +29 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787900000000-AddRestrictToAttachedProjectsToGlobalSso.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/Middleware/SlackAuthorization.js +28 -4
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/UserAuthorization.js +197 -22
- package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/WhatsAppAuthorization.js +32 -2
- package/build/dist/Server/Middleware/WhatsAppAuthorization.js.map +1 -1
- package/build/dist/Server/Services/GlobalOidcProjectService.js +105 -0
- package/build/dist/Server/Services/GlobalOidcProjectService.js.map +1 -1
- package/build/dist/Server/Services/GlobalOidcService.js +127 -0
- package/build/dist/Server/Services/GlobalOidcService.js.map +1 -1
- package/build/dist/Server/Services/GlobalSsoProjectService.js +105 -0
- package/build/dist/Server/Services/GlobalSsoProjectService.js.map +1 -1
- package/build/dist/Server/Services/GlobalSsoService.js +127 -0
- package/build/dist/Server/Services/GlobalSsoService.js.map +1 -1
- package/build/dist/Server/Services/UserEmailService.js +4 -4
- package/build/dist/Server/Utils/CronTab.js +66 -0
- package/build/dist/Server/Utils/CronTab.js.map +1 -1
- package/build/dist/Server/Utils/GlobalSsoAuthorization.js +112 -0
- package/build/dist/Server/Utils/GlobalSsoAuthorization.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +17 -1
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js +37 -35
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/DomainMonitorCriteria.js +20 -22
- package/build/dist/Server/Utils/Monitor/Criteria/DomainMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js +370 -42
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js +21 -25
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js +64 -52
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +25 -29
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +8 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +123 -23
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/StatusPageContentSecurityPolicy.js +39 -0
- package/build/dist/Server/Utils/StatusPageContentSecurityPolicy.js.map +1 -0
- package/build/dist/Server/Utils/StatusPageCustomizationAccess.js +85 -0
- package/build/dist/Server/Utils/StatusPageCustomizationAccess.js.map +1 -0
- package/build/dist/Types/Marketing/MarketingConversion.js +10 -0
- package/build/dist/Types/Marketing/MarketingConversion.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +1 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/NetworkDevice/NetworkDeviceLinkRuleScope.js +46 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceLinkRuleScope.js.map +1 -0
- package/build/dist/UI/Components/FormModal/BasicFormModal.js +2 -1
- package/build/dist/UI/Components/FormModal/BasicFormModal.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicForm.js +10 -1
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicModelForm.js +2 -1
- package/build/dist/UI/Components/Forms/BasicModelForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/ModelForm.js +4 -1
- package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/Utils/FormAnalyticsName.js +33 -0
- package/build/dist/UI/Components/Forms/Utils/FormAnalyticsName.js.map +1 -0
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js +2 -1
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js.map +1 -1
- package/build/dist/Utils/Analytics.js +50 -2
- package/build/dist/Utils/Analytics.js.map +1 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js +37 -0
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkDeviceLinkRuleUtil.js +318 -37
- package/build/dist/Utils/Monitor/NetworkDeviceLinkRuleUtil.js.map +1 -1
- package/build/dist/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.js +87 -0
- package/build/dist/Utils/NetworkDiscovery/UnclaimedScanDiagnosis.js.map +1 -0
- package/package.json +1 -1
|
@@ -9,59 +9,374 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { LIMIT_PER_PROJECT } from "../../../../Types/Database/LimitMax";
|
|
11
11
|
import OneUptimeDate from "../../../../Types/Date";
|
|
12
|
-
import { CheckOn, EvaluateOverTimeType, } from "../../../../Types/Monitor/CriteriaFilter";
|
|
12
|
+
import { CheckOn, EvaluateOverTimeType, NoDataPolicy, } from "../../../../Types/Monitor/CriteriaFilter";
|
|
13
13
|
import MonitorMetricTypeUtil from "../../../../Utils/Monitor/MonitorMetricType";
|
|
14
14
|
import MetricService from "../../../Services/MetricService";
|
|
15
15
|
import CaptureSpan from "../../Telemetry/CaptureSpan";
|
|
16
16
|
import InBetween from "../../../../Types/BaseDatabase/InBetween";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
import CronTab from "../../CronTab";
|
|
18
|
+
import logger from "../../Logger";
|
|
19
|
+
/**
|
|
20
|
+
* Outcome of trying to turn an "evaluate over time" filter into a value the
|
|
21
|
+
* comparators can act on.
|
|
22
|
+
*/
|
|
23
|
+
export var OverTimeEvaluationStatus;
|
|
24
|
+
(function (OverTimeEvaluationStatus) {
|
|
25
|
+
/** The filter is not configured to evaluate over time at all. */
|
|
26
|
+
OverTimeEvaluationStatus["NotConfigured"] = "NotConfigured";
|
|
27
|
+
/**
|
|
28
|
+
* No metric series backs this CheckOn, so there is nothing to look back
|
|
29
|
+
* over. Callers keep their historical behaviour (compare the value that
|
|
30
|
+
* arrived with this check) rather than silently never firing.
|
|
31
|
+
*/
|
|
32
|
+
OverTimeEvaluationStatus["Unsupported"] = "Unsupported";
|
|
33
|
+
/**
|
|
34
|
+
* The window is usable and `value` holds every sample in it (for
|
|
35
|
+
* All Values / Any Value) or the aggregate (for Average / Sum / Min / Max).
|
|
36
|
+
*/
|
|
37
|
+
OverTimeEvaluationStatus["Evaluated"] = "Evaluated";
|
|
38
|
+
/**
|
|
39
|
+
* The window is empty, still filling up, or could not be read. The filter
|
|
40
|
+
* cannot be judged yet — what happens next is up to the no-data policy.
|
|
41
|
+
*/
|
|
42
|
+
OverTimeEvaluationStatus["InsufficientData"] = "InsufficientData";
|
|
43
|
+
})(OverTimeEvaluationStatus || (OverTimeEvaluationStatus = {}));
|
|
44
|
+
class EvaluateOverTime {
|
|
45
|
+
/**
|
|
46
|
+
* Resolve an "evaluate over time" criteria filter into the value its
|
|
47
|
+
* comparator should use, applying the filter's no-data policy.
|
|
48
|
+
*
|
|
49
|
+
* This is the single entry point every monitor-type criteria evaluator
|
|
50
|
+
* uses. It exists so the "window has no usable data" decision is made in
|
|
51
|
+
* exactly one place: previously each evaluator did
|
|
52
|
+
* `overTimeValue || <value from this check>`, which quietly turned every
|
|
53
|
+
* over-time filter into an instantaneous one whenever the window came back
|
|
54
|
+
* empty.
|
|
55
|
+
*
|
|
56
|
+
* Deliberately not span-decorated: this runs for every criteria filter on
|
|
57
|
+
* every check and the vast majority return at the guard below without
|
|
58
|
+
* doing any work. evaluateOverTime, which issues the metric read, carries
|
|
59
|
+
* the span instead.
|
|
60
|
+
*/
|
|
61
|
+
static async getOverTimeValueForCriteriaFilter(data) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
/*
|
|
64
|
+
* Every criteria evaluator calls this for every filter, so the common
|
|
65
|
+
* case - a filter that does not evaluate over time - returns before any
|
|
66
|
+
* of the machinery below runs.
|
|
67
|
+
*/
|
|
68
|
+
if (!data.criteriaFilter.evaluateOverTime ||
|
|
69
|
+
!data.criteriaFilter.evaluateOverTimeOptions) {
|
|
70
|
+
return {
|
|
71
|
+
earlyReturn: null,
|
|
72
|
+
value: undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const evaluation = await this.evaluateOverTime({
|
|
24
76
|
projectId: data.projectId,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (data.miscData) {
|
|
30
|
-
query.attributes = data.miscData;
|
|
31
|
-
}
|
|
32
|
-
const monitorMetricsItems = await MetricService.findBy({
|
|
33
|
-
query: query,
|
|
34
|
-
limit: LIMIT_PER_PROJECT,
|
|
35
|
-
skip: 0,
|
|
36
|
-
props: {
|
|
37
|
-
isRoot: true,
|
|
38
|
-
},
|
|
39
|
-
select: {
|
|
40
|
-
value: true,
|
|
41
|
-
},
|
|
77
|
+
monitorId: data.monitorId,
|
|
78
|
+
criteriaFilter: data.criteriaFilter,
|
|
79
|
+
miscData: data.miscData,
|
|
80
|
+
monitoringInterval: data.monitoringInterval,
|
|
42
81
|
});
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
82
|
+
if (evaluation.status === OverTimeEvaluationStatus.NotConfigured ||
|
|
83
|
+
evaluation.status === OverTimeEvaluationStatus.Unsupported) {
|
|
84
|
+
// Historical behaviour: the caller compares this check's own value.
|
|
85
|
+
return {
|
|
86
|
+
earlyReturn: null,
|
|
87
|
+
value: undefined,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (evaluation.status === OverTimeEvaluationStatus.Evaluated) {
|
|
91
|
+
return {
|
|
92
|
+
earlyReturn: null,
|
|
93
|
+
value: evaluation.value,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// InsufficientData - the no-data policy decides.
|
|
97
|
+
const policy = evaluation.isReadError
|
|
98
|
+
? NoDataPolicy.Ignore
|
|
99
|
+
: ((_a = data.criteriaFilter.evaluateOverTimeOptions) === null || _a === void 0 ? void 0 : _a.onNoDataPolicy) ||
|
|
100
|
+
NoDataPolicy.Ignore;
|
|
101
|
+
if (policy === NoDataPolicy.Trigger) {
|
|
102
|
+
return {
|
|
103
|
+
earlyReturn: {
|
|
104
|
+
result: `${data.criteriaFilter.checkOn} has no data over the last ${(_b = data.criteriaFilter.evaluateOverTimeOptions) === null || _b === void 0 ? void 0 : _b.timeValueInMinutes} minutes. ${evaluation.noDataReason || ""}`.trim(),
|
|
105
|
+
},
|
|
106
|
+
value: undefined,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (policy === NoDataPolicy.TreatAsZero) {
|
|
110
|
+
/*
|
|
111
|
+
* Zero for numeric series, and its boolean equivalent (false) for the
|
|
112
|
+
* online/timeout series, which EvaluateOverTime already maps 1 -> true.
|
|
113
|
+
*/
|
|
114
|
+
const isBooleanSeries = data.criteriaFilter.checkOn === CheckOn.IsOnline ||
|
|
115
|
+
data.criteriaFilter.checkOn === CheckOn.IsRequestTimeout ||
|
|
116
|
+
data.criteriaFilter.checkOn === CheckOn.DnsIsOnline ||
|
|
117
|
+
data.criteriaFilter.checkOn === CheckOn.SnmpIsOnline ||
|
|
118
|
+
data.criteriaFilter.checkOn === CheckOn.ExternalStatusPageIsOnline;
|
|
119
|
+
return {
|
|
120
|
+
earlyReturn: null,
|
|
121
|
+
value: isBooleanSeries ? [false] : [0],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// NoDataPolicy.Ignore - the filter simply does not fire yet.
|
|
125
|
+
logger.debug(`Over time filter for ${data.criteriaFilter.checkOn} not evaluated: ${evaluation.noDataReason}`);
|
|
126
|
+
return {
|
|
127
|
+
earlyReturn: { result: null },
|
|
128
|
+
value: undefined,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Read the evaluation window and decide whether it can back the filter.
|
|
133
|
+
*/
|
|
134
|
+
static async evaluateOverTime(data) {
|
|
135
|
+
const evaluateOverTimeOptions = data.criteriaFilter.evaluateOverTimeOptions;
|
|
136
|
+
if (!data.criteriaFilter.evaluateOverTime || !evaluateOverTimeOptions) {
|
|
137
|
+
return {
|
|
138
|
+
status: OverTimeEvaluationStatus.NotConfigured,
|
|
139
|
+
value: undefined,
|
|
140
|
+
sampleCount: 0,
|
|
141
|
+
noDataReason: null,
|
|
142
|
+
isReadError: false,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const metricName = MonitorMetricTypeUtil.getMonitorMetricTypeByCheckOnOrNull(data.criteriaFilter.checkOn);
|
|
146
|
+
if (!metricName) {
|
|
147
|
+
/*
|
|
148
|
+
* Nothing writes a series for this CheckOn, so there is no history to
|
|
149
|
+
* look back over. Say so instead of throwing - the callers used to
|
|
150
|
+
* swallow that throw and silently compare the instantaneous value.
|
|
151
|
+
*/
|
|
152
|
+
return {
|
|
153
|
+
status: OverTimeEvaluationStatus.Unsupported,
|
|
154
|
+
value: undefined,
|
|
155
|
+
sampleCount: 0,
|
|
156
|
+
noDataReason: `${data.criteriaFilter.checkOn} is not recorded as a metric, so it cannot be evaluated over time.`,
|
|
157
|
+
isReadError: false,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/*
|
|
161
|
+
* The dashboard persists the dropdown's string value while Terraform and
|
|
162
|
+
* the API send a number, so coerce before doing arithmetic with it.
|
|
163
|
+
*/
|
|
164
|
+
const windowInMinutes = Number(evaluateOverTimeOptions.timeValueInMinutes) || 0;
|
|
165
|
+
if (windowInMinutes <= 0) {
|
|
166
|
+
return {
|
|
167
|
+
status: OverTimeEvaluationStatus.InsufficientData,
|
|
168
|
+
value: undefined,
|
|
169
|
+
sampleCount: 0,
|
|
170
|
+
noDataReason: "No evaluation window configured.",
|
|
171
|
+
isReadError: false,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const now = OneUptimeDate.getCurrentDate();
|
|
175
|
+
const windowStart = OneUptimeDate.getSomeMinutesAgo(windowInMinutes);
|
|
176
|
+
let metricItems = [];
|
|
177
|
+
try {
|
|
178
|
+
const query = {
|
|
179
|
+
projectId: data.projectId,
|
|
180
|
+
time: new InBetween(windowStart, now),
|
|
181
|
+
primaryEntityId: data.monitorId,
|
|
182
|
+
name: metricName,
|
|
183
|
+
};
|
|
184
|
+
if (data.miscData) {
|
|
185
|
+
query.attributes = data.miscData;
|
|
48
186
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
187
|
+
metricItems = await MetricService.findBy({
|
|
188
|
+
query: query,
|
|
189
|
+
limit: LIMIT_PER_PROJECT,
|
|
190
|
+
skip: 0,
|
|
191
|
+
props: {
|
|
192
|
+
isRoot: true,
|
|
193
|
+
},
|
|
194
|
+
select: {
|
|
195
|
+
value: true,
|
|
196
|
+
time: true,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
logger.error(`Error in getting over time value for ${data.criteriaFilter.checkOn}`);
|
|
202
|
+
logger.error(err);
|
|
203
|
+
return {
|
|
204
|
+
status: OverTimeEvaluationStatus.InsufficientData,
|
|
205
|
+
value: undefined,
|
|
206
|
+
sampleCount: 0,
|
|
207
|
+
noDataReason: "The metric store could not be read.",
|
|
208
|
+
isReadError: true,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const sampleTimes = [];
|
|
212
|
+
const values = [];
|
|
213
|
+
for (const item of metricItems) {
|
|
214
|
+
if (item.value === undefined || item.value === null) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (data.criteriaFilter.checkOn === CheckOn.IsOnline ||
|
|
218
|
+
data.criteriaFilter.checkOn === CheckOn.IsRequestTimeout ||
|
|
219
|
+
data.criteriaFilter.checkOn === CheckOn.DnsIsOnline ||
|
|
220
|
+
data.criteriaFilter.checkOn === CheckOn.SnmpIsOnline ||
|
|
221
|
+
data.criteriaFilter.checkOn === CheckOn.ExternalStatusPageIsOnline) {
|
|
222
|
+
values.push(item.value === 1);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
values.push(item.value);
|
|
226
|
+
}
|
|
227
|
+
if (item.time) {
|
|
228
|
+
sampleTimes.push(OneUptimeDate.fromString(item.time));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (values.length === 0) {
|
|
232
|
+
return {
|
|
233
|
+
status: OverTimeEvaluationStatus.InsufficientData,
|
|
234
|
+
value: undefined,
|
|
235
|
+
sampleCount: 0,
|
|
236
|
+
noDataReason: `No data was recorded for ${data.criteriaFilter.checkOn} in the last ${windowInMinutes} minutes.`,
|
|
237
|
+
isReadError: false,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/*
|
|
241
|
+
* "All Values" is the only evaluation type that claims something about
|
|
242
|
+
* the WHOLE window, so it is the only one that needs the whole window to
|
|
243
|
+
* be there. Array.every() is trivially true on a single sample, which is
|
|
244
|
+
* exactly how one bad probe used to satisfy
|
|
245
|
+
* "all values over the last 5 minutes".
|
|
246
|
+
*
|
|
247
|
+
* "Any Value" fires on a single breaching sample by design, and the
|
|
248
|
+
* aggregates (Average / Sum / Min / Max) are meaningful over a partial
|
|
249
|
+
* window, so they are left alone.
|
|
250
|
+
*/
|
|
251
|
+
if (evaluateOverTimeOptions.evaluateOverTimeType ===
|
|
252
|
+
EvaluateOverTimeType.AllValues) {
|
|
253
|
+
const isCovered = this.isWindowCovered({
|
|
254
|
+
windowStart: windowStart,
|
|
255
|
+
windowEnd: now,
|
|
256
|
+
sampleTimes: sampleTimes,
|
|
257
|
+
monitoringInterval: data.monitoringInterval,
|
|
258
|
+
});
|
|
259
|
+
if (!isCovered) {
|
|
260
|
+
return {
|
|
261
|
+
status: OverTimeEvaluationStatus.InsufficientData,
|
|
262
|
+
value: undefined,
|
|
263
|
+
sampleCount: values.length,
|
|
264
|
+
noDataReason: `Only ${values.length} data point(s) recorded so far - not enough to cover the last ${windowInMinutes} minutes.`,
|
|
265
|
+
isReadError: false,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (evaluateOverTimeOptions.evaluateOverTimeType ===
|
|
55
270
|
EvaluateOverTimeType.AnyValue ||
|
|
56
|
-
|
|
271
|
+
evaluateOverTimeOptions.evaluateOverTimeType ===
|
|
57
272
|
EvaluateOverTimeType.AllValues) {
|
|
58
273
|
// if its any or all then return the values. Otherwise compute the value based on the type
|
|
59
|
-
return
|
|
274
|
+
return {
|
|
275
|
+
status: OverTimeEvaluationStatus.Evaluated,
|
|
276
|
+
value: values,
|
|
277
|
+
sampleCount: values.length,
|
|
278
|
+
noDataReason: null,
|
|
279
|
+
isReadError: false,
|
|
280
|
+
};
|
|
60
281
|
}
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
282
|
+
return {
|
|
283
|
+
status: OverTimeEvaluationStatus.Evaluated,
|
|
284
|
+
value: this.getValueByEvaluationType({
|
|
285
|
+
values: values,
|
|
286
|
+
evaluateOverTimeType: evaluateOverTimeOptions.evaluateOverTimeType,
|
|
287
|
+
}),
|
|
288
|
+
sampleCount: values.length,
|
|
289
|
+
noDataReason: null,
|
|
290
|
+
isReadError: false,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Whether the samples actually reach back to the start of the window.
|
|
295
|
+
*
|
|
296
|
+
* A monitor that has only been running for a minute has one sample in a
|
|
297
|
+
* five minute window. That sample says nothing about the other four
|
|
298
|
+
* minutes, so "all values over the last 5 minutes" must not be considered
|
|
299
|
+
* satisfied by it.
|
|
300
|
+
*
|
|
301
|
+
* The check is expressed in time rather than in sample count so it is
|
|
302
|
+
* immune to a probe skipping a beat, to several probes writing into the
|
|
303
|
+
* same series, and to a sample landing a fraction of a second outside the
|
|
304
|
+
* window.
|
|
305
|
+
*/
|
|
306
|
+
static isWindowCovered(data) {
|
|
307
|
+
if (data.sampleTimes.length === 0) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
const sortedTimes = data.sampleTimes
|
|
311
|
+
.map((time) => {
|
|
312
|
+
return time.getTime();
|
|
313
|
+
})
|
|
314
|
+
.filter((time) => {
|
|
315
|
+
return !isNaN(time);
|
|
316
|
+
})
|
|
317
|
+
.sort((a, b) => {
|
|
318
|
+
return a - b;
|
|
64
319
|
});
|
|
320
|
+
if (sortedTimes.length === 0) {
|
|
321
|
+
/*
|
|
322
|
+
* Timestamps were unreadable. Fall back to requiring more than one
|
|
323
|
+
* sample so a brand new monitor still cannot satisfy the window off a
|
|
324
|
+
* single reading.
|
|
325
|
+
*/
|
|
326
|
+
return data.sampleTimes.length > 1;
|
|
327
|
+
}
|
|
328
|
+
const intervalInSeconds = this.getSamplingIntervalInSeconds({
|
|
329
|
+
monitoringInterval: data.monitoringInterval,
|
|
330
|
+
sortedSampleTimes: sortedTimes,
|
|
331
|
+
});
|
|
332
|
+
if (intervalInSeconds === null) {
|
|
333
|
+
/*
|
|
334
|
+
* A single sample and no configured interval - there is no way to tell
|
|
335
|
+
* whether the monitor is polled once an hour or once a second, so the
|
|
336
|
+
* window cannot be called covered.
|
|
337
|
+
*/
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
const oldestSampleMs = sortedTimes[0];
|
|
341
|
+
const newestSampleMs = sortedTimes[sortedTimes.length - 1];
|
|
342
|
+
const allowedGapMs = intervalInSeconds * 1000 * this.WINDOW_COVERAGE_TOLERANCE_FACTOR;
|
|
343
|
+
const leadingGapMs = oldestSampleMs - data.windowStart.getTime();
|
|
344
|
+
/*
|
|
345
|
+
* The trailing edge matters as much as the leading one: samples that
|
|
346
|
+
* stop part way through the window say nothing about the minutes since,
|
|
347
|
+
* so "all values over the last N minutes" must not be satisfied by
|
|
348
|
+
* stale data either.
|
|
349
|
+
*/
|
|
350
|
+
const trailingGapMs = data.windowEnd.getTime() - newestSampleMs;
|
|
351
|
+
return leadingGapMs <= allowedGapMs && trailingGapMs <= allowedGapMs;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* How far apart consecutive samples are expected to be, in seconds.
|
|
355
|
+
*
|
|
356
|
+
* The monitor's own schedule is authoritative when we have it. Otherwise
|
|
357
|
+
* infer it from the data: the widest gap actually observed between
|
|
358
|
+
* consecutive samples is the longest wait the window has demonstrated, so
|
|
359
|
+
* it is the safest estimate of the cadence.
|
|
360
|
+
*/
|
|
361
|
+
static getSamplingIntervalInSeconds(data) {
|
|
362
|
+
const configuredIntervalInSeconds = CronTab.getIntervalInSeconds(data.monitoringInterval);
|
|
363
|
+
if (configuredIntervalInSeconds !== null) {
|
|
364
|
+
return configuredIntervalInSeconds;
|
|
365
|
+
}
|
|
366
|
+
if (data.sortedSampleTimes.length < 2) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
let widestGapInSeconds = 0;
|
|
370
|
+
for (let i = 1; i < data.sortedSampleTimes.length; i++) {
|
|
371
|
+
const gapInSeconds = (data.sortedSampleTimes[i] - data.sortedSampleTimes[i - 1]) / 1000;
|
|
372
|
+
if (gapInSeconds > widestGapInSeconds) {
|
|
373
|
+
widestGapInSeconds = gapInSeconds;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (widestGapInSeconds <= 0) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
return widestGapInSeconds;
|
|
65
380
|
}
|
|
66
381
|
static getValueByEvaluationType(data) {
|
|
67
382
|
switch (data.evaluateOverTimeType) {
|
|
@@ -96,10 +411,23 @@ export default class EvaluateOverTime {
|
|
|
96
411
|
return this.getSum(values) / values.length;
|
|
97
412
|
}
|
|
98
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Multiple of the monitor's polling interval that either end of the window
|
|
416
|
+
* is allowed to sit away from the nearest sample before the window counts
|
|
417
|
+
* as "not covered yet".
|
|
418
|
+
*
|
|
419
|
+
* One whole interval is the theoretical minimum (a window that starts
|
|
420
|
+
* mid-cycle legitimately has its first sample up to one interval in). The
|
|
421
|
+
* extra half absorbs scheduling jitter - and the lag between a sample
|
|
422
|
+
* being written and being readable - so a monitor does not flip between
|
|
423
|
+
* "covered" and "not covered" on adjacent checks.
|
|
424
|
+
*/
|
|
425
|
+
EvaluateOverTime.WINDOW_COVERAGE_TOLERANCE_FACTOR = 1.5;
|
|
426
|
+
export default EvaluateOverTime;
|
|
99
427
|
__decorate([
|
|
100
428
|
CaptureSpan(),
|
|
101
429
|
__metadata("design:type", Function),
|
|
102
430
|
__metadata("design:paramtypes", [Object]),
|
|
103
431
|
__metadata("design:returntype", Promise)
|
|
104
|
-
], EvaluateOverTime, "
|
|
432
|
+
], EvaluateOverTime, "evaluateOverTime", null);
|
|
105
433
|
//# sourceMappingURL=EvaluateOverTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvaluateOverTime.js","sourceRoot":"","sources":["../../../../../../Server/Utils/Monitor/Criteria/EvaluateOverTime.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,aAAa,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"EvaluateOverTime.js","sourceRoot":"","sources":["../../../../../../Server/Utils/Monitor/Criteria/EvaluateOverTime.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,aAAa,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EACL,OAAO,EAGP,oBAAoB,EACpB,YAAY,GACb,MAAM,0CAA0C,CAAC;AAGlD,OAAO,qBAAqB,MAAM,6CAA6C,CAAC;AAEhF,OAAO,aAAa,MAAM,iCAAiC,CAAC;AAC5D,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,SAAS,MAAM,0CAA0C,CAAC;AACjE,OAAO,OAAO,MAAM,eAAe,C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EO,MAAM,CAAC,MAAM,CAAC,MAAgB;QACpC,wBAAwB;QACxB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;YAC5C,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEO,MAAM,CAAC,MAAM,CAAC,MAAgB;QACpC,gBAAgB;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEO,MAAM,CAAC,MAAM,CAAC,MAAgB;QACpC,gBAAgB;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,MAAgB;QACxC,oBAAoB;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,CAAC;;AAheD;;;;;;;;;;GAUG;AACqB,iDAAgC,GAAW,GAAG,CAAC;eAZpD,gBAAgB;AAgIf;IADnB,WAAW,EAAE;;;;8CAqMb"}
|
|
@@ -11,36 +11,33 @@ import CompareCriteria from "./CompareCriteria";
|
|
|
11
11
|
import { CheckOn, } from "../../../../Types/Monitor/CriteriaFilter";
|
|
12
12
|
import EvaluateOverTime from "./EvaluateOverTime";
|
|
13
13
|
import CaptureSpan from "../../Telemetry/CaptureSpan";
|
|
14
|
-
import logger from "../../Logger";
|
|
15
14
|
export default class ExternalStatusPageMonitorCriteria {
|
|
16
15
|
static async isMonitorInstanceCriteriaFilterMet(input) {
|
|
16
|
+
var _a, _b;
|
|
17
17
|
let threshold = input.criteriaFilter.value;
|
|
18
18
|
const dataToProcess = input.dataToProcess;
|
|
19
19
|
const externalStatusPageResponse = dataToProcess.externalStatusPageResponse;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
input.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
logger.error(err);
|
|
37
|
-
overTimeValue = undefined;
|
|
38
|
-
}
|
|
20
|
+
const overTime = await EvaluateOverTime.getOverTimeValueForCriteriaFilter({
|
|
21
|
+
projectId: input.dataToProcess.projectId,
|
|
22
|
+
monitorId: input.dataToProcess.monitorId,
|
|
23
|
+
criteriaFilter: input.criteriaFilter,
|
|
24
|
+
monitoringInterval: input.monitoringInterval,
|
|
25
|
+
});
|
|
26
|
+
/*
|
|
27
|
+
* The window could not back this over-time filter (nothing recorded yet,
|
|
28
|
+
* or the monitor has not been running long enough to cover it). Return
|
|
29
|
+
* the decision the no-data policy already made instead of falling
|
|
30
|
+
* through to the value that arrived with this one check - that fallback
|
|
31
|
+
* is what let "all values over the last N minutes" fire off a single
|
|
32
|
+
* bad reading.
|
|
33
|
+
*/
|
|
34
|
+
if (overTime.earlyReturn) {
|
|
35
|
+
return overTime.earlyReturn.result;
|
|
39
36
|
}
|
|
37
|
+
const overTimeValue = overTime.value;
|
|
40
38
|
// Check if external status page is online
|
|
41
39
|
if (input.criteriaFilter.checkOn === CheckOn.ExternalStatusPageIsOnline) {
|
|
42
|
-
const currentIsOnline = overTimeValue
|
|
43
|
-
input.dataToProcess.isOnline;
|
|
40
|
+
const currentIsOnline = (_a = overTimeValue) !== null && _a !== void 0 ? _a : input.dataToProcess.isOnline;
|
|
44
41
|
return CompareCriteria.compareCriteriaBoolean({
|
|
45
42
|
value: currentIsOnline,
|
|
46
43
|
criteriaFilter: input.criteriaFilter,
|
|
@@ -52,9 +49,8 @@ export default class ExternalStatusPageMonitorCriteria {
|
|
|
52
49
|
if (threshold === null || threshold === undefined) {
|
|
53
50
|
return null;
|
|
54
51
|
}
|
|
55
|
-
const currentResponseTime = overTimeValue ||
|
|
56
|
-
|
|
57
|
-
input.dataToProcess.responseTimeInMs;
|
|
52
|
+
const currentResponseTime = (_b = overTimeValue) !== null && _b !== void 0 ? _b : ((externalStatusPageResponse === null || externalStatusPageResponse === void 0 ? void 0 : externalStatusPageResponse.responseTimeInMs) ||
|
|
53
|
+
input.dataToProcess.responseTimeInMs);
|
|
58
54
|
if (currentResponseTime === null || currentResponseTime === undefined) {
|
|
59
55
|
return null;
|
|
60
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalStatusPageMonitorCriteria.js","sourceRoot":"","sources":["../../../../../../Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,OAAO,GAER,MAAM,0CAA0C,CAAC;AAGlD,OAAO,
|
|
1
|
+
{"version":3,"file":"ExternalStatusPageMonitorCriteria.js","sourceRoot":"","sources":["../../../../../../Server/Utils/Monitor/Criteria/ExternalStatusPageMonitorCriteria.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,OAAO,GAER,MAAM,0CAA0C,CAAC;AAGlD,OAAO,gBAA2C,MAAM,oBAAoB,CAAC;AAC7E,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,iCAAiC;IAEhC,AAAb,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,KAUtD;;QACC,IAAI,SAAS,GACX,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;QAE7B,MAAM,aAAa,GACjB,KAAK,CAAC,aAAqC,CAAC;QAE9C,MAAM,0BAA0B,GAEhB,aAAa,CAAC,0BAA0B,CAAC;QAEzD,MAAM,QAAQ,GACZ,MAAM,gBAAgB,CAAC,iCAAiC,CAAC;YACvD,SAAS,EAAG,KAAK,CAAC,aAAsC,CAAC,SAAS;YAClE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,SAA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AiC,EAC1E,CAAC;YACD,SAAS,GAAG,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAEvD,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAClD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,eAAe,GACnB,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,mBAAmB,KAAI,CAAC,CAAC;YAEvD,OAAO,eAAe,CAAC,sBAAsB,CAAC;gBAC5C,KAAK,EAAE,eAAe;gBACtB,SAAS,EAAE,SAAmB;gBAC9B,cAAc,EAAE,KAAK,CAAC,cAAc;aACrC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArJqB;IADnB,WAAW,EAAE;;;;iFAqJb"}
|
|
@@ -17,35 +17,32 @@ import CaptureSpan from "../../Telemetry/CaptureSpan";
|
|
|
17
17
|
export default class IncomingRequestCriteria {
|
|
18
18
|
static async isMonitorInstanceCriteriaFilterMet(input) {
|
|
19
19
|
// Server Monitoring Checks
|
|
20
|
-
var _a;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
logger.debug("Checking IncomingRequestCriteria for Monitor: " +
|
|
22
22
|
input.dataToProcess.monitorId.toString());
|
|
23
23
|
logger.debug("Data to process: " + JSON.stringify(input.dataToProcess, null, 2));
|
|
24
24
|
logger.debug("Criteria Filter: " + JSON.stringify(input.criteriaFilter, null, 2));
|
|
25
25
|
let value = input.criteriaFilter.value;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
input.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
logger.error(err);
|
|
43
|
-
overTimeValue = undefined;
|
|
44
|
-
}
|
|
26
|
+
const overTime = await EvaluateOverTime.getOverTimeValueForCriteriaFilter({
|
|
27
|
+
projectId: input.dataToProcess.projectId,
|
|
28
|
+
monitorId: input.dataToProcess.monitorId,
|
|
29
|
+
criteriaFilter: input.criteriaFilter,
|
|
30
|
+
monitoringInterval: input.monitoringInterval,
|
|
31
|
+
});
|
|
32
|
+
/*
|
|
33
|
+
* The window could not back this over-time filter (nothing recorded yet,
|
|
34
|
+
* or the monitor has not been running long enough to cover it). Return
|
|
35
|
+
* the decision the no-data policy already made instead of falling
|
|
36
|
+
* through to the value that arrived with this one check - that fallback
|
|
37
|
+
* is what let "all values over the last N minutes" fire off a single
|
|
38
|
+
* bad reading.
|
|
39
|
+
*/
|
|
40
|
+
if (overTime.earlyReturn) {
|
|
41
|
+
return overTime.earlyReturn.result;
|
|
45
42
|
}
|
|
43
|
+
const overTimeValue = overTime.value;
|
|
46
44
|
if (input.criteriaFilter.checkOn === CheckOn.IsOnline) {
|
|
47
|
-
const currentIsOnline = overTimeValue
|
|
48
|
-
input.dataToProcess.isOnline;
|
|
45
|
+
const currentIsOnline = (_a = overTimeValue) !== null && _a !== void 0 ? _a : input.dataToProcess.isOnline;
|
|
49
46
|
return CompareCriteria.compareCriteriaBoolean({
|
|
50
47
|
value: currentIsOnline,
|
|
51
48
|
criteriaFilter: input.criteriaFilter,
|
|
@@ -53,8 +50,7 @@ export default class IncomingRequestCriteria {
|
|
|
53
50
|
}
|
|
54
51
|
// timeout.
|
|
55
52
|
if (input.criteriaFilter.checkOn === CheckOn.IsRequestTimeout) {
|
|
56
|
-
const currentIsTimeout = overTimeValue
|
|
57
|
-
input.dataToProcess.isTimeout;
|
|
53
|
+
const currentIsTimeout = (_b = overTimeValue) !== null && _b !== void 0 ? _b : input.dataToProcess.isTimeout;
|
|
58
54
|
return CompareCriteria.compareCriteriaBoolean({
|
|
59
55
|
value: currentIsTimeout,
|
|
60
56
|
criteriaFilter: input.criteriaFilter,
|
|
@@ -66,7 +62,7 @@ export default class IncomingRequestCriteria {
|
|
|
66
62
|
input.dataToProcess.monitorId.toString());
|
|
67
63
|
const lastCheckTime = input.dataToProcess.incomingRequestReceivedAt;
|
|
68
64
|
logger.debug("Last Check Time: " + lastCheckTime);
|
|
69
|
-
const differenceInMinutes = OneUptimeDate.getDifferenceInMinutes(lastCheckTime, ((
|
|
65
|
+
const differenceInMinutes = OneUptimeDate.getDifferenceInMinutes(lastCheckTime, ((_c = input.dataToProcess) === null || _c === void 0 ? void 0 : _c.checkedAt) ||
|
|
70
66
|
OneUptimeDate.getCurrentDate());
|
|
71
67
|
logger.debug("Difference in minutes: " + differenceInMinutes);
|
|
72
68
|
if (!value) {
|