@oneuptime/common 12.0.15 → 12.0.17
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 +568 -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/1788600000000-AddDetectionRuleIncidentColumns.ts +39 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +14 -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 +805 -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/App/Dashboard/SecurityEventsDetectionRulesPage.test.tsx +250 -0
- package/Tests/App/Dashboard/SecurityEventsMonitorStepForm.test.tsx +106 -0
- package/Tests/App/Dashboard/SecurityEventsMonitorsPage.test.tsx +185 -0
- package/Tests/App/Dashboard/SecurityEventsSetupGuide.test.tsx +200 -0
- package/Tests/Models/DatabaseModels/DomainRoleTierCoverage.test.ts +323 -0
- package/Tests/Models/DatabaseModels/ProjectSharedResources.test.ts +386 -0
- package/Tests/Models/DetectionRuleCreateContract.test.ts +35 -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 +1098 -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/DetectionFindingConstants.ts +24 -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 +598 -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/1788600000000-AddDetectionRuleIncidentColumns.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788600000000-AddDetectionRuleIncidentColumns.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +14 -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 +600 -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/DetectionFindingConstants.js +18 -0
- package/build/dist/Types/SecurityEvent/DetectionFindingConstants.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,317 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import MetricType from "../../../Models/DatabaseModels/MetricType";
|
|
11
|
+
import { MetricPointType } from "../../../Models/AnalyticsModels/Metric";
|
|
12
|
+
import AggregationInterval from "../../../Types/BaseDatabase/AggregationInterval";
|
|
13
|
+
import AggregationType from "../../../Types/BaseDatabase/AggregationType";
|
|
14
|
+
import InBetween from "../../../Types/BaseDatabase/InBetween";
|
|
15
|
+
import LIMIT_MAX, { LIMIT_PER_PROJECT } from "../../../Types/Database/LimitMax";
|
|
16
|
+
import OneUptimeDate from "../../../Types/Date";
|
|
17
|
+
import ObjectID from "../../../Types/ObjectID";
|
|
18
|
+
import ServiceType from "../../../Types/Telemetry/ServiceType";
|
|
19
|
+
import LlmCostBudgetService from "../../Services/LlmCostBudgetService";
|
|
20
|
+
import MetricService from "../../Services/MetricService";
|
|
21
|
+
import SpanService from "../../Services/SpanService";
|
|
22
|
+
import logger from "../Logger";
|
|
23
|
+
import CaptureSpan from "../Telemetry/CaptureSpan";
|
|
24
|
+
import TelemetryUtil from "./Telemetry";
|
|
25
|
+
/*
|
|
26
|
+
* Evaluates LLM cost budgets against the day's LLM span spend.
|
|
27
|
+
*
|
|
28
|
+
* The worker job (App/FeatureSet/Workers/Jobs/Llm/EvaluateLlmCostBudgets.ts)
|
|
29
|
+
* calls evaluateAllBudgets() on a 15-minute tick. For each enabled budget it
|
|
30
|
+
* sums the UTC day's llmCost from ClickHouse (scoped by the budget's optional
|
|
31
|
+
* service / provider / model filters), stamps the spend back onto the budget
|
|
32
|
+
* row for the dashboard, and publishes two gauge metrics:
|
|
33
|
+
*
|
|
34
|
+
* oneuptime.llm.budget.spend.usd — the day's spend so far, in USD
|
|
35
|
+
* oneuptime.llm.budget.percent.used — spend as a percent of the budget
|
|
36
|
+
*
|
|
37
|
+
* Budgets do NOT alert directly. Alerting is a Metrics monitor on these
|
|
38
|
+
* series — filter by the oneuptime.llm.budget.id attribute (stable across
|
|
39
|
+
* renames; the name attribute is for charts and changes when the budget is
|
|
40
|
+
* renamed) — which brings thresholds, formulas, anomaly baselines, incidents
|
|
41
|
+
* and on-call routing without a parallel alerting pipeline here.
|
|
42
|
+
*
|
|
43
|
+
* The series gets ONE point per budget per 15-minute sweep. A monitor on it
|
|
44
|
+
* must use a rolling window of at least 15 minutes (30 recommended): the
|
|
45
|
+
* 1-minute default would see an empty series between sweeps and flap.
|
|
46
|
+
*/
|
|
47
|
+
export const LLM_BUDGET_SPEND_METRIC_NAME = "oneuptime.llm.budget.spend.usd";
|
|
48
|
+
export const LLM_BUDGET_PERCENT_METRIC_NAME = "oneuptime.llm.budget.percent.used";
|
|
49
|
+
// Attribute keys carried by both budget metrics, for monitor/chart filtering.
|
|
50
|
+
export const LLM_BUDGET_ID_ATTRIBUTE = "oneuptime.llm.budget.id";
|
|
51
|
+
export const LLM_BUDGET_NAME_ATTRIBUTE = "oneuptime.llm.budget.name";
|
|
52
|
+
export const LLM_BUDGET_PROVIDER_ATTRIBUTE = "oneuptime.llm.budget.provider";
|
|
53
|
+
export const LLM_BUDGET_MODEL_ATTRIBUTE = "oneuptime.llm.budget.model";
|
|
54
|
+
export const LLM_BUDGET_SERVICE_ID_ATTRIBUTE = "oneuptime.llm.budget.service.id";
|
|
55
|
+
/*
|
|
56
|
+
* Matches the derived-metric retention the trace/metric recording rules use.
|
|
57
|
+
* The series exists for monitors and short-range charts; long-range spend
|
|
58
|
+
* history belongs to the spans themselves.
|
|
59
|
+
*/
|
|
60
|
+
const BUDGET_METRIC_RETENTION_IN_DAYS = 15;
|
|
61
|
+
export default class LlmCostBudgetEvaluator {
|
|
62
|
+
/**
|
|
63
|
+
* Percent of the daily budget consumed. 0 when the budget is missing or
|
|
64
|
+
* invalid — never NaN/Infinity, since these values feed monitors.
|
|
65
|
+
*/
|
|
66
|
+
static computePercentUsed(data) {
|
|
67
|
+
if (!isFinite(data.dailyBudgetInUSD) ||
|
|
68
|
+
data.dailyBudgetInUSD <= 0 ||
|
|
69
|
+
!isFinite(data.spendInUSD) ||
|
|
70
|
+
data.spendInUSD < 0) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
const percent = (data.spendInUSD / data.dailyBudgetInUSD) * 100;
|
|
74
|
+
// Trim float noise; hundredth-of-a-percent resolution is plenty.
|
|
75
|
+
return Math.round(percent * 100) / 100;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Start of the UTC day `now` falls in. UTC-explicit (not process-zone) so
|
|
79
|
+
* the budget day is the same day everywhere OneUptime runs.
|
|
80
|
+
*/
|
|
81
|
+
static getUtcDayStart(now) {
|
|
82
|
+
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Build the ClickHouse span filter for a budget: the UTC day so far,
|
|
86
|
+
* LLM spans only, narrowed by the budget's optional service / provider /
|
|
87
|
+
* model scoping.
|
|
88
|
+
*/
|
|
89
|
+
static buildSpanQuery(data) {
|
|
90
|
+
const query = {
|
|
91
|
+
projectId: data.budget.projectId,
|
|
92
|
+
isLlmSpan: true,
|
|
93
|
+
/*
|
|
94
|
+
* Bound rows to the window — aggregateBy's startTimestamp/endTimestamp
|
|
95
|
+
* only pick the bucket grid, they do not filter rows.
|
|
96
|
+
*/
|
|
97
|
+
startTime: new InBetween(data.dayStart, data.now),
|
|
98
|
+
};
|
|
99
|
+
if (data.budget.serviceId) {
|
|
100
|
+
query["primaryEntityId"] =
|
|
101
|
+
data.budget.serviceId;
|
|
102
|
+
}
|
|
103
|
+
if (data.budget.llmSystem) {
|
|
104
|
+
query["llmSystem"] = data.budget.llmSystem;
|
|
105
|
+
}
|
|
106
|
+
if (data.budget.llmModel) {
|
|
107
|
+
query["llmRequestModel"] =
|
|
108
|
+
data.budget.llmModel;
|
|
109
|
+
}
|
|
110
|
+
return query;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Build the two metric rows one evaluation publishes for one budget.
|
|
114
|
+
* Pure — mirrors the derived-metric row shape the trace recording rules
|
|
115
|
+
* write — so the series shape is unit-testable.
|
|
116
|
+
*/
|
|
117
|
+
static buildBudgetMetricRows(data) {
|
|
118
|
+
var _a;
|
|
119
|
+
const attributes = {
|
|
120
|
+
[LLM_BUDGET_ID_ATTRIBUTE]: ((_a = data.budget.id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
|
|
121
|
+
[LLM_BUDGET_NAME_ATTRIBUTE]: data.budget.name || "",
|
|
122
|
+
};
|
|
123
|
+
if (data.budget.serviceId) {
|
|
124
|
+
attributes[LLM_BUDGET_SERVICE_ID_ATTRIBUTE] =
|
|
125
|
+
data.budget.serviceId.toString();
|
|
126
|
+
}
|
|
127
|
+
if (data.budget.llmSystem) {
|
|
128
|
+
attributes[LLM_BUDGET_PROVIDER_ATTRIBUTE] = data.budget.llmSystem;
|
|
129
|
+
}
|
|
130
|
+
if (data.budget.llmModel) {
|
|
131
|
+
attributes[LLM_BUDGET_MODEL_ATTRIBUTE] = data.budget.llmModel;
|
|
132
|
+
}
|
|
133
|
+
const retentionDate = OneUptimeDate.addRemoveDays(data.now, BUDGET_METRIC_RETENTION_IN_DAYS);
|
|
134
|
+
const buildRow = (name, value) => {
|
|
135
|
+
return {
|
|
136
|
+
_id: ObjectID.generateTimeOrdered().toString(),
|
|
137
|
+
projectId: data.budget.projectId.toString(),
|
|
138
|
+
createdAt: OneUptimeDate.toClickhouseDateTime(data.now),
|
|
139
|
+
time: OneUptimeDate.toClickhouseDateTime(data.now),
|
|
140
|
+
timeUnixNano: (data.now.getTime() * 1000000).toString(),
|
|
141
|
+
primaryEntityType: ServiceType.OpenTelemetry,
|
|
142
|
+
name: name,
|
|
143
|
+
metricPointType: MetricPointType.Gauge,
|
|
144
|
+
value: value,
|
|
145
|
+
attributes: attributes,
|
|
146
|
+
attributeKeys: Object.keys(attributes).sort(),
|
|
147
|
+
retentionDate: OneUptimeDate.toClickhouseDateTime(retentionDate),
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
return [
|
|
151
|
+
buildRow(LLM_BUDGET_SPEND_METRIC_NAME, data.spendInUSD),
|
|
152
|
+
buildRow(LLM_BUDGET_PERCENT_METRIC_NAME, data.percentUsed),
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Evaluate every enabled budget. One bad budget never aborts the sweep.
|
|
157
|
+
*/
|
|
158
|
+
static async evaluateAllBudgets() {
|
|
159
|
+
var _a, _b, _c, _d;
|
|
160
|
+
const budgets = await LlmCostBudgetService.findBy({
|
|
161
|
+
query: {
|
|
162
|
+
isEnabled: true,
|
|
163
|
+
},
|
|
164
|
+
select: {
|
|
165
|
+
_id: true,
|
|
166
|
+
projectId: true,
|
|
167
|
+
name: true,
|
|
168
|
+
dailyBudgetInUSD: true,
|
|
169
|
+
serviceId: true,
|
|
170
|
+
llmSystem: true,
|
|
171
|
+
llmModel: true,
|
|
172
|
+
},
|
|
173
|
+
limit: LIMIT_MAX,
|
|
174
|
+
skip: 0,
|
|
175
|
+
props: {
|
|
176
|
+
isRoot: true,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
if (budgets.length === 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
logger.debug(`Llm:EvaluateLlmCostBudgets: evaluating ${budgets.length} enabled budget(s)`);
|
|
183
|
+
const now = new Date();
|
|
184
|
+
for (const budget of budgets) {
|
|
185
|
+
try {
|
|
186
|
+
await this.evaluateBudget({ budget, now });
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
logger.error(`LLM cost budget ${(_a = budget.id) === null || _a === void 0 ? void 0 : _a.toString()} for project ${(_c = (_b = budget.projectId) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "?"} failed: ${err instanceof Error ? err.message : String(err)}`, { projectId: (_d = budget.projectId) === null || _d === void 0 ? void 0 : _d.toString() });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Evaluate one budget: sum the day's spend, stamp it on the row, and
|
|
195
|
+
* publish the spend / percent-used metric points.
|
|
196
|
+
*/
|
|
197
|
+
static async evaluateBudget(data) {
|
|
198
|
+
const budget = data.budget;
|
|
199
|
+
if (!budget.id || !budget.projectId || !budget.dailyBudgetInUSD) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const dayStart = this.getUtcDayStart(data.now);
|
|
203
|
+
const spendInUSD = await this.getSpendInUSD({
|
|
204
|
+
budget: budget,
|
|
205
|
+
dayStart: dayStart,
|
|
206
|
+
now: data.now,
|
|
207
|
+
});
|
|
208
|
+
const percentUsed = this.computePercentUsed({
|
|
209
|
+
spendInUSD: spendInUSD,
|
|
210
|
+
dailyBudgetInUSD: budget.dailyBudgetInUSD,
|
|
211
|
+
});
|
|
212
|
+
// Stamp the spend for the dashboard's Budgets tab.
|
|
213
|
+
await LlmCostBudgetService.updateOneById({
|
|
214
|
+
id: budget.id,
|
|
215
|
+
data: {
|
|
216
|
+
currentDaySpendInUSD: spendInUSD,
|
|
217
|
+
spendLastEvaluatedAt: data.now,
|
|
218
|
+
},
|
|
219
|
+
props: {
|
|
220
|
+
isRoot: true,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
await this.writeBudgetMetrics({
|
|
224
|
+
budget: budget,
|
|
225
|
+
spendInUSD: spendInUSD,
|
|
226
|
+
percentUsed: percentUsed,
|
|
227
|
+
now: data.now,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Sum the day's llmCost for the budget's scope from ClickHouse.
|
|
232
|
+
*/
|
|
233
|
+
static async getSpendInUSD(data) {
|
|
234
|
+
const aggregateBy = {
|
|
235
|
+
query: this.buildSpanQuery(data),
|
|
236
|
+
aggregationType: AggregationType.Sum,
|
|
237
|
+
aggregateColumnName: "llmCost",
|
|
238
|
+
aggregationTimestampColumnName: "startTime",
|
|
239
|
+
startTimestamp: data.dayStart,
|
|
240
|
+
endTimestamp: data.now,
|
|
241
|
+
// One total over the whole window — no time bucketing.
|
|
242
|
+
aggregationInterval: AggregationInterval.Total,
|
|
243
|
+
/*
|
|
244
|
+
* The sum feeds monitors: fail loud on a query timeout — the default
|
|
245
|
+
* 'break' overflow mode returns silently-partial sums, which would
|
|
246
|
+
* understate spend and suppress a real budget breach downstream.
|
|
247
|
+
*/
|
|
248
|
+
timeoutOverflowMode: "throw",
|
|
249
|
+
limit: LIMIT_PER_PROJECT,
|
|
250
|
+
skip: 0,
|
|
251
|
+
props: {
|
|
252
|
+
isRoot: true,
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
const result = await SpanService.aggregateBy(aggregateBy);
|
|
256
|
+
return (result.data || []).reduce((acc, row) => {
|
|
257
|
+
return acc + Number(row.value || 0);
|
|
258
|
+
}, 0);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Publish the budget's spend and percent-used gauge points, and register
|
|
262
|
+
* the metric names so they appear in the dashboard's metric picker and the
|
|
263
|
+
* Metrics-monitor builder.
|
|
264
|
+
*/
|
|
265
|
+
static async writeBudgetMetrics(data) {
|
|
266
|
+
const rows = this.buildBudgetMetricRows(data);
|
|
267
|
+
await MetricService.insertJsonRows(rows);
|
|
268
|
+
const spendType = new MetricType();
|
|
269
|
+
spendType.name = LLM_BUDGET_SPEND_METRIC_NAME;
|
|
270
|
+
spendType.description =
|
|
271
|
+
"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.";
|
|
272
|
+
spendType.unit = "USD";
|
|
273
|
+
const percentType = new MetricType();
|
|
274
|
+
percentType.name = LLM_BUDGET_PERCENT_METRIC_NAME;
|
|
275
|
+
percentType.description =
|
|
276
|
+
"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.";
|
|
277
|
+
percentType.unit = "%";
|
|
278
|
+
/*
|
|
279
|
+
* Registration is what makes the names show up in the metric picker —
|
|
280
|
+
* fire-and-forget, a registration failure must not fail the sweep.
|
|
281
|
+
*/
|
|
282
|
+
TelemetryUtil.indexMetricNameServiceNameMap({
|
|
283
|
+
metricNameServiceNameMap: {
|
|
284
|
+
[LLM_BUDGET_SPEND_METRIC_NAME]: spendType,
|
|
285
|
+
[LLM_BUDGET_PERCENT_METRIC_NAME]: percentType,
|
|
286
|
+
},
|
|
287
|
+
projectId: data.budget.projectId,
|
|
288
|
+
}).catch((err) => {
|
|
289
|
+
logger.error(err);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
__decorate([
|
|
294
|
+
CaptureSpan(),
|
|
295
|
+
__metadata("design:type", Function),
|
|
296
|
+
__metadata("design:paramtypes", []),
|
|
297
|
+
__metadata("design:returntype", Promise)
|
|
298
|
+
], LlmCostBudgetEvaluator, "evaluateAllBudgets", null);
|
|
299
|
+
__decorate([
|
|
300
|
+
CaptureSpan(),
|
|
301
|
+
__metadata("design:type", Function),
|
|
302
|
+
__metadata("design:paramtypes", [Object]),
|
|
303
|
+
__metadata("design:returntype", Promise)
|
|
304
|
+
], LlmCostBudgetEvaluator, "evaluateBudget", null);
|
|
305
|
+
__decorate([
|
|
306
|
+
CaptureSpan(),
|
|
307
|
+
__metadata("design:type", Function),
|
|
308
|
+
__metadata("design:paramtypes", [Object]),
|
|
309
|
+
__metadata("design:returntype", Promise)
|
|
310
|
+
], LlmCostBudgetEvaluator, "getSpendInUSD", null);
|
|
311
|
+
__decorate([
|
|
312
|
+
CaptureSpan(),
|
|
313
|
+
__metadata("design:type", Function),
|
|
314
|
+
__metadata("design:paramtypes", [Object]),
|
|
315
|
+
__metadata("design:returntype", Promise)
|
|
316
|
+
], LlmCostBudgetEvaluator, "writeBudgetMetrics", null);
|
|
317
|
+
//# sourceMappingURL=LlmCostBudgetEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LlmCostBudgetEvaluator.js","sourceRoot":"","sources":["../../../../../Server/Utils/Telemetry/LlmCostBudgetEvaluator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,UAAU,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAGzE,OAAO,mBAAmB,MAAM,iDAAiD,CAAC;AAClF,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,OAAO,SAAS,MAAM,uCAAuC,CAAC;AAE9D,OAAO,SAAS,EAAE,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,OAAO,oBAAoB,MAAM,qCAAqC,CAAC;AACvE,OAAO,aAAa,MAAM,8BAA8B,CAAC;AACzD,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,MAAyB,MAAM,WAAW,CAAC;AAClD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,CAAC,MAAM,4BAA4B,GACvC,gCAAgC,CAAC;AACnC,MAAM,CAAC,MAAM,8BAA8B,GACzC,mCAAmC,CAAC;AAEtC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uBAAuB,GAAW,yBAAyB,CAAC;AACzE,MAAM,CAAC,MAAM,yBAAyB,GAAW,2BAA2B,CAAC;AAC7E,MAAM,CAAC,MAAM,6BAA6B,GACxC,+BAA+B,CAAC;AAClC,M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;AAOmB;IADnB,WAAW,EAAE;;;;kDA0Cb;AAMoB;IADpB,WAAW,EAAE;;;;iDAoCb;AAQoB;IADpB,WAAW,EAAE;;;;sDAoCb"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LlmCostCatalogUtil, } from "../../../Types/Telemetry/LlmCostCatalog";
|
|
2
|
+
import { LlmAgentNameAttributeKeys, LlmAttributeNamespacePrefixes, LlmConversationIdAttributeKeys, LlmCostAttributeKeys, LlmInputTokenAttributeKeys, LlmOperationAttributeKeys, LlmOutputTokenAttributeKeys, LlmRequestModelAttributeKeys, LlmResponseModelAttributeKeys, LlmSystemAttributeKeys, LlmToolNameAttributeKeys, LlmTotalTokenAttributeKeys, } from "../../../Types/Telemetry/LlmConventions";
|
|
2
3
|
export default class LlmSpanUtil {
|
|
3
4
|
/**
|
|
4
5
|
* Return the empty/default LLM field set (non-LLM span).
|
|
@@ -16,13 +17,18 @@ export default class LlmSpanUtil {
|
|
|
16
17
|
llmCost: 0,
|
|
17
18
|
llmAgentName: "",
|
|
18
19
|
llmToolName: "",
|
|
20
|
+
llmConversationId: "",
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Extract first-class LLM fields from a flattened span attribute dictionary.
|
|
23
25
|
* Pure + side-effect free so it can be unit tested in isolation.
|
|
26
|
+
*
|
|
27
|
+
* `projectPriceOverrides` are the project's custom model prices (loaded by
|
|
28
|
+
* the ingest pipeline); they take part in the cost fallback below with
|
|
29
|
+
* longest-prefix-wins semantics against the built-in catalog.
|
|
24
30
|
*/
|
|
25
|
-
static extract(attributes) {
|
|
31
|
+
static extract(attributes, projectPriceOverrides) {
|
|
26
32
|
const fields = this.empty();
|
|
27
33
|
if (!attributes || typeof attributes !== "object") {
|
|
28
34
|
return fields;
|
|
@@ -52,10 +58,47 @@ export default class LlmSpanUtil {
|
|
|
52
58
|
(fields.llmInputTokens > 0 || fields.llmOutputTokens > 0)) {
|
|
53
59
|
fields.llmTotalTokens = fields.llmInputTokens + fields.llmOutputTokens;
|
|
54
60
|
}
|
|
55
|
-
|
|
61
|
+
/*
|
|
62
|
+
* Cost must distinguish "reported as 0" from "not reported at all": a
|
|
63
|
+
* gateway fronting a free local model (or a fully-cached call) reports an
|
|
64
|
+
* explicit cost of 0, and that 0 must win over any catalog estimate.
|
|
65
|
+
*/
|
|
66
|
+
const reportedCost = this.getNumberOrNull(attributes, LlmCostAttributeKeys);
|
|
67
|
+
fields.llmCost = reportedCost !== null && reportedCost !== void 0 ? reportedCost : 0;
|
|
56
68
|
fields.llmAgentName = this.getString(attributes, LlmAgentNameAttributeKeys);
|
|
57
69
|
fields.llmToolName = this.getString(attributes, LlmToolNameAttributeKeys);
|
|
58
70
|
fields.isLlmSpan = this.detectIsLlmSpan(keys, fields);
|
|
71
|
+
/*
|
|
72
|
+
* Conversation id is gated on isLlmSpan because one of its candidate keys
|
|
73
|
+
* ("session.id") is the generic OTel key RUM browser spans carry — those
|
|
74
|
+
* already denormalize it into the sessionId column, and stamping it here
|
|
75
|
+
* too would duplicate it (and its bloom-filter index) across the
|
|
76
|
+
* highest-volume span class for no reader.
|
|
77
|
+
*/
|
|
78
|
+
if (fields.isLlmSpan) {
|
|
79
|
+
fields.llmConversationId = this.getString(attributes, LlmConversationIdAttributeKeys);
|
|
80
|
+
}
|
|
81
|
+
/*
|
|
82
|
+
* Cost fallback: the SDK-reported cost always wins — including an
|
|
83
|
+
* explicit 0 — but most instrumentations only report token counts. Price
|
|
84
|
+
* those against the project's custom price overrides and the built-in
|
|
85
|
+
* list-price catalog (longest prefix wins across both, project entries
|
|
86
|
+
* beat built-ins on ties) so spend shows up in dashboards and cost
|
|
87
|
+
* budgets without per-SDK pricing math. The response model is priced in
|
|
88
|
+
* preference to the request model — it names what the provider actually
|
|
89
|
+
* served (e.g. an alias like "gpt-4o" resolved to a dated snapshot).
|
|
90
|
+
*/
|
|
91
|
+
if (fields.isLlmSpan && reportedCost === null) {
|
|
92
|
+
const computedCost = LlmCostCatalogUtil.computeCostInUSD({
|
|
93
|
+
model: fields.llmResponseModel || fields.llmRequestModel,
|
|
94
|
+
inputTokens: fields.llmInputTokens,
|
|
95
|
+
outputTokens: fields.llmOutputTokens,
|
|
96
|
+
projectPriceOverrides: projectPriceOverrides,
|
|
97
|
+
});
|
|
98
|
+
if (computedCost !== null) {
|
|
99
|
+
fields.llmCost = computedCost;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
59
102
|
return fields;
|
|
60
103
|
}
|
|
61
104
|
static detectIsLlmSpan(keys, fields) {
|
|
@@ -92,6 +135,15 @@ export default class LlmSpanUtil {
|
|
|
92
135
|
return "";
|
|
93
136
|
}
|
|
94
137
|
static getNumber(attributes, candidateKeys) {
|
|
138
|
+
var _a;
|
|
139
|
+
return (_a = this.getNumberOrNull(attributes, candidateKeys)) !== null && _a !== void 0 ? _a : 0;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Like getNumber but null when no candidate key carries a parseable number
|
|
143
|
+
* — callers that must distinguish "reported as 0" from "absent" (cost) use
|
|
144
|
+
* this directly.
|
|
145
|
+
*/
|
|
146
|
+
static getNumberOrNull(attributes, candidateKeys) {
|
|
95
147
|
for (const key of candidateKeys) {
|
|
96
148
|
const value = attributes[key];
|
|
97
149
|
if (value === undefined || value === null || Array.isArray(value)) {
|
|
@@ -107,7 +159,7 @@ export default class LlmSpanUtil {
|
|
|
107
159
|
}
|
|
108
160
|
}
|
|
109
161
|
}
|
|
110
|
-
return
|
|
162
|
+
return null;
|
|
111
163
|
}
|
|
112
164
|
}
|
|
113
165
|
//# sourceMappingURL=LlmSpan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlmSpan.js","sourceRoot":"","sources":["../../../../../Server/Utils/Telemetry/LlmSpan.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EAC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AE,CAAC;gBAClE,SAAS;YACX,CAAC;YAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACrD,MAAM,MAAM,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC;gBAErC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBACrB,OAAO,MAAM,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import TableColumnType from "../../../Types/AnalyticsDatabase/TableColumnType";
|
|
2
|
+
import { SQL, Statement } from "../AnalyticsDatabase/Statement";
|
|
3
|
+
import { LOG_ERROR_PATTERN_MAX_LENGTH, LOG_ERROR_PATTERN_RULES, } from "../../../Utils/Telemetry/LogErrorPattern";
|
|
4
|
+
/*
|
|
5
|
+
* Compiles the shared error-pattern rules (Common/Utils/Telemetry/
|
|
6
|
+
* LogErrorPattern) into the ClickHouse expression that does the grouping.
|
|
7
|
+
*
|
|
8
|
+
* The grouping has to happen in the database. Normalizing client-side would
|
|
9
|
+
* mean shipping a page of raw bodies to the browser and counting those,
|
|
10
|
+
* which answers "what are the top errors in the 5000 rows I happened to
|
|
11
|
+
* fetch" — a different, and much less useful, question than "what are the
|
|
12
|
+
* top errors in this window".
|
|
13
|
+
*
|
|
14
|
+
* Shape of the emitted expression, for rules r0..rN in order:
|
|
15
|
+
*
|
|
16
|
+
* trimBoth(substringUTF8(trimBoth(
|
|
17
|
+
* replaceRegexpAll(...replaceRegexpAll(ifNull(body,''), p0, x0)..., pN, xN)
|
|
18
|
+
* ), 1, 300))
|
|
19
|
+
*
|
|
20
|
+
* The innermost call is the FIRST rule, matching the sequential application
|
|
21
|
+
* order `normalizeLogBodyToErrorPattern` uses, and the trim/truncate/trim
|
|
22
|
+
* tail mirrors its `.trim()` -> `.slice()` -> `.trim()`. The shape is pinned
|
|
23
|
+
* by Common/Tests/Server/Utils/Telemetry/LogErrorPatternSql.test.ts.
|
|
24
|
+
*
|
|
25
|
+
* Truncation uses substringUTF8, NOT substring. ClickHouse's `substring`
|
|
26
|
+
* counts BYTES, so a 300-byte cut through a Japanese message or an emoji
|
|
27
|
+
* lands mid-sequence and the group key ends in a broken UTF-8 fragment. The
|
|
28
|
+
* UTF8 variant counts characters, which is also what the JavaScript
|
|
29
|
+
* normalizer's `.slice()` approximates. The two are not bit-identical for
|
|
30
|
+
* astral-plane characters (JS slices UTF-16 code units, so an emoji costs it
|
|
31
|
+
* two) — that only shifts where a very long pattern is cut, never what it
|
|
32
|
+
* groups, and is deliberately not claimed as exact parity.
|
|
33
|
+
*
|
|
34
|
+
* Patterns and replacements ride as bound query parameters rather than
|
|
35
|
+
* being interpolated. ClickHouse substitutes parameters into the AST as
|
|
36
|
+
* constant literals during parsing, so `replaceRegexpAll` still sees the
|
|
37
|
+
* constant regexp argument it requires (the same shape the Sigma compiler
|
|
38
|
+
* already relies on for `match(expr, {p:String})`), and no rule text ever
|
|
39
|
+
* reaches the SQL text itself.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* The column expression the pattern is computed from.
|
|
43
|
+
*
|
|
44
|
+
* `body` is Nullable(String) on the Log table, and `replaceRegexpAll(NULL,
|
|
45
|
+
* ...)` is NULL — which would collapse every body-less row into one NULL
|
|
46
|
+
* group. Coalescing first turns those into the empty pattern, which the
|
|
47
|
+
* callers exclude with a `!= ''` predicate.
|
|
48
|
+
*/
|
|
49
|
+
export const LOG_ERROR_PATTERN_SOURCE_EXPRESSION = "ifNull(body, '')";
|
|
50
|
+
/**
|
|
51
|
+
* Build the pattern expression over `sourceExpression`.
|
|
52
|
+
*
|
|
53
|
+
* `sourceExpression` is appended to the statement as trusted SQL — it must
|
|
54
|
+
* be a literal owned by this codebase (in practice always
|
|
55
|
+
* LOG_ERROR_PATTERN_SOURCE_EXPRESSION), never anything derived from a
|
|
56
|
+
* request.
|
|
57
|
+
*/
|
|
58
|
+
export function buildLogErrorPatternExpression(sourceExpression = LOG_ERROR_PATTERN_SOURCE_EXPRESSION) {
|
|
59
|
+
const statement = new Statement();
|
|
60
|
+
statement.append("trimBoth(substringUTF8(trimBoth(");
|
|
61
|
+
// One open paren per rule; the arguments below close them inside-out.
|
|
62
|
+
statement.append("replaceRegexpAll(".repeat(LOG_ERROR_PATTERN_RULES.length));
|
|
63
|
+
statement.append(sourceExpression);
|
|
64
|
+
/*
|
|
65
|
+
* Ascending order: rule 0's arguments close the innermost call, so it is
|
|
66
|
+
* applied first — exactly as the JavaScript normalizer iterates.
|
|
67
|
+
*/
|
|
68
|
+
for (const rule of LOG_ERROR_PATTERN_RULES) {
|
|
69
|
+
statement.append(SQL `, ${{
|
|
70
|
+
type: TableColumnType.Text,
|
|
71
|
+
value: rule.pattern,
|
|
72
|
+
}}, ${{
|
|
73
|
+
type: TableColumnType.Text,
|
|
74
|
+
value: rule.replacement,
|
|
75
|
+
}})`);
|
|
76
|
+
}
|
|
77
|
+
statement.append(SQL `), 1, ${{
|
|
78
|
+
type: TableColumnType.Number,
|
|
79
|
+
value: LOG_ERROR_PATTERN_MAX_LENGTH,
|
|
80
|
+
}}))`);
|
|
81
|
+
return statement;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* How many bound parameters `buildLogErrorPatternExpression` contributes.
|
|
85
|
+
* Exported so callers reasoning about parameter budgets (and the tests that
|
|
86
|
+
* pin statement shapes) do not have to count rules by hand.
|
|
87
|
+
*/
|
|
88
|
+
export function getLogErrorPatternParameterCount() {
|
|
89
|
+
return LOG_ERROR_PATTERN_RULES.length * 2 + 1;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Guard for a caller-supplied pattern value (the detail endpoints echo one
|
|
93
|
+
* back to scope their queries), bounding the parameter without changing
|
|
94
|
+
* which rows it matches.
|
|
95
|
+
*
|
|
96
|
+
* Counted in CODE POINTS, because that is what the expression above cuts
|
|
97
|
+
* by. Measuring in JavaScript's UTF-16 code units instead would mangle a
|
|
98
|
+
* legitimate key: a 300-code-point pattern containing one emoji has
|
|
99
|
+
* `.length === 301`, so the clamp would fire on a value the database
|
|
100
|
+
* considers exactly at the limit and slice it — leaving a lone surrogate at
|
|
101
|
+
* the tail when the emoji sits there. The bind would then match zero rows
|
|
102
|
+
* and, since nothing throws, every drill-down panel would come back
|
|
103
|
+
* cheerfully empty for a Top Errors row showing a real count.
|
|
104
|
+
*/
|
|
105
|
+
export function clampLogErrorPattern(pattern) {
|
|
106
|
+
const codePoints = Array.from(pattern);
|
|
107
|
+
if (codePoints.length <= LOG_ERROR_PATTERN_MAX_LENGTH) {
|
|
108
|
+
return pattern;
|
|
109
|
+
}
|
|
110
|
+
return codePoints.slice(0, LOG_ERROR_PATTERN_MAX_LENGTH).join("");
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=LogErrorPatternSql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogErrorPatternSql.js","sourceRoot":"","sources":["../../../../../Server/Utils/Telemetry/LogErrorPatternSql.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,kDAAkD,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,GAExB,MAAM,0CAA0C,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAW,kBAAkB,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,8BAA8B,CAC5C,mBAA2B,mCAAmC;IAE9D,MAAM,SAAS,GAAc,IAAI,SAAS,EAAE,CA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
26
|
return `${userId.toString()}:${projectId.toString()}`;
|
|
27
27
|
}
|
|
28
|
+
/*
|
|
29
|
+
* Adds the implicit `ProjectUser` grant to a member's permission set.
|
|
30
|
+
*
|
|
31
|
+
* `ProjectUser` is not stored on any TeamPermission row - it is what being a
|
|
32
|
+
* member of the project means, and it is what shared workspace resources
|
|
33
|
+
* (saved table views, labels, teams, member profiles) are read through. A
|
|
34
|
+
* user whose teams only grant a domain role such as `MonitorViewer` holds no
|
|
35
|
+
* project-wide role, so without this the dashboard refuses to render the very
|
|
36
|
+
* pages that role exists to give them.
|
|
37
|
+
*
|
|
38
|
+
* Applied on the way out of the cache as well as at refresh time. A snapshot
|
|
39
|
+
* written before this existed would otherwise keep a signed-in member locked
|
|
40
|
+
* out until something invalidated it, and the cache entry lives for 30 days
|
|
41
|
+
* (GlobalCache.setString's default) unless a team or membership change
|
|
42
|
+
* rewrites it first.
|
|
43
|
+
*
|
|
44
|
+
* Deliberately NOT part of `getDefaultUserTenantAccessPermission`: that is
|
|
45
|
+
* also the permission set handed to a user who has not satisfied a project's
|
|
46
|
+
* SSO requirement, and such a user is not yet a member for this purpose.
|
|
47
|
+
*/
|
|
48
|
+
static withProjectUserPermission(permission) {
|
|
49
|
+
const alreadyGranted = permission.permissions.some((userPermission) => {
|
|
50
|
+
return userPermission.permission === Permission.ProjectUser;
|
|
51
|
+
});
|
|
52
|
+
if (alreadyGranted) {
|
|
53
|
+
return permission;
|
|
54
|
+
}
|
|
55
|
+
/*
|
|
56
|
+
* A new object rather than a push. The caller may be holding a snapshot
|
|
57
|
+
* that came out of a cache and is shared with something else; appending in
|
|
58
|
+
* place would grow that array once per read.
|
|
59
|
+
*/
|
|
60
|
+
return Object.assign(Object.assign({}, permission), { permissions: [
|
|
61
|
+
...permission.permissions,
|
|
62
|
+
{
|
|
63
|
+
permission: Permission.ProjectUser,
|
|
64
|
+
labelIds: [],
|
|
65
|
+
isBlockPermission: false,
|
|
66
|
+
_type: "UserPermission",
|
|
67
|
+
},
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
28
70
|
static async getUserTenantAccessPermissionFromCache(userId, projectId) {
|
|
29
71
|
const json = (await GlobalCache.getJSONObject(PermissionNamespace.ProjectPermission, this.buildTenantPermissionCacheKey(userId, projectId)));
|
|
30
72
|
if (json) {
|
|
@@ -33,7 +75,10 @@ export default class UserPermissionUtil {
|
|
|
33
75
|
if (!json) {
|
|
34
76
|
return null;
|
|
35
77
|
}
|
|
36
|
-
|
|
78
|
+
if (!json.permissions) {
|
|
79
|
+
json.permissions = [];
|
|
80
|
+
}
|
|
81
|
+
return this.withProjectUserPermission(json);
|
|
37
82
|
}
|
|
38
83
|
static async getUserGlobalAccessPermissionFromCache(userId) {
|
|
39
84
|
const json = await GlobalCache.getJSONObject("user", userId.toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserPermission.js","sourceRoot":"","sources":["../../../../../Server/Utils/UserPermission/UserPermission.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,UAIN,MAAM,2BAA2B,CAAC;AACnC,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,mBAAmB,MAAM,4CAA4C,CAAC;AAC7E,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;;;;;;;OAQG;IACI,MAAM,CAAC,6BAA6B,CACzC,MAAgB,EAChB,SAAmB;QAEnB,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxD,CAAC;IAGmB,AAAb,MAAM,CAAC,KAAK,CAAC,sCAAsC,CACxD,MAAgB,EAChB,SAAmB;QAEnB,MAAM,IAAI,GACR,CAAC,MAAM,WAAW,CAAC,aAAa,CAC9B,mBAAmB,CAAC,iBAAiB,EACrC,IAAI,CAAC,6BAA6B,CAAC,MAAM,EAAE,SAAS,CAAC,CACtD,CAA+B,CAAC;QAEnC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,GAAG,4BAA4B,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"UserPermission.js","sourceRoot":"","sources":["../../../../../Server/Utils/UserPermission/UserPermission.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,UAIN,MAAM,2BAA2B,CAAC;AACnC,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,mBAAmB,MAAM,4CAA4C,CAAC;AAC7E,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC;;;;;;;;OAQG;IACI,MAAM,CAAC,6BAA6B,CACzC,MAAgB,EAChB,SAAmB;QAEnB,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;IACxD,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACI,MAAM,CAAC,yBAAyB,CACrC,UAAsC;QAEtC,MAAM,cAAc,GAAY,UAAU,CAAC,WAAW,CAAC,IAAI,CACzD,CAAC,cAA8B,EAAE,EAAE;YACjC,OAAO,cAAc,CAAC,UAAU,KAAK,UAAU,CAAC,WAAW,CAAC;QAC9D,CAAC,CACF,CAAC;QAEF,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,UAAU,CAAC;QACpB,CAAC;QAED;;;;WAIG;QACH,uCACK,UAAU,KACb,WAAW,EAAE;gBACX,GAAG,UAAU,CAAC,WAAW;gBACzB;oBACE,UAAU,EAAE,UAAU,CAAC,WAAW;oBAClC,QAAQ,EAAE,EAAE;oBACZ,iBAAiB,EAAE,KAAK;oBACxB,KAAK,EAAE,gBA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nB,UAAU,EAAE,UAAU,CAAC,mBAAmB;YAC1C,QAAQ,EAAE,EAAE;YACZ,iBAAiB,EAAE,KAAK;YACxB,KAAK,EAAE,gBAAgB;SACxB,CAAC,CAAC;QAEH,MAAM,UAAU,GAA+B;YAC7C,SAAS;YACT,WAAW,EAAE,eAAe;YAC5B,iBAAiB,EAAE,KAAK;YACxB,KAAK,EAAE,4BAA4B;SACpC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA3EqB;IADnB,WAAW,EAAE;;qCAEJ,QAAQ;QACL,QAAQ;;sEAqBpB;AAGmB;IADnB,WAAW,EAAE;;qCAEJ,QAAQ;;sEAiBjB;AAGa;IADb,WAAW,EAAE;;qCAED,QAAQ;;oEA0BpB"}
|
|
@@ -34,6 +34,7 @@ export var AIChatCitationTargetType;
|
|
|
34
34
|
AIChatCitationTargetType["WorkflowView"] = "WorkflowView";
|
|
35
35
|
AIChatCitationTargetType["Probes"] = "Probes";
|
|
36
36
|
AIChatCitationTargetType["Teams"] = "Teams";
|
|
37
|
+
AIChatCitationTargetType["SecurityEvents"] = "SecurityEvents";
|
|
37
38
|
})(AIChatCitationTargetType || (AIChatCitationTargetType = {}));
|
|
38
39
|
/*
|
|
39
40
|
* ---------------------------------------------------------------------------
|