@oneuptime/common 12.0.15 → 12.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/Index.ts +10 -0
- package/Models/AnalyticsModels/LogCountBaseline.ts +174 -0
- package/Models/AnalyticsModels/SecurityEvent.ts +794 -0
- package/Models/AnalyticsModels/Span.ts +29 -1
- package/Models/AnalyticsModels/SpanCountBaseline.ts +198 -0
- package/Models/DatabaseModels/Alert.ts +42 -0
- package/Models/DatabaseModels/AlertMeasurement.ts +1114 -0
- package/Models/DatabaseModels/AlertMeasurementValue.ts +501 -0
- package/Models/DatabaseModels/AlertStateTimeline.ts +10 -2
- package/Models/DatabaseModels/BillingPaymentMethod.ts +8 -10
- package/Models/DatabaseModels/DetectionRule.ts +487 -0
- package/Models/DatabaseModels/GoogleSecOpsConnection.ts +382 -0
- package/Models/DatabaseModels/Incident.ts +42 -0
- package/Models/DatabaseModels/IncidentMeasurement.ts +1114 -0
- package/Models/DatabaseModels/IncidentMeasurementValue.ts +501 -0
- package/Models/DatabaseModels/IncidentStateTimeline.ts +10 -2
- package/Models/DatabaseModels/IncomingCallPolicyLabelRule.ts +36 -0
- package/Models/DatabaseModels/IncomingCallPolicyOwnerRule.ts +42 -0
- package/Models/DatabaseModels/Index.ts +20 -0
- package/Models/DatabaseModels/Label.ts +11 -0
- package/Models/DatabaseModels/LlmCostBudget.ts +655 -0
- package/Models/DatabaseModels/LlmModelPrice.ts +481 -0
- package/Models/DatabaseModels/LogSavedView.ts +87 -0
- package/Models/DatabaseModels/MarketingConversion.ts +210 -8
- package/Models/DatabaseModels/MetricSavedView.ts +59 -0
- package/Models/DatabaseModels/OnCallDutyPolicyLabelRule.ts +36 -0
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerRule.ts +42 -0
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLabelRule.ts +36 -0
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleOwnerRule.ts +42 -0
- package/Models/DatabaseModels/Probe.ts +21 -0
- package/Models/DatabaseModels/RunbookLabelRule.ts +36 -0
- package/Models/DatabaseModels/RunbookOwnerRule.ts +42 -0
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.ts +1104 -0
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.ts +491 -0
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.ts +10 -2
- package/Models/DatabaseModels/StatusPageLabelRule.ts +36 -0
- package/Models/DatabaseModels/StatusPageOwnerRule.ts +42 -0
- package/Models/DatabaseModels/TableView.ts +15 -0
- package/Models/DatabaseModels/Team.ts +13 -0
- package/Models/DatabaseModels/TeamMember.ts +8 -0
- package/Models/DatabaseModels/TraceSavedView.ts +52 -0
- package/Models/DatabaseModels/WorkflowLabelRule.ts +36 -0
- package/Models/DatabaseModels/WorkflowOwnerRule.ts +42 -0
- package/Server/API/TelemetryAPI.ts +252 -6
- package/Server/API/UserAPI.ts +88 -0
- package/Server/EnvironmentConfig.ts +36 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788000000000-AddDetectionRuleAndGoogleSecOpsConnection.ts +88 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788100000000-AddMeasurements.ts +457 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788200000000-AddLlmCostBudget.ts +97 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788300000000-AddLlmModelPrice.ts +45 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788400000000-AddMarketingConversionAttribution.ts +105 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788500000000-RemoveLlmCostBudgetAlertColumns.ts +77 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +12 -0
- package/Server/Middleware/IdentityRateLimit.ts +672 -0
- package/Server/Services/AccessTokenService.ts +15 -2
- package/Server/Services/AlertMeasurementService.ts +302 -0
- package/Server/Services/AlertMeasurementValueService.ts +508 -0
- package/Server/Services/AlertService.ts +50 -0
- package/Server/Services/AlertStateTimelineService.ts +54 -0
- package/Server/Services/DetectionRuleService.ts +74 -0
- package/Server/Services/GoogleSecOpsConnectionService.ts +89 -0
- package/Server/Services/IncidentMeasurementService.ts +304 -0
- package/Server/Services/IncidentMeasurementValueService.ts +523 -0
- package/Server/Services/IncidentService.ts +51 -0
- package/Server/Services/IncidentStateTimelineService.ts +54 -0
- package/Server/Services/Index.ts +30 -0
- package/Server/Services/LlmCostBudgetService.ts +93 -0
- package/Server/Services/LlmModelPriceService.ts +202 -0
- package/Server/Services/LogAggregationService.ts +1106 -2
- package/Server/Services/LogCountBaselineService.ts +163 -0
- package/Server/Services/MutableMetricService.ts +30 -9
- package/Server/Services/ScheduledMaintenanceMeasurementService.ts +311 -0
- package/Server/Services/ScheduledMaintenanceMeasurementValueService.ts +546 -0
- package/Server/Services/ScheduledMaintenanceService.ts +53 -0
- package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +188 -1
- package/Server/Services/SecurityEventService.ts +104 -0
- package/Server/Services/SpanCountBaselineService.ts +173 -0
- package/Server/Services/StatusPageService.ts +4 -3
- package/Server/Services/TelemetryUsageBillingService.ts +17 -2
- package/Server/Services/UserService.ts +284 -51
- package/Server/Services/UserTotpAuthService.ts +27 -86
- package/Server/Services/UserWebAuthnService.ts +26 -86
- package/Server/Types/Billing/MeteredPlan/AllMeteredPlans.ts +14 -0
- package/Server/Types/Database/Permissions/TenantPermission.ts +10 -0
- package/Server/Types/Database/QueryHelper.ts +1 -1
- package/Server/Utils/AI/Chat/ObservabilityChatPrompt.ts +1 -1
- package/Server/Utils/AI/Toolbox/Index.ts +6 -0
- package/Server/Utils/AI/Toolbox/SecurityEventTools.ts +349 -0
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +13 -4
- package/Server/Utils/Attribution.ts +130 -34
- package/Server/Utils/Marketing/ConversionUploadProvider.ts +98 -16
- package/Server/Utils/Marketing/Providers/GoogleAds.ts +70 -7
- package/Server/Utils/Marketing/Providers/LinkedIn.ts +54 -16
- package/Server/Utils/Marketing/Providers/Meta.ts +52 -18
- package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +37 -10
- package/Server/Utils/Marketing/Providers/Reddit.ts +45 -15
- package/Server/Utils/Measurement/MeasurementDefinitionValidator.ts +209 -0
- package/Server/Utils/Measurement/MeasurementMetricWriter.ts +189 -0
- package/Server/Utils/Monitor/Criteria/CountAnomaly.ts +182 -0
- package/Server/Utils/Monitor/Criteria/LogMonitorCriteria.ts +132 -0
- package/Server/Utils/Monitor/Criteria/SecurityEventsMonitorCriteria.ts +35 -0
- package/Server/Utils/Monitor/Criteria/TraceMonitorCriteria.ts +132 -0
- package/Server/Utils/Monitor/DataToProcess.ts +2 -0
- package/Server/Utils/Monitor/MonitorCriteriaDataExtractor.ts +14 -0
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +15 -0
- package/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.ts +20 -0
- package/Server/Utils/Monitor/MonitorResource.ts +16 -0
- package/Server/Utils/Monitor/MonitorStepResourceIdentity.ts +1 -0
- package/Server/Utils/Monitor/MonitorStepsReferenceExtractor.ts +1 -0
- package/Server/Utils/SecurityEvent/DetectionRuleEvaluator.ts +548 -0
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.ts +262 -0
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.ts +212 -0
- package/Server/Utils/SecurityEvent/SecurityEventRow.ts +101 -0
- package/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.ts +635 -0
- package/Server/Utils/Telemetry/LlmCostBudgetEvaluator.ts +379 -0
- package/Server/Utils/Telemetry/LlmSpan.ts +83 -4
- package/Server/Utils/Telemetry/LogErrorPatternSql.ts +136 -0
- package/Server/Utils/UserPermission/UserPermission.ts +57 -1
- package/Tests/App/Dashboard/AlertsSideMenu.test.tsx +4 -0
- package/Tests/App/Dashboard/CreatePageEntryPointPermissions.test.tsx +306 -0
- package/Tests/App/Dashboard/DangerZone.test.tsx +11 -0
- package/Tests/App/Dashboard/IncidentsSideMenu.test.tsx +4 -0
- package/Tests/App/Dashboard/LogMonitorAttributeOperatorPreview.test.tsx +459 -0
- package/Tests/App/Dashboard/OverviewCustomFields.test.tsx +24 -0
- package/Tests/App/Dashboard/ScheduledMaintenanceSideMenu.test.tsx +6 -0
- package/Tests/Models/DatabaseModels/DomainRoleTierCoverage.test.ts +323 -0
- package/Tests/Models/DatabaseModels/ProjectSharedResources.test.ts +386 -0
- package/Tests/Server/API/LogErrorPatternAPI.test.ts +811 -0
- package/Tests/Server/API/UserAuthenticationAPI.test.ts +11 -0
- package/Tests/Server/API/UserProjectsAPI.test.ts +11 -2
- package/Tests/Server/API/UserTwoFactorAuthAdminAPI.test.ts +918 -0
- package/Tests/Server/Infrastructure/LocalCache.test.ts +149 -0
- package/Tests/Server/Services/AccessTokenProjectUserGrant.test.ts +249 -0
- package/Tests/Server/Services/AlertMeasurementService.test.ts +665 -0
- package/Tests/Server/Services/AlertMeasurementValueService.test.ts +389 -0
- package/Tests/Server/Services/DetectionRuleService.test.ts +254 -0
- package/Tests/Server/Services/IncidentMeasurementService.test.ts +394 -0
- package/Tests/Server/Services/IncidentMeasurementValueService.test.ts +816 -0
- package/Tests/Server/Services/LlmCostBudgetService.test.ts +104 -0
- package/Tests/Server/Services/LogAggregationAttributeOperators.test.ts +405 -0
- package/Tests/Server/Services/LogErrorPatternAggregation.test.ts +804 -0
- package/Tests/Server/Services/MutableMetricNameRouting.test.ts +83 -0
- package/Tests/Server/Services/ScheduledMaintenanceMeasurementService.test.ts +750 -0
- package/Tests/Server/Services/ScheduledMaintenanceMeasurementValueService.test.ts +478 -0
- package/Tests/Server/Services/UserAuthenticationService.test.ts +216 -4
- package/Tests/Server/Services/UserTwoFactorAuthAdmin.test.ts +1190 -0
- package/Tests/Server/Types/Database/Permissions/ScopedRoleSharedResourceAccess.test.ts +466 -0
- package/Tests/Server/Types/Database/QueryHelperOperators.test.ts +265 -0
- package/Tests/Server/Types/Database/QueryHelperTextAndStructuralOperators.test.ts +206 -0
- package/Tests/Server/Utils/AnalyticsDatabase/ClusterAwareSchema.test.ts +6 -0
- package/Tests/Server/Utils/AnalyticsDatabase/FractionalAttributeThreshold.test.ts +224 -0
- package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +172 -2
- package/Tests/Server/Utils/Attribution.test.ts +228 -1
- package/Tests/Server/Utils/Marketing/AdUploadableConversionTypes.test.ts +153 -92
- package/Tests/Server/Utils/Marketing/ConversionUploadProvider.test.ts +123 -6
- package/Tests/Server/Utils/Marketing/GoogleAds.test.ts +253 -1
- package/Tests/Server/Utils/Marketing/LinkedIn.test.ts +282 -0
- package/Tests/Server/Utils/Marketing/Meta.test.ts +304 -0
- package/Tests/Server/Utils/Marketing/MicrosoftAds.test.ts +263 -0
- package/Tests/Server/Utils/Marketing/Reddit.test.ts +259 -0
- package/Tests/Server/Utils/Measurement/MeasurementDefinitionValidator.test.ts +322 -0
- package/Tests/Server/Utils/Measurement/MeasurementMetricWriter.test.ts +373 -0
- package/Tests/Server/Utils/Monitor/Criteria/CountAnomaly.test.ts +221 -0
- package/Tests/Server/Utils/Monitor/Criteria/LogMonitorCriteria.test.ts +236 -0
- package/Tests/Server/Utils/Monitor/Criteria/SecurityEventsMonitorCriteria.test.ts +147 -0
- package/Tests/Server/Utils/Monitor/Criteria/TraceMonitorCriteria.test.ts +274 -0
- package/Tests/Server/Utils/Monitor/SecurityEventsMonitorDataExtractor.test.ts +93 -0
- package/Tests/Server/Utils/SecurityEvent/DetectionRuleEvaluator.test.ts +660 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsClient.test.ts +308 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPoller.test.ts +271 -0
- package/Tests/Server/Utils/SecurityEvent/SecurityEventRow.test.ts +272 -0
- package/Tests/Server/Utils/SecurityEvent/SigmaClickhouseCompiler.test.ts +511 -0
- package/Tests/Server/Utils/Telemetry/LlmCostBudgetEvaluator.test.ts +497 -0
- package/Tests/Server/Utils/Telemetry/LlmSpan.test.ts +380 -0
- package/Tests/Server/Utils/Telemetry/LogErrorPatternSql.test.ts +207 -0
- package/Tests/Server/Utils/UserPermission/ProjectUserGrant.test.ts +293 -0
- package/Tests/Types/Monitor/MonitorStepInfraMonitorUtils.test.ts +194 -0
- package/Tests/Types/Monitor/MonitorStepSecurityEventsMonitor.test.ts +201 -0
- package/Tests/Types/SecurityEvent/OcsfEventClass.test.ts +105 -0
- package/Tests/Types/SecurityEvent/OcsfSeverity.test.ts +111 -0
- package/Tests/Types/Telemetry/LlmCostCatalog.test.ts +516 -0
- package/Tests/UI/Components/ActiveFilterChipsOperatorValues.test.tsx +222 -0
- package/Tests/UI/Components/BulkActionPermissionGating.test.tsx +296 -0
- package/Tests/UI/Components/CardModelDetailPermissionGating.test.tsx +305 -0
- package/Tests/UI/Components/CustomFields/CustomFieldsDetail.test.tsx +23 -0
- package/Tests/UI/Components/DictionaryFilterOperatorDisplay.test.ts +239 -0
- package/Tests/UI/Components/DisabledButtonTooltip.test.tsx +267 -0
- package/Tests/UI/Components/DuplicateModel.test.tsx +37 -0
- package/Tests/UI/Components/ModelCardPermissionGating.test.tsx +348 -0
- package/Tests/UI/Components/ModelDelete.test.tsx +25 -1
- package/Tests/UI/Components/ModelFormCreatePermission.test.tsx +342 -0
- package/Tests/UI/Components/ModelTable/BaseModelTablePermissionGating.test.tsx +680 -0
- package/Tests/UI/Components/OrderedStatesListCreateGate.test.tsx +174 -0
- package/Tests/UI/Components/SavedViewsDropdownSearch.test.tsx +1127 -0
- package/Tests/UI/Components/SavedViewsFacetSection.test.tsx +958 -0
- package/Tests/UI/Components/SavedViewsList.test.ts +699 -0
- package/Tests/UI/Components/SavedViewsSidebarIntegration.test.tsx +640 -0
- package/Tests/UI/Components/SavedViewsSurfaceParity.test.tsx +679 -0
- package/Tests/UI/Components/TableViewLoadFailure.test.tsx +248 -0
- package/Tests/UI/Types/UseComponentOutsideClick.test.tsx +226 -0
- package/Tests/UI/Utils/PermissionGate.test.ts +467 -0
- package/Tests/Utils/Measurement/MeasurementEvaluator.test.ts +639 -0
- package/Tests/Utils/Monitor/MonitorSummarySnapshotUtil.test.ts +1 -0
- package/Tests/Utils/Monitor/NetworkDeviceLinkRuleUtil.test.ts +285 -0
- package/Tests/Utils/NetworkDevice/DeviceHealthStateUtil.test.ts +433 -0
- package/Tests/Utils/SecurityEvent/GenericNormalizer.test.ts +204 -0
- package/Tests/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.test.ts +252 -0
- package/Tests/Utils/SecurityEvent/NormalizerHelpers.test.ts +274 -0
- package/Tests/Utils/SecurityEvent/OcsfNormalizer.test.ts +208 -0
- package/Tests/Utils/SecurityEvent/SecurityEventNormalizer.test.ts +172 -0
- package/Tests/Utils/SecurityEvent/SigmaRuleParser.test.ts +471 -0
- package/Tests/Utils/SecurityEvent/UdmNormalizer.test.ts +361 -0
- package/Tests/Utils/Telemetry/CrossSignalScope.test.ts +82 -0
- package/Tests/Utils/Telemetry/LogErrorPattern.test.ts +463 -0
- package/Types/AI/AIChatTypes.ts +1 -0
- package/Types/Alerts/AlertMeasurementAnchorType.ts +14 -0
- package/Types/Alerts/AlertStateRole.ts +11 -0
- package/Types/AnalyticsDatabase/AnalyticsTableName.ts +16 -0
- package/Types/Dashboard/Chart/ChartType.ts +1 -0
- package/Types/Dashboard/DashboardComponentType.ts +2 -0
- package/Types/Dashboard/DashboardComponents/DashboardSecurityEventsFlowComponent.ts +18 -0
- package/Types/Dashboard/DashboardComponents/DashboardSecurityEventsListComponent.ts +16 -0
- package/Types/Incident/IncidentMeasurementAnchorType.ts +34 -0
- package/Types/Incident/IncidentStateRole.ts +14 -0
- package/Types/Marketing/Attribution.ts +75 -0
- package/Types/Marketing/MarketingConversion.ts +37 -7
- package/Types/Measurement/MeasurementAggregationType.ts +43 -0
- package/Types/Measurement/MeasurementAnchorKind.ts +23 -0
- package/Types/Measurement/MeasurementOccurrence.ts +14 -0
- package/Types/Measurement/MeasurementStatus.ts +34 -0
- package/Types/MeteredPlan/ProductType.ts +1 -0
- package/Types/Monitor/CriteriaFilter.ts +3 -0
- package/Types/Monitor/MonitorCriteriaInstance.ts +64 -0
- package/Types/Monitor/MonitorStep.ts +28 -0
- package/Types/Monitor/MonitorStepSecurityEventsMonitor.ts +100 -0
- package/Types/Monitor/MonitorType.ts +20 -0
- package/Types/Monitor/SecurityEventsMonitor/SecurityEventsMonitorResponse.ts +17 -0
- package/Types/Permission.ts +399 -2
- package/Types/ScheduledMaintenance/ScheduledMaintenanceMeasurementAnchorType.ts +20 -0
- package/Types/ScheduledMaintenance/ScheduledMaintenanceStateRole.ts +16 -0
- package/Types/SecurityEvent/NormalizedSecurityEvent.ts +92 -0
- package/Types/SecurityEvent/OcsfEventClass.ts +205 -0
- package/Types/SecurityEvent/OcsfSeverity.ts +88 -0
- package/Types/SecurityEvent/SecurityEventFormat.ts +23 -0
- package/Types/SecurityEvent/SigmaRule.ts +70 -0
- package/Types/Telemetry/LlmConventions.ts +20 -1
- package/Types/Telemetry/LlmCostCatalog.ts +557 -0
- package/Types/Telemetry/ServiceType.ts +1 -0
- package/Types/Telemetry/TelemetryRetentionConfig.ts +5 -1
- package/Types/Telemetry/TelemetryType.ts +1 -0
- package/Types/TwoFactorAuthStatus.ts +42 -0
- package/Types/UserAuthenticationStatus.ts +18 -0
- package/UI/Components/ActionButton/ActionButtonSchema.ts +7 -0
- package/UI/Components/BulkUpdate/BulkArchiveActions.tsx +35 -2
- package/UI/Components/BulkUpdate/BulkLabelActions.tsx +34 -1
- package/UI/Components/BulkUpdate/BulkOwnerActions.tsx +45 -1
- package/UI/Components/BulkUpdate/BulkUpdateForm.tsx +3 -0
- package/UI/Components/Button/Button.tsx +37 -2
- package/UI/Components/Card/Card.tsx +6 -0
- package/UI/Components/CustomFields/CustomFieldsDetail.tsx +24 -1
- package/UI/Components/Dictionary/DictionaryFilterOperator.ts +57 -0
- package/UI/Components/DuplicateModel/DuplicateModel.tsx +16 -0
- package/UI/Components/Forms/ModelForm.tsx +54 -2
- package/UI/Components/List/ListRow.tsx +6 -0
- package/UI/Components/LogsViewer/components/ActiveFilterChips.tsx +34 -7
- package/UI/Components/LogsViewer/components/LogsFacetSidebar.tsx +7 -40
- package/UI/Components/LogsViewer/components/SavedViewsDropdown.tsx +155 -3
- package/UI/Components/ModelDelete/ModelDelete.tsx +20 -0
- package/UI/Components/ModelDetail/CardModelDetail.tsx +36 -23
- package/UI/Components/ModelList/ModelList.tsx +21 -2
- package/UI/Components/ModelList/StaticModelList.tsx +11 -0
- package/UI/Components/ModelTable/BaseModelTable.tsx +168 -62
- package/UI/Components/ModelTable/ModelTable.tsx +16 -10
- package/UI/Components/ModelTable/TableView.tsx +36 -4
- package/UI/Components/MoreMenu/MoreMenuItem.tsx +36 -4
- package/UI/Components/OrderedStatesList/Item.tsx +6 -0
- package/UI/Components/OrderedStatesList/OrderedStatesList.tsx +81 -47
- package/UI/Components/ResetObjectID/ResetObjectID.tsx +16 -0
- package/UI/Components/SavedViews/SavedViewsFacetSection.tsx +242 -0
- package/UI/Components/SavedViews/SavedViewsList.ts +168 -0
- package/UI/Components/SavedViews/SavedViewsSearchInput.tsx +46 -0
- package/UI/Components/SavedViews/SavedViewsShowMoreButton.tsx +44 -0
- package/UI/Components/Table/TableRow.tsx +12 -0
- package/UI/Components/TelemetryViewer/components/SavedViewsDropdown.tsx +152 -2
- package/UI/Types/UseComponentOutsideClick.ts +47 -0
- package/UI/Utils/PermissionGate.ts +277 -0
- package/Utils/Dashboard/Components/DashboardSecurityEventsFlowComponent.ts +84 -0
- package/Utils/Dashboard/Components/DashboardSecurityEventsListComponent.ts +110 -0
- package/Utils/Dashboard/Components/Index.ts +14 -0
- package/Utils/Measurement/MeasurementEvaluator.ts +359 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.ts +1 -0
- package/Utils/Monitor/NetworkDeviceLinkRuleUtil.ts +93 -11
- package/Utils/NetworkDevice/DeviceHealthStateUtil.ts +231 -0
- package/Utils/SecurityEvent/GenericNormalizer.ts +208 -0
- package/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.ts +206 -0
- package/Utils/SecurityEvent/NormalizerHelpers.ts +263 -0
- package/Utils/SecurityEvent/OcsfNormalizer.ts +194 -0
- package/Utils/SecurityEvent/SecurityEventNormalizer.ts +82 -0
- package/Utils/SecurityEvent/Sigma/SigmaRuleParser.ts +579 -0
- package/Utils/SecurityEvent/UdmNormalizer.ts +442 -0
- package/Utils/Telemetry/CrossSignalScope.ts +46 -9
- package/Utils/Telemetry/LogErrorPattern.ts +350 -0
- package/build/dist/Models/AnalyticsModels/Index.js +10 -0
- package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/LogCountBaseline.js +159 -0
- package/build/dist/Models/AnalyticsModels/LogCountBaseline.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/SecurityEvent.js +596 -0
- package/build/dist/Models/AnalyticsModels/SecurityEvent.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/Span.js +24 -1
- package/build/dist/Models/AnalyticsModels/Span.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/SpanCountBaseline.js +181 -0
- package/build/dist/Models/AnalyticsModels/SpanCountBaseline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Alert.js +43 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AlertMeasurement.js +1143 -0
- package/build/dist/Models/DatabaseModels/AlertMeasurement.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertMeasurementValue.js +523 -0
- package/build/dist/Models/DatabaseModels/AlertMeasurementValue.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertStateTimeline.js +9 -2
- package/build/dist/Models/DatabaseModels/AlertStateTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/BillingPaymentMethod.js +10 -11
- package/build/dist/Models/DatabaseModels/BillingPaymentMethod.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DetectionRule.js +517 -0
- package/build/dist/Models/DatabaseModels/DetectionRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/GoogleSecOpsConnection.js +410 -0
- package/build/dist/Models/DatabaseModels/GoogleSecOpsConnection.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Incident.js +43 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentMeasurement.js +1143 -0
- package/build/dist/Models/DatabaseModels/IncidentMeasurement.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentMeasurementValue.js +523 -0
- package/build/dist/Models/DatabaseModels/IncidentMeasurementValue.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentStateTimeline.js +9 -2
- package/build/dist/Models/DatabaseModels/IncidentStateTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncomingCallPolicyLabelRule.js +36 -0
- package/build/dist/Models/DatabaseModels/IncomingCallPolicyLabelRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncomingCallPolicyOwnerRule.js +42 -0
- package/build/dist/Models/DatabaseModels/IncomingCallPolicyOwnerRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +20 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Label.js +11 -0
- package/build/dist/Models/DatabaseModels/Label.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmCostBudget.js +681 -0
- package/build/dist/Models/DatabaseModels/LlmCostBudget.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LlmModelPrice.js +503 -0
- package/build/dist/Models/DatabaseModels/LlmModelPrice.js.map +1 -0
- package/build/dist/Models/DatabaseModels/LogSavedView.js +87 -0
- package/build/dist/Models/DatabaseModels/LogSavedView.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MarketingConversion.js +224 -8
- package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MetricSavedView.js +59 -0
- package/build/dist/Models/DatabaseModels/MetricSavedView.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyLabelRule.js +36 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyLabelRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyOwnerRule.js +42 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyOwnerRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLabelRule.js +36 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLabelRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleOwnerRule.js +42 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleOwnerRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Probe.js +21 -0
- package/build/dist/Models/DatabaseModels/Probe.js.map +1 -1
- package/build/dist/Models/DatabaseModels/RunbookLabelRule.js +36 -0
- package/build/dist/Models/DatabaseModels/RunbookLabelRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/RunbookOwnerRule.js +42 -0
- package/build/dist/Models/DatabaseModels/RunbookOwnerRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +1133 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +515 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +9 -2
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageLabelRule.js +36 -0
- package/build/dist/Models/DatabaseModels/StatusPageLabelRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageOwnerRule.js +42 -0
- package/build/dist/Models/DatabaseModels/StatusPageOwnerRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TableView.js +15 -0
- package/build/dist/Models/DatabaseModels/TableView.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Team.js +13 -0
- package/build/dist/Models/DatabaseModels/Team.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TeamMember.js +8 -0
- package/build/dist/Models/DatabaseModels/TeamMember.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TraceSavedView.js +52 -0
- package/build/dist/Models/DatabaseModels/TraceSavedView.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkflowLabelRule.js +36 -0
- package/build/dist/Models/DatabaseModels/WorkflowLabelRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkflowOwnerRule.js +42 -0
- package/build/dist/Models/DatabaseModels/WorkflowOwnerRule.js.map +1 -1
- package/build/dist/Server/API/TelemetryAPI.js +136 -0
- package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
- package/build/dist/Server/API/UserAPI.js +75 -2
- package/build/dist/Server/API/UserAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +29 -1
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788000000000-AddDetectionRuleAndGoogleSecOpsConnection.js +36 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788000000000-AddDetectionRuleAndGoogleSecOpsConnection.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788100000000-AddMeasurements.js +162 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788100000000-AddMeasurements.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788200000000-AddLlmCostBudget.js +40 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788200000000-AddLlmCostBudget.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788300000000-AddLlmModelPrice.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788300000000-AddLlmModelPrice.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788400000000-AddMarketingConversionAttribution.js +52 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788400000000-AddMarketingConversionAttribution.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788500000000-RemoveLlmCostBudgetAlertColumns.js +38 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788500000000-RemoveLlmCostBudgetAlertColumns.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/IdentityRateLimit.js +491 -0
- package/build/dist/Server/Middleware/IdentityRateLimit.js.map +1 -0
- package/build/dist/Server/Services/AccessTokenService.js +13 -2
- package/build/dist/Server/Services/AccessTokenService.js.map +1 -1
- package/build/dist/Server/Services/AlertMeasurementService.js +250 -0
- package/build/dist/Server/Services/AlertMeasurementService.js.map +1 -0
- package/build/dist/Server/Services/AlertMeasurementValueService.js +400 -0
- package/build/dist/Server/Services/AlertMeasurementValueService.js.map +1 -0
- package/build/dist/Server/Services/AlertService.js +37 -0
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateTimelineService.js +48 -0
- package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/DetectionRuleService.js +50 -0
- package/build/dist/Server/Services/DetectionRuleService.js.map +1 -0
- package/build/dist/Server/Services/GoogleSecOpsConnectionService.js +55 -0
- package/build/dist/Server/Services/GoogleSecOpsConnectionService.js.map +1 -0
- package/build/dist/Server/Services/IncidentMeasurementService.js +252 -0
- package/build/dist/Server/Services/IncidentMeasurementService.js.map +1 -0
- package/build/dist/Server/Services/IncidentMeasurementValueService.js +413 -0
- package/build/dist/Server/Services/IncidentMeasurementValueService.js.map +1 -0
- package/build/dist/Server/Services/IncidentService.js +41 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +50 -0
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +30 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LlmCostBudgetService.js +89 -0
- package/build/dist/Server/Services/LlmCostBudgetService.js.map +1 -0
- package/build/dist/Server/Services/LlmModelPriceService.js +163 -0
- package/build/dist/Server/Services/LlmModelPriceService.js.map +1 -0
- package/build/dist/Server/Services/LogAggregationService.js +709 -0
- package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
- package/build/dist/Server/Services/LogCountBaselineService.js +112 -0
- package/build/dist/Server/Services/LogCountBaselineService.js.map +1 -0
- package/build/dist/Server/Services/MutableMetricService.js +28 -9
- package/build/dist/Server/Services/MutableMetricService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceMeasurementService.js +254 -0
- package/build/dist/Server/Services/ScheduledMaintenanceMeasurementService.js.map +1 -0
- package/build/dist/Server/Services/ScheduledMaintenanceMeasurementValueService.js +434 -0
- package/build/dist/Server/Services/ScheduledMaintenanceMeasurementValueService.js.map +1 -0
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +37 -0
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +134 -0
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/SecurityEventService.js +64 -0
- package/build/dist/Server/Services/SecurityEventService.js.map +1 -0
- package/build/dist/Server/Services/SpanCountBaselineService.js +122 -0
- package/build/dist/Server/Services/SpanCountBaselineService.js.map +1 -0
- package/build/dist/Server/Services/StatusPageService.js +4 -3
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +15 -3
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +262 -42
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/UserTotpAuthService.js +0 -73
- package/build/dist/Server/Services/UserTotpAuthService.js.map +1 -1
- package/build/dist/Server/Services/UserWebAuthnService.js +1 -73
- package/build/dist/Server/Services/UserWebAuthnService.js.map +1 -1
- package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js +13 -0
- package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/TenantPermission.js +10 -0
- package/build/dist/Server/Types/Database/Permissions/TenantPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryHelper.js +1 -1
- package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +3 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/SecurityEventTools.js +257 -0
- package/build/dist/Server/Utils/AI/Toolbox/SecurityEventTools.js.map +1 -0
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +13 -4
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
- package/build/dist/Server/Utils/Attribution.js +77 -33
- package/build/dist/Server/Utils/Attribution.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +46 -9
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +52 -8
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +41 -17
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js +42 -18
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +24 -11
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +1 -1
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +34 -15
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +1 -1
- package/build/dist/Server/Utils/Measurement/MeasurementDefinitionValidator.js +109 -0
- package/build/dist/Server/Utils/Measurement/MeasurementDefinitionValidator.js.map +1 -0
- package/build/dist/Server/Utils/Measurement/MeasurementMetricWriter.js +131 -0
- package/build/dist/Server/Utils/Measurement/MeasurementMetricWriter.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CountAnomaly.js +111 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CountAnomaly.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/LogMonitorCriteria.js +84 -1
- package/build/dist/Server/Utils/Monitor/Criteria/LogMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SecurityEventsMonitorCriteria.js +35 -0
- package/build/dist/Server/Utils/Monitor/Criteria/SecurityEventsMonitorCriteria.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/TraceMonitorCriteria.js +84 -1
- package/build/dist/Server/Utils/Monitor/Criteria/TraceMonitorCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaDataExtractor.js +7 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaDataExtractor.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +12 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js +9 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaObservationBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +10 -0
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js +6 -5
- package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorStepsReferenceExtractor.js +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorStepsReferenceExtractor.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js +404 -0
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js +145 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js +176 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/SecurityEventRow.js +69 -0
- package/build/dist/Server/Utils/SecurityEvent/SecurityEventRow.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.js +493 -0
- package/build/dist/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.js.map +1 -0
- package/build/dist/Server/Utils/Telemetry/LlmCostBudgetEvaluator.js +317 -0
- package/build/dist/Server/Utils/Telemetry/LlmCostBudgetEvaluator.js.map +1 -0
- package/build/dist/Server/Utils/Telemetry/LlmSpan.js +56 -4
- package/build/dist/Server/Utils/Telemetry/LlmSpan.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/LogErrorPatternSql.js +112 -0
- package/build/dist/Server/Utils/Telemetry/LogErrorPatternSql.js.map +1 -0
- package/build/dist/Server/Utils/UserPermission/UserPermission.js +46 -1
- package/build/dist/Server/Utils/UserPermission/UserPermission.js.map +1 -1
- package/build/dist/Types/AI/AIChatTypes.js +1 -0
- package/build/dist/Types/AI/AIChatTypes.js.map +1 -1
- package/build/dist/Types/Alerts/AlertMeasurementAnchorType.js +15 -0
- package/build/dist/Types/Alerts/AlertMeasurementAnchorType.js.map +1 -0
- package/build/dist/Types/Alerts/AlertStateRole.js +12 -0
- package/build/dist/Types/Alerts/AlertStateRole.js.map +1 -0
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +16 -0
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
- package/build/dist/Types/Dashboard/Chart/ChartType.js +1 -0
- package/build/dist/Types/Dashboard/Chart/ChartType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponentType.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardSecurityEventsFlowComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardSecurityEventsFlowComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardSecurityEventsListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardSecurityEventsListComponent.js.map +1 -0
- package/build/dist/Types/Incident/IncidentMeasurementAnchorType.js +29 -0
- package/build/dist/Types/Incident/IncidentMeasurementAnchorType.js.map +1 -0
- package/build/dist/Types/Incident/IncidentStateRole.js +15 -0
- package/build/dist/Types/Incident/IncidentStateRole.js.map +1 -0
- package/build/dist/Types/Marketing/Attribution.js +68 -0
- package/build/dist/Types/Marketing/Attribution.js.map +1 -0
- package/build/dist/Types/Marketing/MarketingConversion.js +36 -7
- package/build/dist/Types/Marketing/MarketingConversion.js.map +1 -1
- package/build/dist/Types/Measurement/MeasurementAggregationType.js +40 -0
- package/build/dist/Types/Measurement/MeasurementAggregationType.js.map +1 -0
- package/build/dist/Types/Measurement/MeasurementAnchorKind.js +22 -0
- package/build/dist/Types/Measurement/MeasurementAnchorKind.js.map +1 -0
- package/build/dist/Types/Measurement/MeasurementOccurrence.js +15 -0
- package/build/dist/Types/Measurement/MeasurementOccurrence.js.map +1 -0
- package/build/dist/Types/Measurement/MeasurementStatus.js +32 -0
- package/build/dist/Types/Measurement/MeasurementStatus.js.map +1 -0
- package/build/dist/Types/MeteredPlan/ProductType.js +1 -0
- package/build/dist/Types/MeteredPlan/ProductType.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +2 -0
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +59 -0
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +17 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepSecurityEventsMonitor.js +64 -0
- package/build/dist/Types/Monitor/MonitorStepSecurityEventsMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +19 -0
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/SecurityEventsMonitor/SecurityEventsMonitorResponse.js +2 -0
- package/build/dist/Types/Monitor/SecurityEventsMonitor/SecurityEventsMonitorResponse.js.map +1 -0
- package/build/dist/Types/Permission.js +347 -2
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/ScheduledMaintenance/ScheduledMaintenanceMeasurementAnchorType.js +19 -0
- package/build/dist/Types/ScheduledMaintenance/ScheduledMaintenanceMeasurementAnchorType.js.map +1 -0
- package/build/dist/Types/ScheduledMaintenance/ScheduledMaintenanceStateRole.js +17 -0
- package/build/dist/Types/ScheduledMaintenance/ScheduledMaintenanceStateRole.js.map +1 -0
- package/build/dist/Types/SecurityEvent/NormalizedSecurityEvent.js +2 -0
- package/build/dist/Types/SecurityEvent/NormalizedSecurityEvent.js.map +1 -0
- package/build/dist/Types/SecurityEvent/OcsfEventClass.js +181 -0
- package/build/dist/Types/SecurityEvent/OcsfEventClass.js.map +1 -0
- package/build/dist/Types/SecurityEvent/OcsfSeverity.js +81 -0
- package/build/dist/Types/SecurityEvent/OcsfSeverity.js.map +1 -0
- package/build/dist/Types/SecurityEvent/SecurityEventFormat.js +21 -0
- package/build/dist/Types/SecurityEvent/SecurityEventFormat.js.map +1 -0
- package/build/dist/Types/SecurityEvent/SigmaRule.js +16 -0
- package/build/dist/Types/SecurityEvent/SigmaRule.js.map +1 -0
- package/build/dist/Types/Telemetry/LlmConventions.js +19 -1
- package/build/dist/Types/Telemetry/LlmConventions.js.map +1 -1
- package/build/dist/Types/Telemetry/LlmCostCatalog.js +484 -0
- package/build/dist/Types/Telemetry/LlmCostCatalog.js.map +1 -0
- package/build/dist/Types/Telemetry/ServiceType.js +1 -0
- package/build/dist/Types/Telemetry/ServiceType.js.map +1 -1
- package/build/dist/Types/Telemetry/TelemetryRetentionConfig.js.map +1 -1
- package/build/dist/Types/Telemetry/TelemetryType.js +1 -0
- package/build/dist/Types/Telemetry/TelemetryType.js.map +1 -1
- package/build/dist/Types/TwoFactorAuthStatus.js +41 -0
- package/build/dist/Types/TwoFactorAuthStatus.js.map +1 -0
- package/build/dist/UI/Components/BulkUpdate/BulkArchiveActions.js +16 -2
- package/build/dist/UI/Components/BulkUpdate/BulkArchiveActions.js.map +1 -1
- package/build/dist/UI/Components/BulkUpdate/BulkLabelActions.js +15 -1
- package/build/dist/UI/Components/BulkUpdate/BulkLabelActions.js.map +1 -1
- package/build/dist/UI/Components/BulkUpdate/BulkOwnerActions.js +20 -1
- package/build/dist/UI/Components/BulkUpdate/BulkOwnerActions.js.map +1 -1
- package/build/dist/UI/Components/BulkUpdate/BulkUpdateForm.js +1 -1
- package/build/dist/UI/Components/BulkUpdate/BulkUpdateForm.js.map +1 -1
- package/build/dist/UI/Components/Button/Button.js +22 -1
- package/build/dist/UI/Components/Button/Button.js.map +1 -1
- package/build/dist/UI/Components/Card/Card.js +1 -1
- package/build/dist/UI/Components/Card/Card.js.map +1 -1
- package/build/dist/UI/Components/CustomFields/CustomFieldsDetail.js +14 -1
- package/build/dist/UI/Components/CustomFields/CustomFieldsDetail.js.map +1 -1
- package/build/dist/UI/Components/Dictionary/DictionaryFilterOperator.js +47 -0
- package/build/dist/UI/Components/Dictionary/DictionaryFilterOperator.js.map +1 -1
- package/build/dist/UI/Components/DuplicateModel/DuplicateModel.js +8 -0
- package/build/dist/UI/Components/DuplicateModel/DuplicateModel.js.map +1 -1
- package/build/dist/UI/Components/Forms/ModelForm.js +40 -1
- package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
- package/build/dist/UI/Components/List/ListRow.js +4 -1
- package/build/dist/UI/Components/List/ListRow.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/ActiveFilterChips.js +32 -7
- package/build/dist/UI/Components/LogsViewer/components/ActiveFilterChips.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js +2 -17
- package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/SavedViewsDropdown.js +93 -4
- package/build/dist/UI/Components/LogsViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Components/ModelDelete/ModelDelete.js +13 -0
- package/build/dist/UI/Components/ModelDelete/ModelDelete.js.map +1 -1
- package/build/dist/UI/Components/ModelDetail/CardModelDetail.js +27 -11
- package/build/dist/UI/Components/ModelDetail/CardModelDetail.js.map +1 -1
- package/build/dist/UI/Components/ModelList/ModelList.js +13 -2
- package/build/dist/UI/Components/ModelList/ModelList.js.map +1 -1
- package/build/dist/UI/Components/ModelList/StaticModelList.js +4 -1
- package/build/dist/UI/Components/ModelList/StaticModelList.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +101 -40
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/ModelTable.js +9 -7
- package/build/dist/UI/Components/ModelTable/ModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js +32 -4
- package/build/dist/UI/Components/ModelTable/TableView.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +19 -2
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -1
- package/build/dist/UI/Components/OrderedStatesList/Item.js +4 -1
- package/build/dist/UI/Components/OrderedStatesList/Item.js.map +1 -1
- package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js +33 -32
- package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js.map +1 -1
- package/build/dist/UI/Components/ResetObjectID/ResetObjectID.js +8 -0
- package/build/dist/UI/Components/ResetObjectID/ResetObjectID.js.map +1 -1
- package/build/dist/UI/Components/SavedViews/SavedViewsFacetSection.js +98 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsFacetSection.js.map +1 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsList.js +99 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsList.js.map +1 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsSearchInput.js +17 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsSearchInput.js.map +1 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsShowMoreButton.js +15 -0
- package/build/dist/UI/Components/SavedViews/SavedViewsShowMoreButton.js.map +1 -0
- package/build/dist/UI/Components/Table/TableRow.js +8 -2
- package/build/dist/UI/Components/Table/TableRow.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js +93 -4
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Types/UseComponentOutsideClick.js +39 -0
- package/build/dist/UI/Types/UseComponentOutsideClick.js.map +1 -1
- package/build/dist/UI/Utils/PermissionGate.js +164 -0
- package/build/dist/UI/Utils/PermissionGate.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardSecurityEventsFlowComponent.js +70 -0
- package/build/dist/Utils/Dashboard/Components/DashboardSecurityEventsFlowComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardSecurityEventsListComponent.js +92 -0
- package/build/dist/Utils/Dashboard/Components/DashboardSecurityEventsListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/Index.js +8 -0
- package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
- package/build/dist/Utils/Measurement/MeasurementEvaluator.js +210 -0
- package/build/dist/Utils/Measurement/MeasurementEvaluator.js.map +1 -0
- package/build/dist/Utils/Monitor/MonitorSummarySnapshotUtil.js +1 -0
- package/build/dist/Utils/Monitor/MonitorSummarySnapshotUtil.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkDeviceLinkRuleUtil.js +51 -10
- package/build/dist/Utils/Monitor/NetworkDeviceLinkRuleUtil.js.map +1 -1
- package/build/dist/Utils/NetworkDevice/DeviceHealthStateUtil.js +108 -0
- package/build/dist/Utils/NetworkDevice/DeviceHealthStateUtil.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/GenericNormalizer.js +176 -0
- package/build/dist/Utils/SecurityEvent/GenericNormalizer.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.js +146 -0
- package/build/dist/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/NormalizerHelpers.js +196 -0
- package/build/dist/Utils/SecurityEvent/NormalizerHelpers.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/OcsfNormalizer.js +136 -0
- package/build/dist/Utils/SecurityEvent/OcsfNormalizer.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/SecurityEventNormalizer.js +64 -0
- package/build/dist/Utils/SecurityEvent/SecurityEventNormalizer.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/Sigma/SigmaRuleParser.js +388 -0
- package/build/dist/Utils/SecurityEvent/Sigma/SigmaRuleParser.js.map +1 -0
- package/build/dist/Utils/SecurityEvent/UdmNormalizer.js +328 -0
- package/build/dist/Utils/SecurityEvent/UdmNormalizer.js.map +1 -0
- package/build/dist/Utils/Telemetry/CrossSignalScope.js +29 -7
- package/build/dist/Utils/Telemetry/CrossSignalScope.js.map +1 -1
- package/build/dist/Utils/Telemetry/LogErrorPattern.js +284 -0
- package/build/dist/Utils/Telemetry/LogErrorPattern.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import LlmCostBudget from "../../../Models/DatabaseModels/LlmCostBudget";
|
|
2
|
+
import MetricType from "../../../Models/DatabaseModels/MetricType";
|
|
3
|
+
import Span from "../../../Models/AnalyticsModels/Span";
|
|
4
|
+
import { MetricPointType } from "../../../Models/AnalyticsModels/Metric";
|
|
5
|
+
import AggregatedModel from "../../../Types/BaseDatabase/AggregatedModel";
|
|
6
|
+
import AggregatedResult from "../../../Types/BaseDatabase/AggregatedResult";
|
|
7
|
+
import AggregationInterval from "../../../Types/BaseDatabase/AggregationInterval";
|
|
8
|
+
import AggregationType from "../../../Types/BaseDatabase/AggregationType";
|
|
9
|
+
import InBetween from "../../../Types/BaseDatabase/InBetween";
|
|
10
|
+
import Query from "../../../Types/BaseDatabase/Query";
|
|
11
|
+
import LIMIT_MAX, { LIMIT_PER_PROJECT } from "../../../Types/Database/LimitMax";
|
|
12
|
+
import OneUptimeDate from "../../../Types/Date";
|
|
13
|
+
import { JSONObject } from "../../../Types/JSON";
|
|
14
|
+
import ObjectID from "../../../Types/ObjectID";
|
|
15
|
+
import ServiceType from "../../../Types/Telemetry/ServiceType";
|
|
16
|
+
import AggregateBy from "../../Types/AnalyticsDatabase/AggregateBy";
|
|
17
|
+
import LlmCostBudgetService from "../../Services/LlmCostBudgetService";
|
|
18
|
+
import MetricService from "../../Services/MetricService";
|
|
19
|
+
import SpanService from "../../Services/SpanService";
|
|
20
|
+
import logger, { LogAttributes } from "../Logger";
|
|
21
|
+
import CaptureSpan from "../Telemetry/CaptureSpan";
|
|
22
|
+
import TelemetryUtil from "./Telemetry";
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Evaluates LLM cost budgets against the day's LLM span spend.
|
|
26
|
+
*
|
|
27
|
+
* The worker job (App/FeatureSet/Workers/Jobs/Llm/EvaluateLlmCostBudgets.ts)
|
|
28
|
+
* calls evaluateAllBudgets() on a 15-minute tick. For each enabled budget it
|
|
29
|
+
* sums the UTC day's llmCost from ClickHouse (scoped by the budget's optional
|
|
30
|
+
* service / provider / model filters), stamps the spend back onto the budget
|
|
31
|
+
* row for the dashboard, and publishes two gauge metrics:
|
|
32
|
+
*
|
|
33
|
+
* oneuptime.llm.budget.spend.usd — the day's spend so far, in USD
|
|
34
|
+
* oneuptime.llm.budget.percent.used — spend as a percent of the budget
|
|
35
|
+
*
|
|
36
|
+
* Budgets do NOT alert directly. Alerting is a Metrics monitor on these
|
|
37
|
+
* series — filter by the oneuptime.llm.budget.id attribute (stable across
|
|
38
|
+
* renames; the name attribute is for charts and changes when the budget is
|
|
39
|
+
* renamed) — which brings thresholds, formulas, anomaly baselines, incidents
|
|
40
|
+
* and on-call routing without a parallel alerting pipeline here.
|
|
41
|
+
*
|
|
42
|
+
* The series gets ONE point per budget per 15-minute sweep. A monitor on it
|
|
43
|
+
* must use a rolling window of at least 15 minutes (30 recommended): the
|
|
44
|
+
* 1-minute default would see an empty series between sweeps and flap.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export const LLM_BUDGET_SPEND_METRIC_NAME: string =
|
|
48
|
+
"oneuptime.llm.budget.spend.usd";
|
|
49
|
+
export const LLM_BUDGET_PERCENT_METRIC_NAME: string =
|
|
50
|
+
"oneuptime.llm.budget.percent.used";
|
|
51
|
+
|
|
52
|
+
// Attribute keys carried by both budget metrics, for monitor/chart filtering.
|
|
53
|
+
export const LLM_BUDGET_ID_ATTRIBUTE: string = "oneuptime.llm.budget.id";
|
|
54
|
+
export const LLM_BUDGET_NAME_ATTRIBUTE: string = "oneuptime.llm.budget.name";
|
|
55
|
+
export const LLM_BUDGET_PROVIDER_ATTRIBUTE: string =
|
|
56
|
+
"oneuptime.llm.budget.provider";
|
|
57
|
+
export const LLM_BUDGET_MODEL_ATTRIBUTE: string = "oneuptime.llm.budget.model";
|
|
58
|
+
export const LLM_BUDGET_SERVICE_ID_ATTRIBUTE: string =
|
|
59
|
+
"oneuptime.llm.budget.service.id";
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Matches the derived-metric retention the trace/metric recording rules use.
|
|
63
|
+
* The series exists for monitors and short-range charts; long-range spend
|
|
64
|
+
* history belongs to the spans themselves.
|
|
65
|
+
*/
|
|
66
|
+
const BUDGET_METRIC_RETENTION_IN_DAYS: number = 15;
|
|
67
|
+
|
|
68
|
+
export default class LlmCostBudgetEvaluator {
|
|
69
|
+
/**
|
|
70
|
+
* Percent of the daily budget consumed. 0 when the budget is missing or
|
|
71
|
+
* invalid — never NaN/Infinity, since these values feed monitors.
|
|
72
|
+
*/
|
|
73
|
+
public static computePercentUsed(data: {
|
|
74
|
+
spendInUSD: number;
|
|
75
|
+
dailyBudgetInUSD: number;
|
|
76
|
+
}): number {
|
|
77
|
+
if (
|
|
78
|
+
!isFinite(data.dailyBudgetInUSD) ||
|
|
79
|
+
data.dailyBudgetInUSD <= 0 ||
|
|
80
|
+
!isFinite(data.spendInUSD) ||
|
|
81
|
+
data.spendInUSD < 0
|
|
82
|
+
) {
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const percent: number = (data.spendInUSD / data.dailyBudgetInUSD) * 100;
|
|
87
|
+
|
|
88
|
+
// Trim float noise; hundredth-of-a-percent resolution is plenty.
|
|
89
|
+
return Math.round(percent * 100) / 100;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Start of the UTC day `now` falls in. UTC-explicit (not process-zone) so
|
|
94
|
+
* the budget day is the same day everywhere OneUptime runs.
|
|
95
|
+
*/
|
|
96
|
+
public static getUtcDayStart(now: Date): Date {
|
|
97
|
+
return new Date(
|
|
98
|
+
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Build the ClickHouse span filter for a budget: the UTC day so far,
|
|
104
|
+
* LLM spans only, narrowed by the budget's optional service / provider /
|
|
105
|
+
* model scoping.
|
|
106
|
+
*/
|
|
107
|
+
public static buildSpanQuery(data: {
|
|
108
|
+
budget: LlmCostBudget;
|
|
109
|
+
dayStart: Date;
|
|
110
|
+
now: Date;
|
|
111
|
+
}): Query<Span> {
|
|
112
|
+
const query: Query<Span> = {
|
|
113
|
+
projectId: data.budget.projectId!,
|
|
114
|
+
isLlmSpan: true,
|
|
115
|
+
/*
|
|
116
|
+
* Bound rows to the window — aggregateBy's startTimestamp/endTimestamp
|
|
117
|
+
* only pick the bucket grid, they do not filter rows.
|
|
118
|
+
*/
|
|
119
|
+
startTime: new InBetween(data.dayStart, data.now),
|
|
120
|
+
} as Query<Span>;
|
|
121
|
+
|
|
122
|
+
if (data.budget.serviceId) {
|
|
123
|
+
(query as Record<string, unknown>)["primaryEntityId"] =
|
|
124
|
+
data.budget.serviceId;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (data.budget.llmSystem) {
|
|
128
|
+
(query as Record<string, unknown>)["llmSystem"] = data.budget.llmSystem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (data.budget.llmModel) {
|
|
132
|
+
(query as Record<string, unknown>)["llmRequestModel"] =
|
|
133
|
+
data.budget.llmModel;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return query;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Build the two metric rows one evaluation publishes for one budget.
|
|
141
|
+
* Pure — mirrors the derived-metric row shape the trace recording rules
|
|
142
|
+
* write — so the series shape is unit-testable.
|
|
143
|
+
*/
|
|
144
|
+
public static buildBudgetMetricRows(data: {
|
|
145
|
+
budget: LlmCostBudget;
|
|
146
|
+
spendInUSD: number;
|
|
147
|
+
percentUsed: number;
|
|
148
|
+
now: Date;
|
|
149
|
+
}): Array<JSONObject> {
|
|
150
|
+
const attributes: Record<string, string> = {
|
|
151
|
+
[LLM_BUDGET_ID_ATTRIBUTE]: data.budget.id?.toString() || "",
|
|
152
|
+
[LLM_BUDGET_NAME_ATTRIBUTE]: data.budget.name || "",
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if (data.budget.serviceId) {
|
|
156
|
+
attributes[LLM_BUDGET_SERVICE_ID_ATTRIBUTE] =
|
|
157
|
+
data.budget.serviceId.toString();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (data.budget.llmSystem) {
|
|
161
|
+
attributes[LLM_BUDGET_PROVIDER_ATTRIBUTE] = data.budget.llmSystem;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (data.budget.llmModel) {
|
|
165
|
+
attributes[LLM_BUDGET_MODEL_ATTRIBUTE] = data.budget.llmModel;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const retentionDate: Date = OneUptimeDate.addRemoveDays(
|
|
169
|
+
data.now,
|
|
170
|
+
BUDGET_METRIC_RETENTION_IN_DAYS,
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const buildRow: (name: string, value: number) => JSONObject = (
|
|
174
|
+
name: string,
|
|
175
|
+
value: number,
|
|
176
|
+
): JSONObject => {
|
|
177
|
+
return {
|
|
178
|
+
_id: ObjectID.generateTimeOrdered().toString(),
|
|
179
|
+
projectId: data.budget.projectId!.toString(),
|
|
180
|
+
createdAt: OneUptimeDate.toClickhouseDateTime(data.now),
|
|
181
|
+
time: OneUptimeDate.toClickhouseDateTime(data.now),
|
|
182
|
+
timeUnixNano: (data.now.getTime() * 1_000_000).toString(),
|
|
183
|
+
primaryEntityType: ServiceType.OpenTelemetry,
|
|
184
|
+
name: name,
|
|
185
|
+
metricPointType: MetricPointType.Gauge,
|
|
186
|
+
value: value,
|
|
187
|
+
attributes: attributes,
|
|
188
|
+
attributeKeys: Object.keys(attributes).sort(),
|
|
189
|
+
retentionDate: OneUptimeDate.toClickhouseDateTime(retentionDate),
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
return [
|
|
194
|
+
buildRow(LLM_BUDGET_SPEND_METRIC_NAME, data.spendInUSD),
|
|
195
|
+
buildRow(LLM_BUDGET_PERCENT_METRIC_NAME, data.percentUsed),
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Evaluate every enabled budget. One bad budget never aborts the sweep.
|
|
201
|
+
*/
|
|
202
|
+
@CaptureSpan()
|
|
203
|
+
public static async evaluateAllBudgets(): Promise<void> {
|
|
204
|
+
const budgets: Array<LlmCostBudget> = await LlmCostBudgetService.findBy({
|
|
205
|
+
query: {
|
|
206
|
+
isEnabled: true,
|
|
207
|
+
},
|
|
208
|
+
select: {
|
|
209
|
+
_id: true,
|
|
210
|
+
projectId: true,
|
|
211
|
+
name: true,
|
|
212
|
+
dailyBudgetInUSD: true,
|
|
213
|
+
serviceId: true,
|
|
214
|
+
llmSystem: true,
|
|
215
|
+
llmModel: true,
|
|
216
|
+
},
|
|
217
|
+
limit: LIMIT_MAX,
|
|
218
|
+
skip: 0,
|
|
219
|
+
props: {
|
|
220
|
+
isRoot: true,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if (budgets.length === 0) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
logger.debug(
|
|
229
|
+
`Llm:EvaluateLlmCostBudgets: evaluating ${budgets.length} enabled budget(s)`,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const now: Date = new Date();
|
|
233
|
+
|
|
234
|
+
for (const budget of budgets) {
|
|
235
|
+
try {
|
|
236
|
+
await this.evaluateBudget({ budget, now });
|
|
237
|
+
} catch (err) {
|
|
238
|
+
logger.error(
|
|
239
|
+
`LLM cost budget ${budget.id?.toString()} for project ${budget.projectId?.toString() ?? "?"} failed: ${
|
|
240
|
+
err instanceof Error ? err.message : String(err)
|
|
241
|
+
}`,
|
|
242
|
+
{ projectId: budget.projectId?.toString() } as LogAttributes,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Evaluate one budget: sum the day's spend, stamp it on the row, and
|
|
250
|
+
* publish the spend / percent-used metric points.
|
|
251
|
+
*/
|
|
252
|
+
@CaptureSpan()
|
|
253
|
+
public static async evaluateBudget(data: {
|
|
254
|
+
budget: LlmCostBudget;
|
|
255
|
+
now: Date;
|
|
256
|
+
}): Promise<void> {
|
|
257
|
+
const budget: LlmCostBudget = data.budget;
|
|
258
|
+
|
|
259
|
+
if (!budget.id || !budget.projectId || !budget.dailyBudgetInUSD) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const dayStart: Date = this.getUtcDayStart(data.now);
|
|
264
|
+
|
|
265
|
+
const spendInUSD: number = await this.getSpendInUSD({
|
|
266
|
+
budget: budget,
|
|
267
|
+
dayStart: dayStart,
|
|
268
|
+
now: data.now,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const percentUsed: number = this.computePercentUsed({
|
|
272
|
+
spendInUSD: spendInUSD,
|
|
273
|
+
dailyBudgetInUSD: budget.dailyBudgetInUSD,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Stamp the spend for the dashboard's Budgets tab.
|
|
277
|
+
await LlmCostBudgetService.updateOneById({
|
|
278
|
+
id: budget.id,
|
|
279
|
+
data: {
|
|
280
|
+
currentDaySpendInUSD: spendInUSD,
|
|
281
|
+
spendLastEvaluatedAt: data.now,
|
|
282
|
+
},
|
|
283
|
+
props: {
|
|
284
|
+
isRoot: true,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
await this.writeBudgetMetrics({
|
|
289
|
+
budget: budget,
|
|
290
|
+
spendInUSD: spendInUSD,
|
|
291
|
+
percentUsed: percentUsed,
|
|
292
|
+
now: data.now,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Sum the day's llmCost for the budget's scope from ClickHouse.
|
|
298
|
+
*/
|
|
299
|
+
@CaptureSpan()
|
|
300
|
+
private static async getSpendInUSD(data: {
|
|
301
|
+
budget: LlmCostBudget;
|
|
302
|
+
dayStart: Date;
|
|
303
|
+
now: Date;
|
|
304
|
+
}): Promise<number> {
|
|
305
|
+
const aggregateBy: AggregateBy<Span> = {
|
|
306
|
+
query: this.buildSpanQuery(data),
|
|
307
|
+
aggregationType: AggregationType.Sum,
|
|
308
|
+
aggregateColumnName: "llmCost",
|
|
309
|
+
aggregationTimestampColumnName: "startTime",
|
|
310
|
+
startTimestamp: data.dayStart,
|
|
311
|
+
endTimestamp: data.now,
|
|
312
|
+
// One total over the whole window — no time bucketing.
|
|
313
|
+
aggregationInterval: AggregationInterval.Total,
|
|
314
|
+
/*
|
|
315
|
+
* The sum feeds monitors: fail loud on a query timeout — the default
|
|
316
|
+
* 'break' overflow mode returns silently-partial sums, which would
|
|
317
|
+
* understate spend and suppress a real budget breach downstream.
|
|
318
|
+
*/
|
|
319
|
+
timeoutOverflowMode: "throw",
|
|
320
|
+
limit: LIMIT_PER_PROJECT,
|
|
321
|
+
skip: 0,
|
|
322
|
+
props: {
|
|
323
|
+
isRoot: true,
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const result: AggregatedResult = await SpanService.aggregateBy(aggregateBy);
|
|
328
|
+
|
|
329
|
+
return (result.data || []).reduce(
|
|
330
|
+
(acc: number, row: AggregatedModel): number => {
|
|
331
|
+
return acc + Number(row.value || 0);
|
|
332
|
+
},
|
|
333
|
+
0,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Publish the budget's spend and percent-used gauge points, and register
|
|
339
|
+
* the metric names so they appear in the dashboard's metric picker and the
|
|
340
|
+
* Metrics-monitor builder.
|
|
341
|
+
*/
|
|
342
|
+
@CaptureSpan()
|
|
343
|
+
private static async writeBudgetMetrics(data: {
|
|
344
|
+
budget: LlmCostBudget;
|
|
345
|
+
spendInUSD: number;
|
|
346
|
+
percentUsed: number;
|
|
347
|
+
now: Date;
|
|
348
|
+
}): Promise<void> {
|
|
349
|
+
const rows: Array<JSONObject> = this.buildBudgetMetricRows(data);
|
|
350
|
+
|
|
351
|
+
await MetricService.insertJsonRows(rows);
|
|
352
|
+
|
|
353
|
+
const spendType: MetricType = new MetricType();
|
|
354
|
+
spendType.name = LLM_BUDGET_SPEND_METRIC_NAME;
|
|
355
|
+
spendType.description =
|
|
356
|
+
"LLM spend accrued so far in the current UTC day for an LLM cost budget, in USD. One point per budget every 15 minutes; filter by the oneuptime.llm.budget.id attribute.";
|
|
357
|
+
spendType.unit = "USD";
|
|
358
|
+
|
|
359
|
+
const percentType: MetricType = new MetricType();
|
|
360
|
+
percentType.name = LLM_BUDGET_PERCENT_METRIC_NAME;
|
|
361
|
+
percentType.description =
|
|
362
|
+
"LLM spend as a percent of an LLM cost budget's daily limit. One point per budget every 15 minutes — alert with a Metrics monitor (e.g. value >= 80) using a rolling window of 30 minutes, filtered by oneuptime.llm.budget.id.";
|
|
363
|
+
percentType.unit = "%";
|
|
364
|
+
|
|
365
|
+
/*
|
|
366
|
+
* Registration is what makes the names show up in the metric picker —
|
|
367
|
+
* fire-and-forget, a registration failure must not fail the sweep.
|
|
368
|
+
*/
|
|
369
|
+
TelemetryUtil.indexMetricNameServiceNameMap({
|
|
370
|
+
metricNameServiceNameMap: {
|
|
371
|
+
[LLM_BUDGET_SPEND_METRIC_NAME]: spendType,
|
|
372
|
+
[LLM_BUDGET_PERCENT_METRIC_NAME]: percentType,
|
|
373
|
+
},
|
|
374
|
+
projectId: data.budget.projectId!,
|
|
375
|
+
}).catch((err: Error) => {
|
|
376
|
+
logger.error(err);
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import Dictionary from "../../../Types/Dictionary";
|
|
2
|
+
import {
|
|
3
|
+
LlmCostCatalogUtil,
|
|
4
|
+
LlmModelPrice,
|
|
5
|
+
} from "../../../Types/Telemetry/LlmCostCatalog";
|
|
2
6
|
import {
|
|
3
7
|
LlmAgentNameAttributeKeys,
|
|
4
8
|
LlmAttributeNamespacePrefixes,
|
|
9
|
+
LlmConversationIdAttributeKeys,
|
|
5
10
|
LlmCostAttributeKeys,
|
|
6
11
|
LlmInputTokenAttributeKeys,
|
|
7
12
|
LlmOperationAttributeKeys,
|
|
@@ -44,11 +49,18 @@ export interface LlmSpanFields {
|
|
|
44
49
|
llmInputTokens: number;
|
|
45
50
|
llmOutputTokens: number;
|
|
46
51
|
llmTotalTokens: number;
|
|
47
|
-
|
|
52
|
+
/*
|
|
53
|
+
* Cost in USD. The SDK-reported cost (gen_ai.usage.cost) when present;
|
|
54
|
+
* otherwise an estimate computed from token counts against the project's
|
|
55
|
+
* custom price overrides and the built-in list-price catalog
|
|
56
|
+
* (Common/Types/Telemetry/LlmCostCatalog.ts). 0 when none is available.
|
|
57
|
+
*/
|
|
48
58
|
llmCost: number;
|
|
49
59
|
// Agent / tool names for agent-framework spans.
|
|
50
60
|
llmAgentName: string;
|
|
51
61
|
llmToolName: string;
|
|
62
|
+
// Conversation / session id grouping calls of one interaction (gen_ai.conversation.id).
|
|
63
|
+
llmConversationId: string;
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
type SpanAttributes = Dictionary<AttributeType | Array<AttributeType>>;
|
|
@@ -70,14 +82,22 @@ export default class LlmSpanUtil {
|
|
|
70
82
|
llmCost: 0,
|
|
71
83
|
llmAgentName: "",
|
|
72
84
|
llmToolName: "",
|
|
85
|
+
llmConversationId: "",
|
|
73
86
|
};
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
/**
|
|
77
90
|
* Extract first-class LLM fields from a flattened span attribute dictionary.
|
|
78
91
|
* Pure + side-effect free so it can be unit tested in isolation.
|
|
92
|
+
*
|
|
93
|
+
* `projectPriceOverrides` are the project's custom model prices (loaded by
|
|
94
|
+
* the ingest pipeline); they take part in the cost fallback below with
|
|
95
|
+
* longest-prefix-wins semantics against the built-in catalog.
|
|
79
96
|
*/
|
|
80
|
-
public static extract(
|
|
97
|
+
public static extract(
|
|
98
|
+
attributes: SpanAttributes,
|
|
99
|
+
projectPriceOverrides?: Array<LlmModelPrice>,
|
|
100
|
+
): LlmSpanFields {
|
|
81
101
|
const fields: LlmSpanFields = this.empty();
|
|
82
102
|
|
|
83
103
|
if (!attributes || typeof attributes !== "object") {
|
|
@@ -134,7 +154,17 @@ export default class LlmSpanUtil {
|
|
|
134
154
|
fields.llmTotalTokens = fields.llmInputTokens + fields.llmOutputTokens;
|
|
135
155
|
}
|
|
136
156
|
|
|
137
|
-
|
|
157
|
+
/*
|
|
158
|
+
* Cost must distinguish "reported as 0" from "not reported at all": a
|
|
159
|
+
* gateway fronting a free local model (or a fully-cached call) reports an
|
|
160
|
+
* explicit cost of 0, and that 0 must win over any catalog estimate.
|
|
161
|
+
*/
|
|
162
|
+
const reportedCost: number | null = this.getNumberOrNull(
|
|
163
|
+
attributes,
|
|
164
|
+
LlmCostAttributeKeys,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
fields.llmCost = reportedCost ?? 0;
|
|
138
168
|
|
|
139
169
|
fields.llmAgentName = this.getString(attributes, LlmAgentNameAttributeKeys);
|
|
140
170
|
|
|
@@ -142,6 +172,43 @@ export default class LlmSpanUtil {
|
|
|
142
172
|
|
|
143
173
|
fields.isLlmSpan = this.detectIsLlmSpan(keys, fields);
|
|
144
174
|
|
|
175
|
+
/*
|
|
176
|
+
* Conversation id is gated on isLlmSpan because one of its candidate keys
|
|
177
|
+
* ("session.id") is the generic OTel key RUM browser spans carry — those
|
|
178
|
+
* already denormalize it into the sessionId column, and stamping it here
|
|
179
|
+
* too would duplicate it (and its bloom-filter index) across the
|
|
180
|
+
* highest-volume span class for no reader.
|
|
181
|
+
*/
|
|
182
|
+
if (fields.isLlmSpan) {
|
|
183
|
+
fields.llmConversationId = this.getString(
|
|
184
|
+
attributes,
|
|
185
|
+
LlmConversationIdAttributeKeys,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* Cost fallback: the SDK-reported cost always wins — including an
|
|
191
|
+
* explicit 0 — but most instrumentations only report token counts. Price
|
|
192
|
+
* those against the project's custom price overrides and the built-in
|
|
193
|
+
* list-price catalog (longest prefix wins across both, project entries
|
|
194
|
+
* beat built-ins on ties) so spend shows up in dashboards and cost
|
|
195
|
+
* budgets without per-SDK pricing math. The response model is priced in
|
|
196
|
+
* preference to the request model — it names what the provider actually
|
|
197
|
+
* served (e.g. an alias like "gpt-4o" resolved to a dated snapshot).
|
|
198
|
+
*/
|
|
199
|
+
if (fields.isLlmSpan && reportedCost === null) {
|
|
200
|
+
const computedCost: number | null = LlmCostCatalogUtil.computeCostInUSD({
|
|
201
|
+
model: fields.llmResponseModel || fields.llmRequestModel,
|
|
202
|
+
inputTokens: fields.llmInputTokens,
|
|
203
|
+
outputTokens: fields.llmOutputTokens,
|
|
204
|
+
projectPriceOverrides: projectPriceOverrides,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (computedCost !== null) {
|
|
208
|
+
fields.llmCost = computedCost;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
145
212
|
return fields;
|
|
146
213
|
}
|
|
147
214
|
|
|
@@ -199,6 +266,18 @@ export default class LlmSpanUtil {
|
|
|
199
266
|
attributes: SpanAttributes,
|
|
200
267
|
candidateKeys: Array<string>,
|
|
201
268
|
): number {
|
|
269
|
+
return this.getNumberOrNull(attributes, candidateKeys) ?? 0;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Like getNumber but null when no candidate key carries a parseable number
|
|
274
|
+
* — callers that must distinguish "reported as 0" from "absent" (cost) use
|
|
275
|
+
* this directly.
|
|
276
|
+
*/
|
|
277
|
+
private static getNumberOrNull(
|
|
278
|
+
attributes: SpanAttributes,
|
|
279
|
+
candidateKeys: Array<string>,
|
|
280
|
+
): number | null {
|
|
202
281
|
for (const key of candidateKeys) {
|
|
203
282
|
const value: AttributeType | Array<AttributeType> | undefined =
|
|
204
283
|
attributes[key];
|
|
@@ -220,6 +299,6 @@ export default class LlmSpanUtil {
|
|
|
220
299
|
}
|
|
221
300
|
}
|
|
222
301
|
|
|
223
|
-
return
|
|
302
|
+
return null;
|
|
224
303
|
}
|
|
225
304
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import TableColumnType from "../../../Types/AnalyticsDatabase/TableColumnType";
|
|
2
|
+
import { SQL, Statement } from "../AnalyticsDatabase/Statement";
|
|
3
|
+
import {
|
|
4
|
+
LOG_ERROR_PATTERN_MAX_LENGTH,
|
|
5
|
+
LOG_ERROR_PATTERN_RULES,
|
|
6
|
+
LogErrorPatternRule,
|
|
7
|
+
} from "../../../Utils/Telemetry/LogErrorPattern";
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Compiles the shared error-pattern rules (Common/Utils/Telemetry/
|
|
11
|
+
* LogErrorPattern) into the ClickHouse expression that does the grouping.
|
|
12
|
+
*
|
|
13
|
+
* The grouping has to happen in the database. Normalizing client-side would
|
|
14
|
+
* mean shipping a page of raw bodies to the browser and counting those,
|
|
15
|
+
* which answers "what are the top errors in the 5000 rows I happened to
|
|
16
|
+
* fetch" — a different, and much less useful, question than "what are the
|
|
17
|
+
* top errors in this window".
|
|
18
|
+
*
|
|
19
|
+
* Shape of the emitted expression, for rules r0..rN in order:
|
|
20
|
+
*
|
|
21
|
+
* trimBoth(substringUTF8(trimBoth(
|
|
22
|
+
* replaceRegexpAll(...replaceRegexpAll(ifNull(body,''), p0, x0)..., pN, xN)
|
|
23
|
+
* ), 1, 300))
|
|
24
|
+
*
|
|
25
|
+
* The innermost call is the FIRST rule, matching the sequential application
|
|
26
|
+
* order `normalizeLogBodyToErrorPattern` uses, and the trim/truncate/trim
|
|
27
|
+
* tail mirrors its `.trim()` -> `.slice()` -> `.trim()`. The shape is pinned
|
|
28
|
+
* by Common/Tests/Server/Utils/Telemetry/LogErrorPatternSql.test.ts.
|
|
29
|
+
*
|
|
30
|
+
* Truncation uses substringUTF8, NOT substring. ClickHouse's `substring`
|
|
31
|
+
* counts BYTES, so a 300-byte cut through a Japanese message or an emoji
|
|
32
|
+
* lands mid-sequence and the group key ends in a broken UTF-8 fragment. The
|
|
33
|
+
* UTF8 variant counts characters, which is also what the JavaScript
|
|
34
|
+
* normalizer's `.slice()` approximates. The two are not bit-identical for
|
|
35
|
+
* astral-plane characters (JS slices UTF-16 code units, so an emoji costs it
|
|
36
|
+
* two) — that only shifts where a very long pattern is cut, never what it
|
|
37
|
+
* groups, and is deliberately not claimed as exact parity.
|
|
38
|
+
*
|
|
39
|
+
* Patterns and replacements ride as bound query parameters rather than
|
|
40
|
+
* being interpolated. ClickHouse substitutes parameters into the AST as
|
|
41
|
+
* constant literals during parsing, so `replaceRegexpAll` still sees the
|
|
42
|
+
* constant regexp argument it requires (the same shape the Sigma compiler
|
|
43
|
+
* already relies on for `match(expr, {p:String})`), and no rule text ever
|
|
44
|
+
* reaches the SQL text itself.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The column expression the pattern is computed from.
|
|
49
|
+
*
|
|
50
|
+
* `body` is Nullable(String) on the Log table, and `replaceRegexpAll(NULL,
|
|
51
|
+
* ...)` is NULL — which would collapse every body-less row into one NULL
|
|
52
|
+
* group. Coalescing first turns those into the empty pattern, which the
|
|
53
|
+
* callers exclude with a `!= ''` predicate.
|
|
54
|
+
*/
|
|
55
|
+
export const LOG_ERROR_PATTERN_SOURCE_EXPRESSION: string = "ifNull(body, '')";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Build the pattern expression over `sourceExpression`.
|
|
59
|
+
*
|
|
60
|
+
* `sourceExpression` is appended to the statement as trusted SQL — it must
|
|
61
|
+
* be a literal owned by this codebase (in practice always
|
|
62
|
+
* LOG_ERROR_PATTERN_SOURCE_EXPRESSION), never anything derived from a
|
|
63
|
+
* request.
|
|
64
|
+
*/
|
|
65
|
+
export function buildLogErrorPatternExpression(
|
|
66
|
+
sourceExpression: string = LOG_ERROR_PATTERN_SOURCE_EXPRESSION,
|
|
67
|
+
): Statement {
|
|
68
|
+
const statement: Statement = new Statement();
|
|
69
|
+
|
|
70
|
+
statement.append("trimBoth(substringUTF8(trimBoth(");
|
|
71
|
+
|
|
72
|
+
// One open paren per rule; the arguments below close them inside-out.
|
|
73
|
+
statement.append("replaceRegexpAll(".repeat(LOG_ERROR_PATTERN_RULES.length));
|
|
74
|
+
|
|
75
|
+
statement.append(sourceExpression);
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* Ascending order: rule 0's arguments close the innermost call, so it is
|
|
79
|
+
* applied first — exactly as the JavaScript normalizer iterates.
|
|
80
|
+
*/
|
|
81
|
+
for (const rule of LOG_ERROR_PATTERN_RULES) {
|
|
82
|
+
statement.append(
|
|
83
|
+
SQL`, ${{
|
|
84
|
+
type: TableColumnType.Text,
|
|
85
|
+
value: rule.pattern,
|
|
86
|
+
}}, ${{
|
|
87
|
+
type: TableColumnType.Text,
|
|
88
|
+
value: rule.replacement,
|
|
89
|
+
}})`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
statement.append(
|
|
94
|
+
SQL`), 1, ${{
|
|
95
|
+
type: TableColumnType.Number,
|
|
96
|
+
value: LOG_ERROR_PATTERN_MAX_LENGTH,
|
|
97
|
+
}}))`,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return statement;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* How many bound parameters `buildLogErrorPatternExpression` contributes.
|
|
105
|
+
* Exported so callers reasoning about parameter budgets (and the tests that
|
|
106
|
+
* pin statement shapes) do not have to count rules by hand.
|
|
107
|
+
*/
|
|
108
|
+
export function getLogErrorPatternParameterCount(): number {
|
|
109
|
+
return LOG_ERROR_PATTERN_RULES.length * 2 + 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Guard for a caller-supplied pattern value (the detail endpoints echo one
|
|
114
|
+
* back to scope their queries), bounding the parameter without changing
|
|
115
|
+
* which rows it matches.
|
|
116
|
+
*
|
|
117
|
+
* Counted in CODE POINTS, because that is what the expression above cuts
|
|
118
|
+
* by. Measuring in JavaScript's UTF-16 code units instead would mangle a
|
|
119
|
+
* legitimate key: a 300-code-point pattern containing one emoji has
|
|
120
|
+
* `.length === 301`, so the clamp would fire on a value the database
|
|
121
|
+
* considers exactly at the limit and slice it — leaving a lone surrogate at
|
|
122
|
+
* the tail when the emoji sits there. The bind would then match zero rows
|
|
123
|
+
* and, since nothing throws, every drill-down panel would come back
|
|
124
|
+
* cheerfully empty for a Top Errors row showing a real count.
|
|
125
|
+
*/
|
|
126
|
+
export function clampLogErrorPattern(pattern: string): string {
|
|
127
|
+
const codePoints: Array<string> = Array.from(pattern);
|
|
128
|
+
|
|
129
|
+
if (codePoints.length <= LOG_ERROR_PATTERN_MAX_LENGTH) {
|
|
130
|
+
return pattern;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return codePoints.slice(0, LOG_ERROR_PATTERN_MAX_LENGTH).join("");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type { LogErrorPatternRule };
|