@oneuptime/common 14.0.110 → 14.1.0
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/AIRunRecording.d.mts +12 -0
- package/Models/DatabaseModels/AIRunRecording.d.ts +12 -0
- package/Models/DatabaseModels/AIRunRecording.js +181 -0
- package/Models/DatabaseModels/AIRunRecording.mjs +2 -0
- package/Models/DatabaseModels/Alert.js +18 -2
- package/Models/DatabaseModels/DataStore.js +9 -0
- package/Models/DatabaseModels/EmailLog.js +2 -2
- package/Models/DatabaseModels/Form.js +3 -3
- package/Models/DatabaseModels/FormSubmission.js +4 -4
- package/Models/DatabaseModels/GlobalConfig.js +46 -45
- package/Models/DatabaseModels/Incident.js +18 -2
- package/Models/DatabaseModels/IncidentSlaRule.js +2 -2
- package/Models/DatabaseModels/Index.js +4 -0
- package/Models/DatabaseModels/InventoryItem.js +11 -0
- package/Models/DatabaseModels/Monitor.js +51 -17
- package/Models/DatabaseModels/MonitorNetworkDevice.d.mts +11 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.d.ts +11 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.js +189 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.mjs +2 -0
- package/Models/DatabaseModels/MonitorProbe.js +22 -5
- package/Models/DatabaseModels/NetworkDevice.js +23 -7
- package/Models/DatabaseModels/NetworkEndpoint.d.mts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.d.ts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.js +39 -7
- package/Models/DatabaseModels/NetworkInterface.js +5 -5
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +19 -5
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.mts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.ts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +35 -7
- package/Models/DatabaseModels/OpenStackCloudCheck.js +8 -1
- package/Models/DatabaseModels/Project.d.mts +1 -0
- package/Models/DatabaseModels/Project.d.ts +1 -0
- package/Models/DatabaseModels/Project.js +46 -3
- package/Models/DatabaseModels/ProjectCallSMSConfig.js +3 -1
- package/Models/DatabaseModels/ProjectSmtpConfig.js +2 -0
- package/Models/DatabaseModels/PublicNoteApprovalRequest.js +3 -3
- package/Models/DatabaseModels/PublicNoteApprovalStep.js +1 -1
- package/Models/DatabaseModels/RunbookExecution.js +2 -2
- package/Models/DatabaseModels/RunbookRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenance.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceCalendarFeed.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceLabelRule.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +7 -7
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerTeam.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerUser.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +5 -5
- package/Models/DatabaseModels/TeamMember.js +10 -1
- package/Models/DatabaseModels/WorkspaceNotificationRule.js +36 -1
- package/Models/DatabaseModels/WorkspaceNotificationSummary.js +1 -1
- package/Models/DatabaseModels/WorkspacePublicNoteApprovalMessage.js +3 -3
- package/Server/Services/DatabaseService.d.mts +4 -1
- package/Server/Services/DatabaseService.d.ts +4 -1
- package/Server/Types/Database/CountBy.d.mts +1 -0
- package/Server/Types/Database/CountBy.d.ts +1 -0
- package/Server/Types/Database/UpdateLimit.d.mts +6 -0
- package/Server/Types/Database/UpdateLimit.d.ts +6 -0
- package/Types/AI/AIActionWords.d.mts +25 -1
- package/Types/AI/AIActionWords.d.ts +25 -1
- package/Types/AI/AIActionWords.js +166 -3
- package/Types/AI/AIActionWords.mjs +6 -0
- package/Types/AI/AIChatTypes.d.mts +2 -1
- package/Types/AI/AIChatTypes.d.ts +2 -1
- package/Types/AI/AiOutcomes.d.mts +57 -0
- package/Types/AI/AiOutcomes.d.ts +57 -0
- package/Types/AI/AiOutcomes.js +67 -0
- package/Types/AI/AiOutcomes.mjs +10 -0
- package/Types/AI/AiRunRefusal.d.mts +45 -0
- package/Types/AI/AiRunRefusal.d.ts +45 -0
- package/Types/AI/AiRunRefusal.js +187 -0
- package/Types/AI/AiRunRefusal.mjs +12 -0
- package/Types/AI/InvestigationRecording.d.mts +46 -0
- package/Types/AI/InvestigationRecording.d.ts +46 -0
- package/Types/AI/InvestigationRecording.js +42 -0
- package/Types/AI/InvestigationRecording.mjs +7 -0
- package/Types/API/HTTPResponse.d.mts +3 -0
- package/Types/API/HTTPResponse.d.ts +3 -0
- package/Types/API/HTTPResponse.js +15 -0
- package/Types/BaseDatabase/AggregateBy.d.mts +16 -0
- package/Types/BaseDatabase/AggregateBy.d.ts +16 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +16 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +16 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.js +92 -2
- package/Types/BaseDatabase/ListResult.d.mts +1 -0
- package/Types/BaseDatabase/ListResult.d.ts +1 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.d.mts +47 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.d.ts +47 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.js +282 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.mjs +7 -0
- package/Types/Dashboard/DashboardAutoRefresh.d.mts +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.d.ts +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.js +21 -0
- package/Types/Dashboard/DashboardAutoRefresh.mjs +1 -0
- package/Types/Date.d.mts +6 -1
- package/Types/Date.d.ts +6 -1
- package/Types/Date.js +39 -7
- package/Types/Date.mjs +1 -0
- package/Types/Email/ServerEmailEnvironment.d.mts +85 -0
- package/Types/Email/ServerEmailEnvironment.d.ts +85 -0
- package/Types/Email/ServerEmailEnvironment.js +793 -0
- package/Types/Email/ServerEmailEnvironment.mjs +14 -0
- package/Types/Exception/AiRunRefusalException.d.mts +6 -0
- package/Types/Exception/AiRunRefusalException.d.ts +6 -0
- package/Types/Exception/AiRunRefusalException.js +23 -0
- package/Types/Exception/AiRunRefusalException.mjs +2 -0
- package/Types/Form/FormTargetCatalog.js +2 -2
- package/Types/Form/FormTargetType.js +2 -2
- package/Types/ListData.d.mts +2 -0
- package/Types/ListData.d.ts +2 -0
- package/Types/ListData.js +4 -0
- package/Types/Monitor/MonitorCriteriaInstance.js +9 -0
- package/Types/Monitor/MonitorNotCheckedReason.d.mts +7 -0
- package/Types/Monitor/MonitorNotCheckedReason.d.ts +7 -0
- package/Types/Monitor/MonitorNotCheckedReason.js +36 -0
- package/Types/Monitor/MonitorNotCheckedReason.mjs +4 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.d.mts +6 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.d.ts +6 -0
- package/Types/Monitor/UptimeHistoryLabels.js +2 -2
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.mts +1 -0
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.ts +1 -0
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.js +12 -9
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.mts +3 -1
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.ts +3 -1
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.js +24 -6
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.mts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.ts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.mts +12 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.ts +12 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.js +38 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.mjs +3 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.mts +92 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.ts +92 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.js +512 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.mjs +7 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.d.mts +23 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.d.ts +23 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.js +105 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.mjs +6 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.mts +64 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.ts +64 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.js +237 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.mjs +14 -0
- package/Types/Permission.js +2 -2
- package/Types/Probe/ProbeCapability.d.mts +2 -1
- package/Types/Probe/ProbeCapability.d.ts +2 -1
- package/Types/Probe/ProbeCapability.js +10 -0
- package/Types/ReaderLanguage.d.mts +1 -0
- package/Types/ReaderLanguage.d.ts +1 -0
- package/Types/ReaderLanguage.js +13 -1
- package/Types/ReaderLanguage.mjs +1 -0
- package/Types/Rules/RuleRun.js +2 -2
- package/Types/ScheduledMaintenance/MaintenanceCalendar.js +1 -1
- package/Types/ServerSending/ServerSendingStatus.d.mts +7 -0
- package/Types/ServerSending/ServerSendingStatus.d.ts +7 -0
- package/Types/ServerSending/ServerSendingStatus.js +49 -2
- package/Types/ServerSetup/ServerSetupChecklist.js +3 -3
- package/Types/StateTimeline/RowsKeptOnDelete.js +1 -1
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.mts +8 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.ts +8 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.js +50 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.mjs +3 -0
- package/Types/StatusPage/PublicNoteSubscriberNotificationDefault.js +1 -1
- package/Types/Telemetry/CompatibleIngest.d.mts +20 -0
- package/Types/Telemetry/CompatibleIngest.d.ts +20 -0
- package/Types/Telemetry/CompatibleIngest.js +123 -0
- package/Types/Telemetry/CompatibleIngest.mjs +21 -0
- package/Types/Telemetry/TelemetryIngestSurface.d.mts +5 -0
- package/Types/Telemetry/TelemetryIngestSurface.d.ts +5 -0
- package/Types/Telemetry/TelemetryIngestSurface.js +48 -7
- package/Types/TimezoneAlias.d.mts +1 -0
- package/Types/TimezoneAlias.d.ts +1 -0
- package/Types/TimezoneAlias.js +13 -0
- package/Types/Translator.js +374 -48
- package/Types/Workflow/RunRecord.js +1 -1
- package/Types/Workflow/Templates.js +2 -2
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.mts +2 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.ts +2 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +26 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +26 -1
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.mts +84 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.ts +84 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.js +456 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.mjs +5 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.mts +2 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.ts +2 -0
- package/Utils/Dashboard/ValueWidgetSeries.js +75 -0
- package/Utils/DeveloperDocs/ExampleBuilder.js +1 -1
- package/Utils/DeveloperDocs/ResourceProfiles.js +2 -2
- package/Utils/GuidedSetup/StatusPageRecords.d.mts +5 -0
- package/Utils/GuidedSetup/StatusPageRecords.d.ts +5 -0
- package/Utils/GuidedSetup/StatusPageRecords.js +27 -2
- package/Utils/GuidedSetup/StatusPageRecords.mjs +1 -0
- package/Utils/GuidedSetup/WebsiteMonitorRecords.js +6 -0
- package/Utils/HostAddressUtil.d.mts +1 -0
- package/Utils/HostAddressUtil.d.ts +1 -0
- package/Utils/HostAddressUtil.js +30 -0
- package/Utils/LinearRegExp/LinearRegExp.js +5 -1
- package/Utils/Milliseconds.d.mts +7 -0
- package/Utils/Milliseconds.d.ts +7 -0
- package/Utils/Milliseconds.js +60 -0
- package/Utils/Milliseconds.mjs +4 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.mts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.ts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.js +91 -21
- package/Utils/Monitor/EndpointAttachmentUtil.mjs +4 -0
- package/Utils/Monitor/InterfaceInventoryUtil.d.mts +40 -0
- package/Utils/Monitor/InterfaceInventoryUtil.d.ts +40 -0
- package/Utils/Monitor/InterfaceInventoryUtil.js +217 -5
- package/Utils/Monitor/InterfaceInventoryUtil.mjs +8 -0
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +63 -29
- package/Utils/Monitor/MonitorOverviewProbeUtil.js +13 -2
- package/Utils/Monitor/MonitorRootCauseWording.d.mts +2 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +2 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +58 -4
- package/Utils/Monitor/MonitoringOff.d.mts +2 -0
- package/Utils/Monitor/MonitoringOff.d.ts +2 -0
- package/Utils/Monitor/MonitoringOff.js +21 -0
- package/Utils/Monitor/NetworkTopologyUtil.d.mts +2 -1
- package/Utils/Monitor/NetworkTopologyUtil.d.ts +2 -1
- package/Utils/Monitor/NetworkTopologyUtil.js +10 -0
- package/Utils/Monitor/NotOperationalMonitorQuery.d.mts +2 -1
- package/Utils/Monitor/NotOperationalMonitorQuery.d.ts +2 -1
- package/Utils/Monitor/NotOperationalMonitorQuery.js +23 -4
- package/Utils/Monitor/ProbeFailureReading.d.mts +14 -0
- package/Utils/Monitor/ProbeFailureReading.d.ts +14 -0
- package/Utils/Monitor/ProbeFailureReading.js +137 -0
- package/Utils/Monitor/ProbeFailureReading.mjs +7 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.d.mts +9 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.d.ts +9 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.js +15 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.mjs +2 -0
- package/Utils/Project/NextNumber.js +1 -1
- package/Utils/PromQL/PromQLAst.d.mts +159 -0
- package/Utils/PromQL/PromQLAst.d.ts +159 -0
- package/Utils/PromQL/PromQLAst.js +118 -0
- package/Utils/PromQL/PromQLAst.mjs +12 -0
- package/Utils/PromQL/PromQLDuration.d.mts +2 -0
- package/Utils/PromQL/PromQLDuration.d.ts +2 -0
- package/Utils/PromQL/PromQLDuration.js +78 -0
- package/Utils/PromQL/PromQLDuration.mjs +3 -0
- package/Utils/PromQL/PromQLEngine.d.mts +15 -0
- package/Utils/PromQL/PromQLEngine.d.ts +15 -0
- package/Utils/PromQL/PromQLEngine.js +965 -0
- package/Utils/PromQL/PromQLEngine.mjs +7 -0
- package/Utils/PromQL/PromQLEngineTypes.d.mts +84 -0
- package/Utils/PromQL/PromQLEngineTypes.d.ts +84 -0
- package/Utils/PromQL/PromQLEngineTypes.js +10 -0
- package/Utils/PromQL/PromQLEngineTypes.mjs +2 -0
- package/Utils/PromQL/PromQLError.d.mts +11 -0
- package/Utils/PromQL/PromQLError.d.ts +11 -0
- package/Utils/PromQL/PromQLError.js +27 -0
- package/Utils/PromQL/PromQLError.mjs +3 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.d.mts +8 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.d.ts +8 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.js +773 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.mjs +3 -0
- package/Utils/PromQL/PromQLFunctions.d.mts +10 -0
- package/Utils/PromQL/PromQLFunctions.d.ts +10 -0
- package/Utils/PromQL/PromQLFunctions.js +127 -0
- package/Utils/PromQL/PromQLFunctions.mjs +4 -0
- package/Utils/PromQL/PromQLLabels.d.mts +11 -0
- package/Utils/PromQL/PromQLLabels.d.ts +11 -0
- package/Utils/PromQL/PromQLLabels.js +218 -0
- package/Utils/PromQL/PromQLLabels.mjs +9 -0
- package/Utils/PromQL/PromQLLexer.d.mts +39 -0
- package/Utils/PromQL/PromQLLexer.d.ts +39 -0
- package/Utils/PromQL/PromQLLexer.js +391 -0
- package/Utils/PromQL/PromQLLexer.mjs +3 -0
- package/Utils/PromQL/PromQLMath.d.mts +19 -0
- package/Utils/PromQL/PromQLMath.d.ts +19 -0
- package/Utils/PromQL/PromQLMath.js +200 -0
- package/Utils/PromQL/PromQLMath.mjs +9 -0
- package/Utils/PromQL/PromQLMetricNames.d.mts +21 -0
- package/Utils/PromQL/PromQLMetricNames.d.ts +21 -0
- package/Utils/PromQL/PromQLMetricNames.js +199 -0
- package/Utils/PromQL/PromQLMetricNames.mjs +8 -0
- package/Utils/PromQL/PromQLParser.d.mts +4 -0
- package/Utils/PromQL/PromQLParser.d.ts +4 -0
- package/Utils/PromQL/PromQLParser.js +831 -0
- package/Utils/PromQL/PromQLParser.mjs +4 -0
- package/Utils/PromQL/PromQLRegex.d.mts +9 -0
- package/Utils/PromQL/PromQLRegex.d.ts +9 -0
- package/Utils/PromQL/PromQLRegex.js +74 -0
- package/Utils/PromQL/PromQLRegex.mjs +2 -0
- package/Utils/PromQL/PrometheusResponse.d.mts +25 -0
- package/Utils/PromQL/PrometheusResponse.d.ts +25 -0
- package/Utils/PromQL/PrometheusResponse.js +90 -0
- package/Utils/PromQL/PrometheusResponse.mjs +3 -0
- package/Utils/Rum/PathInSentence.d.mts +5 -0
- package/Utils/Rum/PathInSentence.d.ts +5 -0
- package/Utils/Rum/PathInSentence.js +46 -0
- package/Utils/Rum/PathInSentence.mjs +6 -0
- package/Utils/Rum/UrlScrubber.d.mts +4 -0
- package/Utils/Rum/UrlScrubber.d.ts +4 -0
- package/Utils/Rum/UrlScrubber.js +143 -3
- package/Utils/Rum/UserFlow.d.mts +1 -1
- package/Utils/Rum/UserFlow.d.ts +1 -1
- package/Utils/Rum/UserFlow.js +180 -25
- package/Utils/Rum/UserFlow.mjs +1 -1
- package/Utils/Runbook/RunbookStepsSignature.d.mts +3 -0
- package/Utils/Runbook/RunbookStepsSignature.d.ts +3 -0
- package/Utils/Runbook/RunbookStepsSignature.js +30 -0
- package/Utils/Runbook/RunbookStepsSignature.mjs +3 -0
- package/Utils/Schema/TypeSchemas.js +6 -0
- package/Utils/Slo/SloDuration.d.mts +5 -2
- package/Utils/Slo/SloDuration.d.ts +5 -2
- package/Utils/Slo/SloDuration.js +11 -6
- package/Utils/Slo/SloHealth.js +1 -1
- package/Utils/StateOrder.js +1 -4
- package/Utils/StateTimeline/StateTimelineRowDelete.js +1 -1
- package/Utils/Telemetry/HeartbeatAvailability.d.mts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.d.ts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.js +118 -26
- package/Utils/Uptime/DayUptimeGraphUtil.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PROMQL_ORDERING_FUNCTIONS = exports.evaluatePromQLFunction = void 0;
|
|
37
|
+
const PromQLAst_1 = require("./PromQLAst");
|
|
38
|
+
const PromQLError_1 = __importStar(require("./PromQLError"));
|
|
39
|
+
const PromQLLabels_1 = require("./PromQLLabels");
|
|
40
|
+
const PromQLMath_1 = require("./PromQLMath");
|
|
41
|
+
const PromQLRegex_1 = require("./PromQLRegex");
|
|
42
|
+
const PatternCache_1 = require("../LinearRegExp/PatternCache");
|
|
43
|
+
const PatternProblem_1 = require("../LinearRegExp/PatternProblem");
|
|
44
|
+
const vectorValue = (samples) => {
|
|
45
|
+
return { type: PromQLAst_1.PromQLValueType.InstantVector, samples };
|
|
46
|
+
};
|
|
47
|
+
const scalarValue = (value) => {
|
|
48
|
+
return { type: PromQLAst_1.PromQLValueType.Scalar, value };
|
|
49
|
+
};
|
|
50
|
+
const readSamples = (value) => {
|
|
51
|
+
if (value.type !== PromQLAst_1.PromQLValueType.InstantVector) {
|
|
52
|
+
throw new PromQLError_1.default("An instant vector was expected here.", PromQLError_1.PromQLErrorType.Execution);
|
|
53
|
+
}
|
|
54
|
+
return value.samples;
|
|
55
|
+
};
|
|
56
|
+
const readRange = (value) => {
|
|
57
|
+
if (value.type !== PromQLAst_1.PromQLValueType.RangeVector) {
|
|
58
|
+
throw new PromQLError_1.default("A range vector was expected here.", PromQLError_1.PromQLErrorType.Execution);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
};
|
|
62
|
+
const readScalar = (value) => {
|
|
63
|
+
if (value.type !== PromQLAst_1.PromQLValueType.Scalar) {
|
|
64
|
+
throw new PromQLError_1.default("A number was expected here.", PromQLError_1.PromQLErrorType.Execution);
|
|
65
|
+
}
|
|
66
|
+
return value.value;
|
|
67
|
+
};
|
|
68
|
+
const readString = (value) => {
|
|
69
|
+
if (value.type !== PromQLAst_1.PromQLValueType.String) {
|
|
70
|
+
throw new PromQLError_1.default("A string was expected here.", PromQLError_1.PromQLErrorType.Execution);
|
|
71
|
+
}
|
|
72
|
+
return value.value;
|
|
73
|
+
};
|
|
74
|
+
// Applies `transform` to each value, dropping the metric name.
|
|
75
|
+
const mapValues = (samples, timestampMs, transform) => {
|
|
76
|
+
return samples.map((sample) => {
|
|
77
|
+
return {
|
|
78
|
+
labels: (0, PromQLLabels_1.dropMetricName)(sample.labels),
|
|
79
|
+
value: transform(sample.value),
|
|
80
|
+
timestampMs,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const SIMPLE_FUNCTIONS = {
|
|
85
|
+
abs: Math.abs,
|
|
86
|
+
acos: Math.acos,
|
|
87
|
+
acosh: Math.acosh,
|
|
88
|
+
asin: Math.asin,
|
|
89
|
+
asinh: Math.asinh,
|
|
90
|
+
atan: Math.atan,
|
|
91
|
+
atanh: Math.atanh,
|
|
92
|
+
ceil: Math.ceil,
|
|
93
|
+
cos: Math.cos,
|
|
94
|
+
cosh: Math.cosh,
|
|
95
|
+
deg: (value) => {
|
|
96
|
+
return (value * 180) / Math.PI;
|
|
97
|
+
},
|
|
98
|
+
exp: Math.exp,
|
|
99
|
+
floor: Math.floor,
|
|
100
|
+
ln: Math.log,
|
|
101
|
+
log10: Math.log10,
|
|
102
|
+
log2: Math.log2,
|
|
103
|
+
rad: (value) => {
|
|
104
|
+
return (value * Math.PI) / 180;
|
|
105
|
+
},
|
|
106
|
+
sgn: (value) => {
|
|
107
|
+
if (Number.isNaN(value)) {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
return value > 0 ? 1 : value < 0 ? -1 : value;
|
|
111
|
+
},
|
|
112
|
+
sin: Math.sin,
|
|
113
|
+
sinh: Math.sinh,
|
|
114
|
+
sqrt: Math.sqrt,
|
|
115
|
+
tan: Math.tan,
|
|
116
|
+
tanh: Math.tanh,
|
|
117
|
+
};
|
|
118
|
+
/*
|
|
119
|
+
* rate(), increase() and delta(): the change across the range, extrapolated
|
|
120
|
+
* to the range's edges the way Prometheus extrapolates it, with counter
|
|
121
|
+
* resets added back for the counter functions.
|
|
122
|
+
*/
|
|
123
|
+
const extrapolatedRate = (series, range, isCounter, isRate) => {
|
|
124
|
+
const count = series.values.length;
|
|
125
|
+
if (count < 2) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const firstTimestamp = series.timestampsMs[0];
|
|
129
|
+
const lastTimestamp = series.timestampsMs[count - 1];
|
|
130
|
+
const firstValue = series.values[0];
|
|
131
|
+
let result = series.values[count - 1] - firstValue;
|
|
132
|
+
if (isCounter) {
|
|
133
|
+
let previous = firstValue;
|
|
134
|
+
for (let index = 1; index < count; index++) {
|
|
135
|
+
const current = series.values[index];
|
|
136
|
+
if (current < previous) {
|
|
137
|
+
result += previous;
|
|
138
|
+
}
|
|
139
|
+
previous = current;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
let durationToStart = (firstTimestamp - range.rangeStartMs) / 1000;
|
|
143
|
+
let durationToEnd = (range.rangeEndMs - lastTimestamp) / 1000;
|
|
144
|
+
const sampledInterval = (lastTimestamp - firstTimestamp) / 1000;
|
|
145
|
+
const averageDurationBetweenSamples = sampledInterval / (count - 1);
|
|
146
|
+
const extrapolationThreshold = averageDurationBetweenSamples * 1.1;
|
|
147
|
+
if (durationToStart >= extrapolationThreshold) {
|
|
148
|
+
durationToStart = averageDurationBetweenSamples / 2;
|
|
149
|
+
}
|
|
150
|
+
// A counter is never negative: do not extrapolate past its zero.
|
|
151
|
+
if (isCounter && result > 0 && firstValue >= 0) {
|
|
152
|
+
const durationToZero = sampledInterval * (firstValue / result);
|
|
153
|
+
if (durationToZero < durationToStart) {
|
|
154
|
+
durationToStart = durationToZero;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (durationToEnd >= extrapolationThreshold) {
|
|
158
|
+
durationToEnd = averageDurationBetweenSamples / 2;
|
|
159
|
+
}
|
|
160
|
+
let factor = (sampledInterval + durationToStart + durationToEnd) / sampledInterval;
|
|
161
|
+
if (isRate) {
|
|
162
|
+
factor /= range.rangeMs / 1000;
|
|
163
|
+
}
|
|
164
|
+
return result * factor;
|
|
165
|
+
};
|
|
166
|
+
// irate() and idelta(): from the last two samples only.
|
|
167
|
+
const instantValue = (series, isRate) => {
|
|
168
|
+
const count = series.values.length;
|
|
169
|
+
if (count < 2) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
const last = series.values[count - 1];
|
|
173
|
+
const previous = series.values[count - 2];
|
|
174
|
+
const interval = series.timestampsMs[count - 1] - series.timestampsMs[count - 2];
|
|
175
|
+
if (interval === 0) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
// A counter reset: the counter restarted from zero.
|
|
179
|
+
const change = isRate && last < previous ? last : last - previous;
|
|
180
|
+
return isRate ? change / (interval / 1000) : change;
|
|
181
|
+
};
|
|
182
|
+
const valuesOf = (series) => {
|
|
183
|
+
return Array.from(series.values);
|
|
184
|
+
};
|
|
185
|
+
const populationVariance = (values) => {
|
|
186
|
+
let count = 0;
|
|
187
|
+
let mean = 0;
|
|
188
|
+
let squares = 0;
|
|
189
|
+
for (let index = 0; index < values.length; index++) {
|
|
190
|
+
const value = values[index];
|
|
191
|
+
count++;
|
|
192
|
+
const delta = value - mean;
|
|
193
|
+
mean += delta / count;
|
|
194
|
+
squares += delta * (value - mean);
|
|
195
|
+
}
|
|
196
|
+
return squares / count;
|
|
197
|
+
};
|
|
198
|
+
const average = (values) => {
|
|
199
|
+
const sum = { sum: 0, compensation: 0 };
|
|
200
|
+
for (let index = 0; index < values.length; index++) {
|
|
201
|
+
(0, PromQLMath_1.kahanAdd)(sum, values[index]);
|
|
202
|
+
}
|
|
203
|
+
return (0, PromQLMath_1.kahanResult)(sum) / values.length;
|
|
204
|
+
};
|
|
205
|
+
/*
|
|
206
|
+
* The functions that read a range vector and answer with one value per
|
|
207
|
+
* series. Undefined means "no value for this series at this step".
|
|
208
|
+
*/
|
|
209
|
+
const OVER_TIME = {
|
|
210
|
+
avg_over_time: (series) => {
|
|
211
|
+
return average(series.values);
|
|
212
|
+
},
|
|
213
|
+
count_over_time: (series) => {
|
|
214
|
+
return series.values.length;
|
|
215
|
+
},
|
|
216
|
+
last_over_time: (series) => {
|
|
217
|
+
return series.values[series.values.length - 1];
|
|
218
|
+
},
|
|
219
|
+
mad_over_time: (series) => {
|
|
220
|
+
const values = valuesOf(series);
|
|
221
|
+
const median = (0, PromQLMath_1.promQLQuantile)(0.5, values);
|
|
222
|
+
return (0, PromQLMath_1.promQLQuantile)(0.5, values.map((value) => {
|
|
223
|
+
return Math.abs(value - median);
|
|
224
|
+
}));
|
|
225
|
+
},
|
|
226
|
+
max_over_time: (series) => {
|
|
227
|
+
let max = series.values[0];
|
|
228
|
+
for (let index = 1; index < series.values.length; index++) {
|
|
229
|
+
const value = series.values[index];
|
|
230
|
+
if (value > max || Number.isNaN(max)) {
|
|
231
|
+
max = value;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return max;
|
|
235
|
+
},
|
|
236
|
+
min_over_time: (series) => {
|
|
237
|
+
let min = series.values[0];
|
|
238
|
+
for (let index = 1; index < series.values.length; index++) {
|
|
239
|
+
const value = series.values[index];
|
|
240
|
+
if (value < min || Number.isNaN(min)) {
|
|
241
|
+
min = value;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return min;
|
|
245
|
+
},
|
|
246
|
+
present_over_time: () => {
|
|
247
|
+
return 1;
|
|
248
|
+
},
|
|
249
|
+
stddev_over_time: (series) => {
|
|
250
|
+
return Math.sqrt(populationVariance(series.values));
|
|
251
|
+
},
|
|
252
|
+
stdvar_over_time: (series) => {
|
|
253
|
+
return populationVariance(series.values);
|
|
254
|
+
},
|
|
255
|
+
sum_over_time: (series) => {
|
|
256
|
+
const sum = { sum: 0, compensation: 0 };
|
|
257
|
+
for (let index = 0; index < series.values.length; index++) {
|
|
258
|
+
(0, PromQLMath_1.kahanAdd)(sum, series.values[index]);
|
|
259
|
+
}
|
|
260
|
+
return (0, PromQLMath_1.kahanResult)(sum);
|
|
261
|
+
},
|
|
262
|
+
changes: (series) => {
|
|
263
|
+
let changes = 0;
|
|
264
|
+
for (let index = 1; index < series.values.length; index++) {
|
|
265
|
+
const current = series.values[index];
|
|
266
|
+
const previous = series.values[index - 1];
|
|
267
|
+
if (current !== previous &&
|
|
268
|
+
!(Number.isNaN(current) && Number.isNaN(previous))) {
|
|
269
|
+
changes++;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return changes;
|
|
273
|
+
},
|
|
274
|
+
resets: (series) => {
|
|
275
|
+
let resets = 0;
|
|
276
|
+
for (let index = 1; index < series.values.length; index++) {
|
|
277
|
+
if (series.values[index] < series.values[index - 1]) {
|
|
278
|
+
resets++;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return resets;
|
|
282
|
+
},
|
|
283
|
+
deriv: (series) => {
|
|
284
|
+
if (series.values.length < 2) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return (0, PromQLMath_1.linearRegression)(series.timestampsMs, series.values, series.timestampsMs[0]).slope;
|
|
288
|
+
},
|
|
289
|
+
delta: (series, range) => {
|
|
290
|
+
return extrapolatedRate(series, range, false, false);
|
|
291
|
+
},
|
|
292
|
+
increase: (series, range) => {
|
|
293
|
+
return extrapolatedRate(series, range, true, false);
|
|
294
|
+
},
|
|
295
|
+
rate: (series, range) => {
|
|
296
|
+
return extrapolatedRate(series, range, true, true);
|
|
297
|
+
},
|
|
298
|
+
idelta: (series) => {
|
|
299
|
+
return instantValue(series, false);
|
|
300
|
+
},
|
|
301
|
+
irate: (series) => {
|
|
302
|
+
return instantValue(series, true);
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
// The functions whose answer keeps the input's metric name.
|
|
306
|
+
const KEEPS_METRIC_NAME = new Set([
|
|
307
|
+
"last_over_time",
|
|
308
|
+
]);
|
|
309
|
+
const DATE_FUNCTIONS = {
|
|
310
|
+
day_of_month: (date) => {
|
|
311
|
+
return date.getUTCDate();
|
|
312
|
+
},
|
|
313
|
+
day_of_week: (date) => {
|
|
314
|
+
return date.getUTCDay();
|
|
315
|
+
},
|
|
316
|
+
day_of_year: (date) => {
|
|
317
|
+
const startOfYear = Date.UTC(date.getUTCFullYear(), 0, 1);
|
|
318
|
+
return Math.floor((date.getTime() - startOfYear) / 86400000) + 1;
|
|
319
|
+
},
|
|
320
|
+
days_in_month: (date) => {
|
|
321
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)).getUTCDate();
|
|
322
|
+
},
|
|
323
|
+
hour: (date) => {
|
|
324
|
+
return date.getUTCHours();
|
|
325
|
+
},
|
|
326
|
+
minute: (date) => {
|
|
327
|
+
return date.getUTCMinutes();
|
|
328
|
+
},
|
|
329
|
+
month: (date) => {
|
|
330
|
+
return date.getUTCMonth() + 1;
|
|
331
|
+
},
|
|
332
|
+
year: (date) => {
|
|
333
|
+
return date.getUTCFullYear();
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
/*
|
|
337
|
+
* The labels absent() and absent_over_time() give their 1: the selector's
|
|
338
|
+
* equality matchers, as Prometheus derives them. A label matched for
|
|
339
|
+
* equality twice is left out, since no one value is right.
|
|
340
|
+
*/
|
|
341
|
+
const absentLabels = (expression) => {
|
|
342
|
+
let selectorMatchers = [];
|
|
343
|
+
if (expression.kind === PromQLAst_1.PromQLNodeKind.VectorSelector) {
|
|
344
|
+
selectorMatchers = expression.matchers;
|
|
345
|
+
}
|
|
346
|
+
else if (expression.kind === PromQLAst_1.PromQLNodeKind.MatrixSelector) {
|
|
347
|
+
selectorMatchers = expression.vectorSelector
|
|
348
|
+
.matchers;
|
|
349
|
+
}
|
|
350
|
+
const labels = {};
|
|
351
|
+
const repeated = new Set();
|
|
352
|
+
for (const matcher of selectorMatchers) {
|
|
353
|
+
if (matcher.type !== PromQLAst_1.PromQLMatchType.Equal ||
|
|
354
|
+
matcher.name === PromQLAst_1.PROMQL_METRIC_NAME_LABEL) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (labels[matcher.name] !== undefined) {
|
|
358
|
+
repeated.add(matcher.name);
|
|
359
|
+
}
|
|
360
|
+
labels[matcher.name] = matcher.value;
|
|
361
|
+
}
|
|
362
|
+
for (const name of repeated) {
|
|
363
|
+
delete labels[name];
|
|
364
|
+
}
|
|
365
|
+
for (const name of Object.keys(labels)) {
|
|
366
|
+
if (labels[name] === "") {
|
|
367
|
+
delete labels[name];
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return labels;
|
|
371
|
+
};
|
|
372
|
+
const TEMPLATE_NAME_CHARACTER_REGEX = /[A-Za-z0-9_]/;
|
|
373
|
+
const DIGITS_ONLY_REGEX = /^\d+$/;
|
|
374
|
+
/*
|
|
375
|
+
* Go's regexp.Expand: `$1`, `${1}`, `$name` and `${name}` become the group's
|
|
376
|
+
* text, `$$` a dollar sign. As in Go, `$1x` names the group "1x", which does
|
|
377
|
+
* not exist, so write `${1}x`.
|
|
378
|
+
*/
|
|
379
|
+
const expandTemplate = (template, match) => {
|
|
380
|
+
let result = "";
|
|
381
|
+
let index = 0;
|
|
382
|
+
while (index < template.length) {
|
|
383
|
+
const character = template[index];
|
|
384
|
+
if (character !== "$") {
|
|
385
|
+
result += character;
|
|
386
|
+
index++;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const next = template[index + 1] || "";
|
|
390
|
+
if (next === "$") {
|
|
391
|
+
result += "$";
|
|
392
|
+
index += 2;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
let name = "";
|
|
396
|
+
let end = index + 1;
|
|
397
|
+
if (next === "{") {
|
|
398
|
+
const close = template.indexOf("}", index + 2);
|
|
399
|
+
if (close === -1) {
|
|
400
|
+
result += character;
|
|
401
|
+
index++;
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
name = template.slice(index + 2, close);
|
|
405
|
+
end = close + 1;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
while (end < template.length &&
|
|
409
|
+
TEMPLATE_NAME_CHARACTER_REGEX.test(template[end])) {
|
|
410
|
+
end++;
|
|
411
|
+
}
|
|
412
|
+
name = template.slice(index + 1, end);
|
|
413
|
+
}
|
|
414
|
+
if (name.length === 0) {
|
|
415
|
+
result += character;
|
|
416
|
+
index++;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (DIGITS_ONLY_REGEX.test(name)) {
|
|
420
|
+
// $0 is the whole match, $1 the first group.
|
|
421
|
+
const group = Number(name);
|
|
422
|
+
result += (group === 0 ? match.value : match.captures[group - 1]) || "";
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
result += match.groups[name] || "";
|
|
426
|
+
}
|
|
427
|
+
index = end;
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
};
|
|
431
|
+
const sortSamples = (samples, descending) => {
|
|
432
|
+
return [...samples].sort((a, b) => {
|
|
433
|
+
// NaN goes last either way, as in Prometheus.
|
|
434
|
+
if (Number.isNaN(a.value)) {
|
|
435
|
+
return Number.isNaN(b.value) ? 0 : 1;
|
|
436
|
+
}
|
|
437
|
+
if (Number.isNaN(b.value)) {
|
|
438
|
+
return -1;
|
|
439
|
+
}
|
|
440
|
+
return descending ? b.value - a.value : a.value - b.value;
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
const naturalCompare = (a, b) => {
|
|
444
|
+
return a.localeCompare(b, "en", { numeric: true });
|
|
445
|
+
};
|
|
446
|
+
const evaluatePromQLFunction = (call, context) => {
|
|
447
|
+
const name = call.functionName;
|
|
448
|
+
const now = context.timestampMs;
|
|
449
|
+
const arg = (index) => {
|
|
450
|
+
return context.evaluate(call.args[index]);
|
|
451
|
+
};
|
|
452
|
+
const simple = SIMPLE_FUNCTIONS[name];
|
|
453
|
+
if (simple) {
|
|
454
|
+
return vectorValue(mapValues(readSamples(arg(0)), now, simple));
|
|
455
|
+
}
|
|
456
|
+
const overTime = OVER_TIME[name];
|
|
457
|
+
if (overTime) {
|
|
458
|
+
const range = readRange(arg(0));
|
|
459
|
+
const samples = [];
|
|
460
|
+
for (const series of range.series) {
|
|
461
|
+
if (series.values.length === 0) {
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
const value = overTime(series, range);
|
|
465
|
+
if (value !== undefined) {
|
|
466
|
+
samples.push({
|
|
467
|
+
labels: KEEPS_METRIC_NAME.has(name)
|
|
468
|
+
? series.labels
|
|
469
|
+
: (0, PromQLLabels_1.dropMetricName)(series.labels),
|
|
470
|
+
value,
|
|
471
|
+
timestampMs: now,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return vectorValue(samples);
|
|
476
|
+
}
|
|
477
|
+
const dateFunction = DATE_FUNCTIONS[name];
|
|
478
|
+
if (dateFunction) {
|
|
479
|
+
const samples = call.args.length === 0
|
|
480
|
+
? [{ labels: {}, value: now / 1000, timestampMs: now }]
|
|
481
|
+
: readSamples(arg(0));
|
|
482
|
+
return vectorValue(mapValues(samples, now, (value) => {
|
|
483
|
+
if (!Number.isFinite(value)) {
|
|
484
|
+
return NaN;
|
|
485
|
+
}
|
|
486
|
+
return dateFunction(new Date(value * 1000));
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
switch (name) {
|
|
490
|
+
case "time":
|
|
491
|
+
return scalarValue(now / 1000);
|
|
492
|
+
case "pi":
|
|
493
|
+
return scalarValue(Math.PI);
|
|
494
|
+
case "vector":
|
|
495
|
+
return vectorValue([
|
|
496
|
+
{ labels: {}, value: readScalar(arg(0)), timestampMs: now },
|
|
497
|
+
]);
|
|
498
|
+
case "scalar": {
|
|
499
|
+
const samples = readSamples(arg(0));
|
|
500
|
+
return scalarValue(samples.length === 1 ? samples[0].value : NaN);
|
|
501
|
+
}
|
|
502
|
+
case "timestamp":
|
|
503
|
+
return vectorValue(readSamples(arg(0)).map((sample) => {
|
|
504
|
+
return {
|
|
505
|
+
labels: (0, PromQLLabels_1.dropMetricName)(sample.labels),
|
|
506
|
+
value: sample.timestampMs / 1000,
|
|
507
|
+
timestampMs: now,
|
|
508
|
+
};
|
|
509
|
+
}));
|
|
510
|
+
case "absent": {
|
|
511
|
+
const samples = readSamples(arg(0));
|
|
512
|
+
if (samples.length > 0) {
|
|
513
|
+
return vectorValue([]);
|
|
514
|
+
}
|
|
515
|
+
return vectorValue([
|
|
516
|
+
{ labels: absentLabels(call.args[0]), value: 1, timestampMs: now },
|
|
517
|
+
]);
|
|
518
|
+
}
|
|
519
|
+
case "absent_over_time": {
|
|
520
|
+
const range = readRange(arg(0));
|
|
521
|
+
const hasSamples = range.series.some((series) => {
|
|
522
|
+
return series.values.length > 0;
|
|
523
|
+
});
|
|
524
|
+
if (hasSamples) {
|
|
525
|
+
return vectorValue([]);
|
|
526
|
+
}
|
|
527
|
+
return vectorValue([
|
|
528
|
+
{ labels: absentLabels(call.args[0]), value: 1, timestampMs: now },
|
|
529
|
+
]);
|
|
530
|
+
}
|
|
531
|
+
case "clamp": {
|
|
532
|
+
const samples = readSamples(arg(0));
|
|
533
|
+
const min = readScalar(arg(1));
|
|
534
|
+
const max = readScalar(arg(2));
|
|
535
|
+
if (max < min) {
|
|
536
|
+
return vectorValue([]);
|
|
537
|
+
}
|
|
538
|
+
return vectorValue(mapValues(samples, now, (value) => {
|
|
539
|
+
return Math.max(min, Math.min(max, value));
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
542
|
+
case "clamp_max": {
|
|
543
|
+
const max = readScalar(arg(1));
|
|
544
|
+
return vectorValue(mapValues(readSamples(arg(0)), now, (value) => {
|
|
545
|
+
return Math.min(max, value);
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
case "clamp_min": {
|
|
549
|
+
const min = readScalar(arg(1));
|
|
550
|
+
return vectorValue(mapValues(readSamples(arg(0)), now, (value) => {
|
|
551
|
+
return Math.max(min, value);
|
|
552
|
+
}));
|
|
553
|
+
}
|
|
554
|
+
case "round": {
|
|
555
|
+
const toNearest = call.args.length > 1 ? readScalar(arg(1)) : 1;
|
|
556
|
+
// Dividing by the inverse keeps 0.1-steps exact, as in Prometheus.
|
|
557
|
+
const inverse = 1 / toNearest;
|
|
558
|
+
return vectorValue(mapValues(readSamples(arg(0)), now, (value) => {
|
|
559
|
+
return Math.floor(value * inverse + 0.5) / inverse;
|
|
560
|
+
}));
|
|
561
|
+
}
|
|
562
|
+
case "quantile_over_time": {
|
|
563
|
+
const phi = readScalar(arg(0));
|
|
564
|
+
const range = readRange(arg(1));
|
|
565
|
+
const samples = [];
|
|
566
|
+
for (const series of range.series) {
|
|
567
|
+
if (series.values.length === 0) {
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
samples.push({
|
|
571
|
+
labels: (0, PromQLLabels_1.dropMetricName)(series.labels),
|
|
572
|
+
value: (0, PromQLMath_1.promQLQuantile)(phi, valuesOf(series)),
|
|
573
|
+
timestampMs: now,
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
return vectorValue(samples);
|
|
577
|
+
}
|
|
578
|
+
case "predict_linear": {
|
|
579
|
+
const range = readRange(arg(0));
|
|
580
|
+
const seconds = readScalar(arg(1));
|
|
581
|
+
const samples = [];
|
|
582
|
+
for (const series of range.series) {
|
|
583
|
+
if (series.values.length < 2) {
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
const line = (0, PromQLMath_1.linearRegression)(series.timestampsMs, series.values, now);
|
|
587
|
+
samples.push({
|
|
588
|
+
labels: (0, PromQLLabels_1.dropMetricName)(series.labels),
|
|
589
|
+
value: line.slope * seconds + line.intercept,
|
|
590
|
+
timestampMs: now,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
return vectorValue(samples);
|
|
594
|
+
}
|
|
595
|
+
case "holt_winters":
|
|
596
|
+
case "double_exponential_smoothing": {
|
|
597
|
+
const range = readRange(arg(0));
|
|
598
|
+
const smoothing = readScalar(arg(1));
|
|
599
|
+
const trend = readScalar(arg(2));
|
|
600
|
+
if (!(smoothing > 0 && smoothing < 1)) {
|
|
601
|
+
throw new PromQLError_1.default(`The smoothing factor of ${name}() must be between 0 and 1, but it is ${smoothing}.`, PromQLError_1.PromQLErrorType.Execution, call.position);
|
|
602
|
+
}
|
|
603
|
+
if (!(trend > 0 && trend < 1)) {
|
|
604
|
+
throw new PromQLError_1.default(`The trend factor of ${name}() must be between 0 and 1, but it is ${trend}.`, PromQLError_1.PromQLErrorType.Execution, call.position);
|
|
605
|
+
}
|
|
606
|
+
const samples = [];
|
|
607
|
+
for (const series of range.series) {
|
|
608
|
+
const count = series.values.length;
|
|
609
|
+
if (count < 2) {
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
let previousSmoothed = 0;
|
|
613
|
+
let smoothed = series.values[0];
|
|
614
|
+
let slope = series.values[1] - series.values[0];
|
|
615
|
+
for (let index = 1; index < count; index++) {
|
|
616
|
+
const scaled = smoothing * series.values[index];
|
|
617
|
+
if (index > 1) {
|
|
618
|
+
slope = trend * (smoothed - previousSmoothed) + (1 - trend) * slope;
|
|
619
|
+
}
|
|
620
|
+
const carried = (1 - smoothing) * (smoothed + slope);
|
|
621
|
+
previousSmoothed = smoothed;
|
|
622
|
+
smoothed = scaled + carried;
|
|
623
|
+
}
|
|
624
|
+
samples.push({
|
|
625
|
+
labels: (0, PromQLLabels_1.dropMetricName)(series.labels),
|
|
626
|
+
value: smoothed,
|
|
627
|
+
timestampMs: now,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
return vectorValue(samples);
|
|
631
|
+
}
|
|
632
|
+
case "histogram_quantile": {
|
|
633
|
+
const phi = readScalar(arg(0));
|
|
634
|
+
const groups = new Map();
|
|
635
|
+
for (const sample of readSamples(arg(1))) {
|
|
636
|
+
const le = sample.labels["le"];
|
|
637
|
+
if (le === undefined) {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
const upperBound = le === "+Inf" || le === "Inf" || le === "inf" ? Infinity : Number(le);
|
|
641
|
+
if (Number.isNaN(upperBound)) {
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
const groupLabels = Object.assign({}, sample.labels);
|
|
645
|
+
delete groupLabels["le"];
|
|
646
|
+
delete groupLabels[PromQLAst_1.PROMQL_METRIC_NAME_LABEL];
|
|
647
|
+
const key = (0, PromQLLabels_1.promQLLabelsKey)(groupLabels);
|
|
648
|
+
let group = groups.get(key);
|
|
649
|
+
if (!group) {
|
|
650
|
+
group = { labels: groupLabels, buckets: [] };
|
|
651
|
+
groups.set(key, group);
|
|
652
|
+
}
|
|
653
|
+
group.buckets.push({ upperBound, count: sample.value });
|
|
654
|
+
}
|
|
655
|
+
const samples = [];
|
|
656
|
+
for (const group of groups.values()) {
|
|
657
|
+
samples.push({
|
|
658
|
+
labels: group.labels,
|
|
659
|
+
value: (0, PromQLMath_1.bucketQuantile)(phi, group.buckets),
|
|
660
|
+
timestampMs: now,
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
return vectorValue(samples);
|
|
664
|
+
}
|
|
665
|
+
case "label_replace": {
|
|
666
|
+
const samples = readSamples(arg(0));
|
|
667
|
+
const destination = readString(arg(1));
|
|
668
|
+
const replacement = readString(arg(2));
|
|
669
|
+
const source = readString(arg(3));
|
|
670
|
+
const pattern = readString(arg(4));
|
|
671
|
+
let regex;
|
|
672
|
+
try {
|
|
673
|
+
// Compiled once for every series below, with what its groups capture.
|
|
674
|
+
regex = (0, PromQLRegex_1.compilePromQLRegex)(pattern, { captures: true }).regex;
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
// Why a regular expression cannot run here, or null.
|
|
678
|
+
const problem = (0, PatternCache_1.describePatternProblem)(error);
|
|
679
|
+
throw new PromQLError_1.default(problem === null
|
|
680
|
+
? `"${pattern}" in label_replace() is not a regular expression.`
|
|
681
|
+
: `The pattern "${pattern}" in label_replace() ${problem}`, PromQLError_1.PromQLErrorType.Execution, call.position);
|
|
682
|
+
}
|
|
683
|
+
if (destination.length === 0) {
|
|
684
|
+
throw new PromQLError_1.default("label_replace() needs a destination label name.", PromQLError_1.PromQLErrorType.Execution, call.position);
|
|
685
|
+
}
|
|
686
|
+
return vectorValue(samples.map((sample) => {
|
|
687
|
+
let match;
|
|
688
|
+
try {
|
|
689
|
+
match = regex.exec((0, PromQLLabels_1.promQLLabelValue)(sample.labels, source));
|
|
690
|
+
}
|
|
691
|
+
catch (error) {
|
|
692
|
+
if (error instanceof PatternProblem_1.PatternWorkLimitError) {
|
|
693
|
+
throw new PromQLError_1.default(`The pattern "${pattern}" in label_replace() needed more work to match a value of the label "${source}" than the value's length allows. Write a simpler pattern.`, PromQLError_1.PromQLErrorType.Execution, call.position);
|
|
694
|
+
}
|
|
695
|
+
throw error;
|
|
696
|
+
}
|
|
697
|
+
if (!match) {
|
|
698
|
+
return sample;
|
|
699
|
+
}
|
|
700
|
+
const labels = Object.assign({}, sample.labels);
|
|
701
|
+
const value = expandTemplate(replacement, match);
|
|
702
|
+
if (value.length === 0) {
|
|
703
|
+
delete labels[destination];
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
labels[destination] = value;
|
|
707
|
+
}
|
|
708
|
+
return Object.assign(Object.assign({}, sample), { labels });
|
|
709
|
+
}));
|
|
710
|
+
}
|
|
711
|
+
case "label_join": {
|
|
712
|
+
const samples = readSamples(arg(0));
|
|
713
|
+
const destination = readString(arg(1));
|
|
714
|
+
const separator = readString(arg(2));
|
|
715
|
+
const sources = call.args
|
|
716
|
+
.slice(3)
|
|
717
|
+
.map((_expression, index) => {
|
|
718
|
+
return readString(arg(index + 3));
|
|
719
|
+
});
|
|
720
|
+
if (destination.length === 0) {
|
|
721
|
+
throw new PromQLError_1.default("label_join() needs a destination label name.", PromQLError_1.PromQLErrorType.Execution, call.position);
|
|
722
|
+
}
|
|
723
|
+
return vectorValue(samples.map((sample) => {
|
|
724
|
+
const value = sources
|
|
725
|
+
.map((source) => {
|
|
726
|
+
return sample.labels[source] || "";
|
|
727
|
+
})
|
|
728
|
+
.join(separator);
|
|
729
|
+
const labels = Object.assign({}, sample.labels);
|
|
730
|
+
if (value.length === 0) {
|
|
731
|
+
delete labels[destination];
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
labels[destination] = value;
|
|
735
|
+
}
|
|
736
|
+
return Object.assign(Object.assign({}, sample), { labels });
|
|
737
|
+
}));
|
|
738
|
+
}
|
|
739
|
+
case "sort":
|
|
740
|
+
return vectorValue(sortSamples(readSamples(arg(0)), false));
|
|
741
|
+
case "sort_desc":
|
|
742
|
+
return vectorValue(sortSamples(readSamples(arg(0)), true));
|
|
743
|
+
case "sort_by_label":
|
|
744
|
+
case "sort_by_label_desc": {
|
|
745
|
+
const samples = readSamples(arg(0));
|
|
746
|
+
const labels = call.args
|
|
747
|
+
.slice(1)
|
|
748
|
+
.map((_expression, index) => {
|
|
749
|
+
return readString(arg(index + 1));
|
|
750
|
+
});
|
|
751
|
+
const direction = name === "sort_by_label_desc" ? -1 : 1;
|
|
752
|
+
return vectorValue([...samples].sort((a, b) => {
|
|
753
|
+
for (const label of labels) {
|
|
754
|
+
const order = naturalCompare(a.labels[label] || "", b.labels[label] || "");
|
|
755
|
+
if (order !== 0) {
|
|
756
|
+
return order * direction;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return 0;
|
|
760
|
+
}));
|
|
761
|
+
}
|
|
762
|
+
default:
|
|
763
|
+
throw new PromQLError_1.default(`Unknown function "${name}".`, PromQLError_1.PromQLErrorType.BadData, call.position);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
exports.evaluatePromQLFunction = evaluatePromQLFunction;
|
|
767
|
+
// Whether a call's answer keeps the order the function gives it.
|
|
768
|
+
exports.PROMQL_ORDERING_FUNCTIONS = new Set([
|
|
769
|
+
"sort",
|
|
770
|
+
"sort_desc",
|
|
771
|
+
"sort_by_label",
|
|
772
|
+
"sort_by_label_desc",
|
|
773
|
+
]);
|