@oneuptime/common 12.0.5 → 12.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/AIRun.ts +33 -0
- package/Models/DatabaseModels/DataSource.ts +744 -0
- package/Models/DatabaseModels/Index.ts +3 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.ts +10 -2
- package/Models/DatabaseModels/User.ts +2 -0
- package/Models/DatabaseModels/UserOnCallLog.ts +2 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +2 -0
- package/Models/DatabaseModels/UserSession.ts +2 -0
- package/Models/DatabaseModels/UserTotpAuth.ts +6 -4
- package/Models/DatabaseModels/UserWebAuthn.ts +5 -3
- package/Server/API/AIInsightAPI.ts +47 -4
- package/Server/API/AIInvestigationAPI.ts +25 -0
- package/Server/API/DashboardAPI.ts +176 -492
- package/Server/API/DataSourceAPI.ts +268 -0
- package/Server/API/StatusPageAPI.ts +11 -1
- package/Server/API/UserAPI.ts +119 -0
- package/Server/Infrastructure/ClickhouseConfig.ts +59 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1786303472848-AddDataSourceTable.ts +39 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1786600000000-AddInvestigationAnalysisTldr.ts +24 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1786700000000-DropProjectCallSMSConfigCredentialUniques.ts +76 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Infrastructure/Queue.ts +26 -0
- package/Server/Infrastructure/QueueWorker.ts +17 -0
- package/Server/Middleware/TelemetryIngest.ts +8 -3
- package/Server/Services/AIInsightService.ts +132 -12
- package/Server/Services/AIRunService.ts +34 -0
- package/Server/Services/AIService.ts +17 -2
- package/Server/Services/AlertService.ts +38 -32
- package/Server/Services/AnalyticsDatabaseService.ts +8 -4
- package/Server/Services/DataSourceService.ts +200 -0
- package/Server/Services/HostService.ts +92 -0
- package/Server/Services/IncidentService.ts +45 -0
- package/Server/Services/Index.ts +2 -0
- package/Server/Services/MonitorService.ts +49 -0
- package/Server/Services/MonitorStatusService.ts +166 -0
- package/Server/Services/OpenTelemetryIngestService.ts +255 -184
- package/Server/Services/RumSessionPinService.ts +7 -21
- package/Server/Services/StatusPageSubscriberService.ts +13 -0
- package/Server/Services/UserService.ts +280 -9
- package/Server/Static/Vendor/README.md +62 -0
- package/Server/Static/Vendor/fonts/InterVariable.woff2 +0 -0
- package/Server/Static/Vendor/highlight/highlight.min.js +1244 -0
- package/Server/Static/Vendor/highlight/languages/apache.min.js +15 -0
- package/Server/Static/Vendor/highlight/languages/bash.min.js +21 -0
- package/Server/Static/Vendor/highlight/languages/c.min.js +41 -0
- package/Server/Static/Vendor/highlight/languages/cpp.min.js +47 -0
- package/Server/Static/Vendor/highlight/languages/csharp.min.js +49 -0
- package/Server/Static/Vendor/highlight/languages/css.min.js +31 -0
- package/Server/Static/Vendor/highlight/languages/diff.min.js +9 -0
- package/Server/Static/Vendor/highlight/languages/dns.min.js +11 -0
- package/Server/Static/Vendor/highlight/languages/dockerfile.min.js +8 -0
- package/Server/Static/Vendor/highlight/languages/go.min.js +20 -0
- package/Server/Static/Vendor/highlight/languages/graphql.min.js +12 -0
- package/Server/Static/Vendor/highlight/languages/http.min.js +14 -0
- package/Server/Static/Vendor/highlight/languages/ini.min.js +15 -0
- package/Server/Static/Vendor/highlight/languages/java.min.js +38 -0
- package/Server/Static/Vendor/highlight/languages/javascript.min.js +81 -0
- package/Server/Static/Vendor/highlight/languages/json.min.js +8 -0
- package/Server/Static/Vendor/highlight/languages/kotlin.min.js +46 -0
- package/Server/Static/Vendor/highlight/languages/lua.min.js +15 -0
- package/Server/Static/Vendor/highlight/languages/makefile.min.js +14 -0
- package/Server/Static/Vendor/highlight/languages/nginx.min.js +21 -0
- package/Server/Static/Vendor/highlight/languages/perl.min.js +41 -0
- package/Server/Static/Vendor/highlight/languages/php.min.js +59 -0
- package/Server/Static/Vendor/highlight/languages/powershell.min.js +39 -0
- package/Server/Static/Vendor/highlight/languages/python.min.js +42 -0
- package/Server/Static/Vendor/highlight/languages/r.min.js +26 -0
- package/Server/Static/Vendor/highlight/languages/ruby.min.js +54 -0
- package/Server/Static/Vendor/highlight/languages/rust.min.js +27 -0
- package/Server/Static/Vendor/highlight/languages/scala.min.js +28 -0
- package/Server/Static/Vendor/highlight/languages/sql.min.js +21 -0
- package/Server/Static/Vendor/highlight/languages/swift.min.js +68 -0
- package/Server/Static/Vendor/highlight/languages/typescript.min.js +99 -0
- package/Server/Static/Vendor/highlight/languages/xml.min.js +29 -0
- package/Server/Static/Vendor/highlight/languages/yaml.min.js +28 -0
- package/Server/Static/Vendor/highlight/styles/github-dark.min.css +10 -0
- package/Server/Static/Vendor/highlight/styles/vs2015.min.css +1 -0
- package/Server/Static/Vendor/tailwind/tailwind-3.4.5.js +21028 -0
- package/Server/Types/Database/Permissions/BasePermission.ts +7 -0
- package/Server/Types/Database/Permissions/DeletePermission.ts +2 -0
- package/Server/Types/Database/Permissions/ReadPermission.ts +3 -0
- package/Server/Types/Database/Permissions/TenantPermission.ts +101 -16
- package/Server/Utils/AI/CodeFix/FixRunBudget.ts +2 -2
- package/Server/Utils/AI/SRE/AIInvestigationEngine.ts +90 -11
- package/Server/Utils/AI/SRE/AlertInvestigationRunner.ts +1 -0
- package/Server/Utils/AI/SRE/IncidentInvestigationRunner.ts +1 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/ExceptionIdentity.ts +125 -0
- package/Server/Utils/AI/SRE/Insights/Detectors/ExceptionSpikeDetector.ts +25 -15
- package/Server/Utils/AI/SRE/Insights/Detectors/NewExceptionDetector.ts +256 -57
- package/Server/Utils/AI/SRE/Insights/InsightStore.ts +76 -18
- package/Server/Utils/AI/SRE/InvestigationTldr.ts +352 -0
- package/Server/Utils/AnalyticsDatabase/InsertDedupContext.ts +7 -2
- package/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.ts +1793 -0
- package/Server/Utils/Dashboard/PublicDashboardViewConfig.ts +65 -0
- package/Server/Utils/DataSource/ConnectorRegistry.ts +53 -0
- package/Server/Utils/DataSource/Connectors/ClickHouseConnector.ts +338 -0
- package/Server/Utils/DataSource/Connectors/ElasticsearchConnector.ts +717 -0
- package/Server/Utils/DataSource/Connectors/LokiConnector.ts +606 -0
- package/Server/Utils/DataSource/Connectors/MySqlConnector.ts +307 -0
- package/Server/Utils/DataSource/Connectors/PostgresConnector.ts +260 -0
- package/Server/Utils/DataSource/Connectors/PrometheusConnector.ts +555 -0
- package/Server/Utils/DataSource/Connectors/RestApiConnector.ts +597 -0
- package/Server/Utils/DataSource/Connectors/SqlServerConnector.ts +318 -0
- package/Server/Utils/DataSource/EgressGuard.ts +446 -0
- package/Server/Utils/DataSource/HttpFetch.ts +221 -0
- package/Server/Utils/DataSource/SqlQueryGuard.ts +383 -0
- package/Server/Utils/DataSource/SqlResultShaper.ts +372 -0
- package/Server/Utils/DataSource/Types.ts +93 -0
- package/Server/Utils/Database/PostgresErrorTranslator.ts +172 -17
- package/Server/Utils/InProcessMemo.ts +141 -0
- package/Server/Utils/InstanceHealth/TelemetryIngestion.ts +628 -0
- package/Server/Utils/Monitor/MonitorMetricUtil.ts +58 -0
- package/Server/Utils/Monitor/MonitorResource.ts +14 -0
- package/Server/Utils/Response.ts +12 -1
- package/Server/Utils/SSRFProtection.ts +237 -0
- package/Server/Utils/StartServer.ts +8 -0
- package/Server/Utils/StatusPageSubscriberWebhook.ts +30 -0
- package/Server/Utils/Telemetry/CaptureSpan.ts +30 -18
- package/Server/Utils/Telemetry/IngestionTimestamp.ts +75 -0
- package/Server/Utils/Telemetry/ResourceHeartbeat.ts +99 -7
- package/Server/Utils/Telemetry/Telemetry.ts +112 -1
- package/Server/Utils/Telemetry.ts +104 -3
- package/Server/Utils/VendorAssets.ts +165 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +28 -5
- package/Server/Utils/Workspace/Slack/Slack.ts +5 -0
- package/Server/Views/Partials/Head.ejs +21 -7
- package/Tests/App/AdminDashboard/AdminProjectsIdFilter.test.tsx +207 -0
- package/Tests/App/AdminDashboard/AdminUsersIdFilter.test.tsx +216 -0
- package/Tests/App/Dashboard/AIInsightViewActions.test.tsx +422 -0
- package/Tests/App/Dashboard/AddWidgetModal.test.tsx +10 -3
- package/Tests/App/Dashboard/AlertsSideMenu.test.tsx +387 -0
- package/Tests/App/Dashboard/ChatActivityFeed.test.tsx +199 -0
- package/Tests/App/Dashboard/DataSourceChartSyntheticConfig.test.tsx +736 -0
- package/Tests/App/Dashboard/DataSourceQueryEditor.test.tsx +868 -0
- package/Tests/App/Dashboard/DataSourceWidgetCatalog.test.ts +440 -0
- package/Tests/App/Dashboard/DataSourceWidgetFetching.test.tsx +2109 -0
- package/Tests/App/Dashboard/DataSourceWidgetViews.test.tsx +726 -0
- package/Tests/App/Dashboard/IncidentsSideMenu.test.tsx +447 -0
- package/Tests/App/Dashboard/InvestigationPanel.test.tsx +514 -3
- package/Tests/App/Dashboard/ProductMenuBreadcrumbs.test.tsx +391 -0
- package/Tests/App/Dashboard/ScheduledMaintenanceSideMenu.test.tsx +326 -0
- package/Tests/App/Dashboard/SideMenuHarness.tsx +187 -0
- package/Tests/App/Dashboard/WidgetCatalog.test.ts +6 -1
- package/Tests/App/StatusPage/StatusPageResourceExplorer.test.tsx +1858 -0
- package/Tests/Models/DatabaseModels/DataSourceModelSecrets.test.ts +70 -0
- package/Tests/Server/API/AIInvestigationAPI.test.ts +187 -0
- package/Tests/Server/API/DashboardPublicDataSourceStrip.test.ts +686 -0
- package/Tests/Server/API/DashboardPublicResourceListAPI.test.ts +585 -823
- package/Tests/Server/API/DataSourceAPIRoutes.test.ts +486 -0
- package/Tests/Server/API/StatusPageSubscriberOwnership.test.ts +291 -0
- package/Tests/Server/API/UserAuthenticationAPI.test.ts +641 -0
- package/Tests/Server/Infrastructure/ClickhouseKeepAliveOptions.test.ts +441 -0
- package/Tests/Server/Middleware/TelemetryIngestTokenLog.test.ts +140 -0
- package/Tests/Server/Services/AIInsightService.test.ts +266 -11
- package/Tests/Server/Services/AIRunAnalysisTldrPersistence.test.ts +160 -0
- package/Tests/Server/Services/AIServiceDailyBudget.test.ts +4 -0
- package/Tests/Server/Services/AlertMetricResourceAttributes.test.ts +352 -0
- package/Tests/Server/Services/DataSourceServiceSettings.test.ts +244 -0
- package/Tests/Server/Services/HostServiceFindOrCreateMemo.test.ts +397 -0
- package/Tests/Server/Services/HostServiceUpdateLastSeen.test.ts +41 -2
- package/Tests/Server/Services/IncidentMetricResourceAttributes.test.ts +408 -0
- package/Tests/Server/Services/MonitorStatusServiceDeleteReferenceCleanup.test.ts +351 -0
- package/Tests/Server/Services/MonitorStatusServiceValidation.test.ts +171 -0
- package/Tests/Server/Services/OpenTelemetryResourceRetentionMemo.test.ts +398 -0
- package/Tests/Server/Services/OpenTelemetryServiceResolutionCache.test.ts +19 -0
- package/Tests/Server/Services/ProjectCallSMSConfigCredentialUniqueness.test.ts +305 -0
- package/Tests/Server/Services/ResourceUpdateLastSeenLivenessFallback.test.ts +36 -1
- package/Tests/Server/Services/RumSessionPinUniqueViolationRecovery.test.ts +163 -0
- package/Tests/Server/Services/UserAuthenticationService.test.ts +973 -0
- package/Tests/Server/Types/Database/ObjectIdColumnQuery.test.ts +262 -0
- package/Tests/Server/Types/Database/Permissions/TenantPermission.test.ts +358 -0
- package/Tests/Server/Utils/AI/FixRunBudget.test.ts +2 -2
- package/Tests/Server/Utils/AI/Insights/ExceptionSpikeDetector.test.ts +6 -1
- package/Tests/Server/Utils/AI/Insights/InsightStore.test.ts +121 -4
- package/Tests/Server/Utils/AI/Insights/NewExceptionDetector.test.ts +361 -10
- package/Tests/Server/Utils/AI/InvestigationSettlement.test.ts +292 -0
- package/Tests/Server/Utils/AI/InvestigationTldr.test.ts +623 -0
- package/Tests/Server/Utils/AI/InvestigationTldrWiring.test.ts +98 -0
- package/Tests/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.test.ts +857 -0
- package/Tests/Server/Utils/Dashboard/PublicDashboardViewConfig.test.ts +480 -0
- package/Tests/Server/Utils/DataSource/ClickHouseConnector.test.ts +759 -0
- package/Tests/Server/Utils/DataSource/ConnectorRegistry.test.ts +37 -0
- package/Tests/Server/Utils/DataSource/EgressGuard.test.ts +645 -0
- package/Tests/Server/Utils/DataSource/ElasticsearchConnector.test.ts +1206 -0
- package/Tests/Server/Utils/DataSource/HttpFetch.test.ts +616 -0
- package/Tests/Server/Utils/DataSource/LokiConnector.test.ts +970 -0
- package/Tests/Server/Utils/DataSource/MySqlConnector.test.ts +935 -0
- package/Tests/Server/Utils/DataSource/PostgresConnector.test.ts +854 -0
- package/Tests/Server/Utils/DataSource/PrometheusConnector.test.ts +881 -0
- package/Tests/Server/Utils/DataSource/RestApiConnector.test.ts +1020 -0
- package/Tests/Server/Utils/DataSource/SqlQueryGuard.test.ts +425 -0
- package/Tests/Server/Utils/DataSource/SqlResultShaper.test.ts +555 -0
- package/Tests/Server/Utils/DataSource/SqlServerConnector.test.ts +934 -0
- package/Tests/Server/Utils/Database/PostgresErrorTranslator.test.ts +228 -7
- package/Tests/Server/Utils/InProcessMemo.test.ts +292 -0
- package/Tests/Server/Utils/InstanceHealth/TelemetryIngestion.test.ts +960 -0
- package/Tests/Server/Utils/MicrosoftTeamsWebhookUrlValidation.test.ts +103 -0
- package/Tests/Server/Utils/Monitor/MonitorMetricResourceAttributes.test.ts +336 -0
- package/Tests/Server/Utils/OfflineAssetHygiene.test.ts +521 -0
- package/Tests/Server/Utils/ResponseRenderAnalytics.test.ts +143 -0
- package/Tests/Server/Utils/SSRFProtection.test.ts +193 -0
- package/Tests/Server/Utils/StatusPageSubscriberWebhook.test.ts +101 -0
- package/Tests/Server/Utils/TailwindBuildCopy.test.ts +225 -0
- package/Tests/Server/Utils/Telemetry/ResourceHeartbeatL1Memo.test.ts +355 -0
- package/Tests/Server/Utils/Telemetry/TelemetryFanInWriter.test.ts +128 -0
- package/Tests/Server/Utils/Telemetry/TelemetryUtilAttributeKeys.test.ts +381 -0
- package/Tests/Server/Utils/Telemetry.test.ts +87 -0
- package/Tests/Server/Utils/VendorAssetIntegrity.test.ts +343 -0
- package/Tests/Server/Utils/VendorAssets.test.ts +671 -0
- package/Tests/Server/Views/OfflineRender.test.ts +297 -0
- package/Tests/Types/Dashboard/DataSourceComponentTypes.test.ts +618 -0
- package/Tests/Types/DateClickhouseFormat.test.ts +192 -0
- package/Tests/Types/Password.test.ts +363 -0
- package/Tests/UI/Components/ConfirmModal.test.tsx +7 -0
- package/Tests/UI/Components/ErrorBoundary.test.tsx +53 -0
- package/Tests/UI/Components/Modal.test.tsx +281 -1
- package/Tests/UI/Components/ObjectIdFilterPipeline.test.tsx +396 -0
- package/Tests/UI/Components/StatusPage/ResourceGroupNavigator.test.tsx +1147 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +116 -1
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +2 -0
- package/Tests/Utils/Analytics.test.ts +23 -0
- package/Tests/Utils/Dashboard/Components/DashboardDataSourceComponents.test.ts +640 -0
- package/Tests/Utils/DataSource/DataSourceQueryText.test.ts +138 -0
- package/Tests/Utils/DataSource/DataSourceValueReducer.test.ts +526 -0
- package/Tests/Utils/Metrics/MetricResourceAttributeUtil.test.ts +691 -0
- package/Tests/Utils/StatusPage/GroupHierarchyView.test.ts +1452 -0
- package/Tests/Utils/StatusPage/ResourceExplorer.test.ts +931 -0
- package/Tests/Utils/Telemetry/CaptureSpanExportGating.test.ts +288 -0
- package/Tests/Utils/Telemetry/IngestionTimestamp.test.ts +170 -0
- package/Types/AI/AIInsightEvidence.ts +6 -0
- package/Types/Analytics/RevenueEvent.ts +31 -0
- package/Types/Dashboard/DashboardComponentType.ts +31 -0
- package/Types/Dashboard/DashboardComponents/DashboardDataSourceChartComponent.ts +27 -0
- package/Types/Dashboard/DashboardComponents/DashboardDataSourceGaugeComponent.ts +32 -0
- package/Types/Dashboard/DashboardComponents/DashboardDataSourceTableComponent.ts +30 -0
- package/Types/Dashboard/DashboardComponents/DashboardDataSourceValueComponent.ts +55 -0
- package/Types/DataSource/DataSourceLimits.ts +62 -0
- package/Types/DataSource/DataSourceQueryConfig.ts +41 -0
- package/Types/DataSource/DataSourceTableResult.ts +38 -0
- package/Types/DataSource/DataSourceType.ts +213 -0
- package/Types/Date.ts +43 -3
- package/Types/Password.ts +64 -0
- package/Types/Permission.ts +46 -0
- package/Types/UserAuthenticationStatus.ts +34 -0
- package/UI/Components/Button/Button.tsx +1 -1
- package/UI/Components/ErrorBoundary.tsx +459 -108
- package/UI/Components/Icon/Icon.tsx +10 -9
- package/UI/Components/Modal/ConfirmModal.tsx +6 -1
- package/UI/Components/Modal/Modal.tsx +267 -35
- package/UI/Components/Modal/ModalFooter.tsx +6 -1
- package/UI/Components/MoreMenu/MoreMenu.tsx +19 -4
- package/UI/Components/MoreMenu/MoreMenuItem.tsx +6 -1
- package/UI/Components/StatusPage/ResourceGrid.tsx +314 -0
- package/UI/Components/StatusPage/ResourceGroupNavigator.tsx +808 -0
- package/UI/Components/StatusPage/ResourceList.tsx +570 -0
- package/UI/Styles/Theme.css +18 -0
- package/UI/Utils/API/RequestOptions.ts +7 -0
- package/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts +1 -0
- package/UI/Utils/ModelAPI/ModelAPI.ts +1 -0
- package/UI/Utils/TestDataSource.ts +61 -0
- package/UI/esbuild-config.js +45 -0
- package/Utils/Analytics.ts +15 -0
- package/Utils/Dashboard/Components/DashboardDataSourceChartComponent.ts +88 -0
- package/Utils/Dashboard/Components/DashboardDataSourceGaugeComponent.ts +123 -0
- package/Utils/Dashboard/Components/DashboardDataSourceShared.ts +16 -0
- package/Utils/Dashboard/Components/DashboardDataSourceTableComponent.ts +72 -0
- package/Utils/Dashboard/Components/DashboardDataSourceValueComponent.ts +126 -0
- package/Utils/Dashboard/Components/Index.ts +28 -0
- package/Utils/DataSource/DataSourceQueryText.ts +94 -0
- package/Utils/DataSource/DataSourceValueReducer.ts +156 -0
- package/Utils/Metrics/MetricResourceAttributeUtil.ts +380 -0
- package/Utils/NetworkDiscovery/ScanTargetUtil.ts +8 -6
- package/Utils/StatusPage/GroupHierarchyView.ts +931 -0
- package/Utils/StatusPage/ResourceExplorer.ts +853 -0
- package/build/dist/Models/DatabaseModels/AIRun.js +34 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DataSource.js +774 -0
- package/build/dist/Models/DatabaseModels/DataSource.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProjectCallSMSConfig.js +14 -4
- package/build/dist/Models/DatabaseModels/ProjectCallSMSConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/User.js +2 -0
- package/build/dist/Models/DatabaseModels/User.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js +2 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +2 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserSession.js +2 -0
- package/build/dist/Models/DatabaseModels/UserSession.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserTotpAuth.js +6 -4
- package/build/dist/Models/DatabaseModels/UserTotpAuth.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserWebAuthn.js +5 -3
- package/build/dist/Models/DatabaseModels/UserWebAuthn.js.map +1 -1
- package/build/dist/Server/API/AIInsightAPI.js +34 -4
- package/build/dist/Server/API/AIInsightAPI.js.map +1 -1
- package/build/dist/Server/API/AIInvestigationAPI.js +23 -0
- package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
- package/build/dist/Server/API/DashboardAPI.js +119 -433
- package/build/dist/Server/API/DashboardAPI.js.map +1 -1
- package/build/dist/Server/API/DataSourceAPI.js +173 -0
- package/build/dist/Server/API/DataSourceAPI.js.map +1 -0
- package/build/dist/Server/API/StatusPageAPI.js +11 -1
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/API/UserAPI.js +94 -2
- package/build/dist/Server/API/UserAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/ClickhouseConfig.js +49 -0
- package/build/dist/Server/Infrastructure/ClickhouseConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786303472848-AddDataSourceTable.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786303472848-AddDataSourceTable.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786600000000-AddInvestigationAnalysisTldr.js +19 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786600000000-AddInvestigationAnalysisTldr.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786700000000-DropProjectCallSMSConfigCredentialUniques.js +64 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1786700000000-DropProjectCallSMSConfigCredentialUniques.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Queue.js +27 -0
- package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
- package/build/dist/Server/Infrastructure/QueueWorker.js +13 -0
- package/build/dist/Server/Infrastructure/QueueWorker.js.map +1 -1
- package/build/dist/Server/Middleware/TelemetryIngest.js +8 -3
- package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
- package/build/dist/Server/Services/AIInsightService.js +110 -10
- package/build/dist/Server/Services/AIInsightService.js.map +1 -1
- package/build/dist/Server/Services/AIRunService.js +34 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -1
- package/build/dist/Server/Services/AIService.js +16 -2
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +28 -35
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +8 -4
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DataSourceService.js +159 -0
- package/build/dist/Server/Services/DataSourceService.js.map +1 -0
- package/build/dist/Server/Services/HostService.js +74 -0
- package/build/dist/Server/Services/HostService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +35 -24
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +45 -0
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/MonitorStatusService.js +129 -0
- package/build/dist/Server/Services/MonitorStatusService.js.map +1 -1
- package/build/dist/Server/Services/OpenTelemetryIngestService.js +222 -159
- package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
- package/build/dist/Server/Services/RumSessionPinService.js +7 -15
- package/build/dist/Server/Services/RumSessionPinService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +10 -0
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +241 -10
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/BasePermission.js +6 -0
- package/build/dist/Server/Types/Database/Permissions/BasePermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/DeletePermission.js +1 -0
- package/build/dist/Server/Types/Database/Permissions/DeletePermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/ReadPermission.js +2 -0
- package/build/dist/Server/Types/Database/Permissions/ReadPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/TenantPermission.js +68 -12
- package/build/dist/Server/Types/Database/Permissions/TenantPermission.js.map +1 -1
- package/build/dist/Server/Utils/AI/CodeFix/FixRunBudget.js +2 -2
- package/build/dist/Server/Utils/AI/CodeFix/FixRunBudget.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js +68 -8
- package/build/dist/Server/Utils/AI/SRE/AIInvestigationEngine.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js +1 -0
- package/build/dist/Server/Utils/AI/SRE/AlertInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js +1 -0
- package/build/dist/Server/Utils/AI/SRE/IncidentInvestigationRunner.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ExceptionIdentity.js +97 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ExceptionIdentity.js.map +1 -0
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ExceptionSpikeDetector.js +17 -15
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/ExceptionSpikeDetector.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/NewExceptionDetector.js +178 -54
- package/build/dist/Server/Utils/AI/SRE/Insights/Detectors/NewExceptionDetector.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightStore.js +65 -16
- package/build/dist/Server/Utils/AI/SRE/Insights/InsightStore.js.map +1 -1
- package/build/dist/Server/Utils/AI/SRE/InvestigationTldr.js +303 -0
- package/build/dist/Server/Utils/AI/SRE/InvestigationTldr.js.map +1 -0
- package/build/dist/Server/Utils/AnalyticsDatabase/InsertDedupContext.js.map +1 -1
- package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js +1261 -0
- package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js.map +1 -0
- package/build/dist/Server/Utils/Dashboard/PublicDashboardViewConfig.js +47 -0
- package/build/dist/Server/Utils/Dashboard/PublicDashboardViewConfig.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/ConnectorRegistry.js +42 -0
- package/build/dist/Server/Utils/DataSource/ConnectorRegistry.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/ClickHouseConnector.js +187 -0
- package/build/dist/Server/Utils/DataSource/Connectors/ClickHouseConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/ElasticsearchConnector.js +493 -0
- package/build/dist/Server/Utils/DataSource/Connectors/ElasticsearchConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/LokiConnector.js +399 -0
- package/build/dist/Server/Utils/DataSource/Connectors/LokiConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/MySqlConnector.js +195 -0
- package/build/dist/Server/Utils/DataSource/Connectors/MySqlConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/PostgresConnector.js +149 -0
- package/build/dist/Server/Utils/DataSource/Connectors/PostgresConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/PrometheusConnector.js +362 -0
- package/build/dist/Server/Utils/DataSource/Connectors/PrometheusConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/RestApiConnector.js +342 -0
- package/build/dist/Server/Utils/DataSource/Connectors/RestApiConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Connectors/SqlServerConnector.js +186 -0
- package/build/dist/Server/Utils/DataSource/Connectors/SqlServerConnector.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/EgressGuard.js +305 -0
- package/build/dist/Server/Utils/DataSource/EgressGuard.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/HttpFetch.js +134 -0
- package/build/dist/Server/Utils/DataSource/HttpFetch.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/SqlQueryGuard.js +331 -0
- package/build/dist/Server/Utils/DataSource/SqlQueryGuard.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/SqlResultShaper.js +280 -0
- package/build/dist/Server/Utils/DataSource/SqlResultShaper.js.map +1 -0
- package/build/dist/Server/Utils/DataSource/Types.js +2 -0
- package/build/dist/Server/Utils/DataSource/Types.js.map +1 -0
- package/build/dist/Server/Utils/Database/PostgresErrorTranslator.js +103 -9
- package/build/dist/Server/Utils/Database/PostgresErrorTranslator.js.map +1 -1
- package/build/dist/Server/Utils/InProcessMemo.js +113 -0
- package/build/dist/Server/Utils/InProcessMemo.js.map +1 -0
- package/build/dist/Server/Utils/InstanceHealth/TelemetryIngestion.js +406 -0
- package/build/dist/Server/Utils/InstanceHealth/TelemetryIngestion.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js +34 -0
- package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +14 -0
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Response.js +9 -1
- package/build/dist/Server/Utils/Response.js.map +1 -1
- package/build/dist/Server/Utils/SSRFProtection.js +192 -0
- package/build/dist/Server/Utils/SSRFProtection.js.map +1 -0
- package/build/dist/Server/Utils/StartServer.js +7 -0
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/StatusPageSubscriberWebhook.js +24 -0
- package/build/dist/Server/Utils/StatusPageSubscriberWebhook.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/CaptureSpan.js +25 -11
- package/build/dist/Server/Utils/Telemetry/CaptureSpan.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/IngestionTimestamp.js +32 -0
- package/build/dist/Server/Utils/Telemetry/IngestionTimestamp.js.map +1 -0
- package/build/dist/Server/Utils/Telemetry/ResourceHeartbeat.js +92 -5
- package/build/dist/Server/Utils/Telemetry/ResourceHeartbeat.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/Telemetry.js +92 -6
- package/build/dist/Server/Utils/Telemetry/Telemetry.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry.js +93 -6
- package/build/dist/Server/Utils/Telemetry.js.map +1 -1
- package/build/dist/Server/Utils/VendorAssets.js +121 -0
- package/build/dist/Server/Utils/VendorAssets.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +25 -4
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +5 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Types/Analytics/RevenueEvent.js +26 -0
- package/build/dist/Types/Analytics/RevenueEvent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponentType.js +27 -0
- package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceChartComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceChartComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceGaugeComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceGaugeComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceTableComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceTableComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceValueComponent.js +16 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDataSourceValueComponent.js.map +1 -0
- package/build/dist/Types/DataSource/DataSourceLimits.js +47 -0
- package/build/dist/Types/DataSource/DataSourceLimits.js.map +1 -0
- package/build/dist/Types/DataSource/DataSourceQueryConfig.js +10 -0
- package/build/dist/Types/DataSource/DataSourceQueryConfig.js.map +1 -0
- package/build/dist/Types/DataSource/DataSourceTableResult.js +14 -0
- package/build/dist/Types/DataSource/DataSourceTableResult.js.map +1 -0
- package/build/dist/Types/DataSource/DataSourceType.js +183 -0
- package/build/dist/Types/DataSource/DataSourceType.js.map +1 -0
- package/build/dist/Types/Date.js +38 -3
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Password.js +56 -0
- package/build/dist/Types/Password.js.map +1 -0
- package/build/dist/Types/Permission.js +42 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/UserAuthenticationStatus.js +2 -0
- package/build/dist/Types/UserAuthenticationStatus.js.map +1 -0
- package/build/dist/UI/Components/ErrorBoundary.js +388 -72
- package/build/dist/UI/Components/ErrorBoundary.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +10 -4
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Modal/ConfirmModal.js +1 -1
- package/build/dist/UI/Components/Modal/ConfirmModal.js.map +1 -1
- package/build/dist/UI/Components/Modal/Modal.js +178 -19
- package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js +3 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js +9 -6
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +7 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -1
- package/build/dist/UI/Components/StatusPage/ResourceGrid.js +119 -0
- package/build/dist/UI/Components/StatusPage/ResourceGrid.js.map +1 -0
- package/build/dist/UI/Components/StatusPage/ResourceGroupNavigator.js +354 -0
- package/build/dist/UI/Components/StatusPage/ResourceGroupNavigator.js.map +1 -0
- package/build/dist/UI/Components/StatusPage/ResourceList.js +203 -0
- package/build/dist/UI/Components/StatusPage/ResourceList.js.map +1 -0
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js +1 -6
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +3 -8
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/TestDataSource.js +39 -0
- package/build/dist/UI/Utils/TestDataSource.js.map +1 -0
- package/build/dist/Utils/Analytics.js +4 -0
- package/build/dist/Utils/Analytics.js.map +1 -1
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceChartComponent.js +79 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceChartComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceGaugeComponent.js +111 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceGaugeComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceShared.js +15 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceShared.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceTableComponent.js +62 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceTableComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceValueComponent.js +112 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDataSourceValueComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/Index.js +16 -0
- package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
- package/build/dist/Utils/DataSource/DataSourceQueryText.js +64 -0
- package/build/dist/Utils/DataSource/DataSourceQueryText.js.map +1 -0
- package/build/dist/Utils/DataSource/DataSourceValueReducer.js +124 -0
- package/build/dist/Utils/DataSource/DataSourceValueReducer.js.map +1 -0
- package/build/dist/Utils/Metrics/MetricResourceAttributeUtil.js +281 -0
- package/build/dist/Utils/Metrics/MetricResourceAttributeUtil.js.map +1 -0
- package/build/dist/Utils/NetworkDiscovery/ScanTargetUtil.js +8 -6
- package/build/dist/Utils/NetworkDiscovery/ScanTargetUtil.js.map +1 -1
- package/build/dist/Utils/StatusPage/GroupHierarchyView.js +560 -0
- package/build/dist/Utils/StatusPage/GroupHierarchyView.js.map +1 -0
- package/build/dist/Utils/StatusPage/ResourceExplorer.js +519 -0
- package/build/dist/Utils/StatusPage/ResourceExplorer.js.map +1 -0
- package/jest.config.json +1 -0
- package/package.json +5 -1
- package/tsconfig.json +12 -10
|
@@ -0,0 +1,881 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "@jest/globals";
|
|
2
|
+
import PrometheusConnector, {
|
|
3
|
+
assertPrometheusSuccess,
|
|
4
|
+
buildPrometheusApiUrl,
|
|
5
|
+
parseInstantQueryResult,
|
|
6
|
+
parseRangeQueryResult,
|
|
7
|
+
} from "../../../../Server/Utils/DataSource/Connectors/PrometheusConnector";
|
|
8
|
+
import DataSourceEgressGuard from "../../../../Server/Utils/DataSource/EgressGuard";
|
|
9
|
+
import DataSourceHttpFetch, {
|
|
10
|
+
DataSourceHttpRequest,
|
|
11
|
+
DataSourceHttpResponse,
|
|
12
|
+
} from "../../../../Server/Utils/DataSource/HttpFetch";
|
|
13
|
+
import {
|
|
14
|
+
DataSourceConnectionSettings,
|
|
15
|
+
DataSourceQueryWindow,
|
|
16
|
+
} from "../../../../Server/Utils/DataSource/Types";
|
|
17
|
+
import AggregatedResult from "../../../../Types/BaseDatabase/AggregatedResult";
|
|
18
|
+
import {
|
|
19
|
+
DATA_SOURCE_CONNECT_TIMEOUT_IN_MS,
|
|
20
|
+
DATA_SOURCE_QUERY_TIMEOUT_IN_MS,
|
|
21
|
+
} from "../../../../Types/DataSource/DataSourceLimits";
|
|
22
|
+
import DataSourceTableResult, {
|
|
23
|
+
DataSourceTableColumnType,
|
|
24
|
+
} from "../../../../Types/DataSource/DataSourceTableResult";
|
|
25
|
+
import DataSourceType from "../../../../Types/DataSource/DataSourceType";
|
|
26
|
+
import BadDataException from "../../../../Types/Exception/BadDataException";
|
|
27
|
+
|
|
28
|
+
type MakeSettingsFunction = (
|
|
29
|
+
overrides?: Partial<DataSourceConnectionSettings>,
|
|
30
|
+
) => DataSourceConnectionSettings;
|
|
31
|
+
|
|
32
|
+
const makeSettings: MakeSettingsFunction = (
|
|
33
|
+
overrides?: Partial<DataSourceConnectionSettings>,
|
|
34
|
+
): DataSourceConnectionSettings => {
|
|
35
|
+
return {
|
|
36
|
+
dataSourceType: DataSourceType.Prometheus,
|
|
37
|
+
url: "https://prometheus.example.com",
|
|
38
|
+
...overrides,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const queryWindow: DataSourceQueryWindow = {
|
|
43
|
+
startDate: new Date("2026-01-01T00:00:00.000Z"),
|
|
44
|
+
endDate: new Date("2026-01-01T01:00:00.000Z"),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type EnvelopeFunction = (resultType: string, result: unknown) => unknown;
|
|
48
|
+
|
|
49
|
+
const successBody: EnvelopeFunction = (
|
|
50
|
+
resultType: string,
|
|
51
|
+
result: unknown,
|
|
52
|
+
): unknown => {
|
|
53
|
+
return {
|
|
54
|
+
status: "success",
|
|
55
|
+
data: { resultType: resultType, result: result },
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type HttpResponseFunction = (body: unknown) => DataSourceHttpResponse;
|
|
60
|
+
|
|
61
|
+
const httpResponse: HttpResponseFunction = (
|
|
62
|
+
body: unknown,
|
|
63
|
+
): DataSourceHttpResponse => {
|
|
64
|
+
return {
|
|
65
|
+
statusCode: 200,
|
|
66
|
+
bodyText: JSON.stringify(body),
|
|
67
|
+
bodyJson: body,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type MockFetchFunction = (response: DataSourceHttpResponse) => jest.SpyInstance;
|
|
72
|
+
|
|
73
|
+
const mockFetch: MockFetchFunction = (
|
|
74
|
+
response: DataSourceHttpResponse,
|
|
75
|
+
): jest.SpyInstance => {
|
|
76
|
+
return jest.spyOn(DataSourceHttpFetch, "fetch").mockResolvedValue(response);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type LastRequestFunction = (spy: jest.SpyInstance) => DataSourceHttpRequest;
|
|
80
|
+
|
|
81
|
+
const lastRequest: LastRequestFunction = (
|
|
82
|
+
spy: jest.SpyInstance,
|
|
83
|
+
): DataSourceHttpRequest => {
|
|
84
|
+
const calls: Array<Array<unknown>> = spy.mock.calls as Array<Array<unknown>>;
|
|
85
|
+
return calls[calls.length - 1]![0] as DataSourceHttpRequest;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
afterEach(() => {
|
|
89
|
+
jest.restoreAllMocks();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("buildPrometheusApiUrl", () => {
|
|
93
|
+
test("joins a bare host base URL with the API path", () => {
|
|
94
|
+
expect(
|
|
95
|
+
buildPrometheusApiUrl("https://prometheus.example.com", "/api/v1/query", {
|
|
96
|
+
query: "up",
|
|
97
|
+
}),
|
|
98
|
+
).toBe("https://prometheus.example.com/api/v1/query?query=up");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("preserves a path prefix on the base URL", () => {
|
|
102
|
+
expect(
|
|
103
|
+
buildPrometheusApiUrl(
|
|
104
|
+
"https://host.example.com/prometheus",
|
|
105
|
+
"/api/v1/query",
|
|
106
|
+
{ query: "up" },
|
|
107
|
+
),
|
|
108
|
+
).toBe("https://host.example.com/prometheus/api/v1/query?query=up");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("never produces double slashes for trailing-slash base URLs", () => {
|
|
112
|
+
expect(
|
|
113
|
+
buildPrometheusApiUrl(
|
|
114
|
+
"https://host.example.com/prometheus///",
|
|
115
|
+
"/api/v1/query",
|
|
116
|
+
{ query: "up" },
|
|
117
|
+
),
|
|
118
|
+
).toBe("https://host.example.com/prometheus/api/v1/query?query=up");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("adds a leading slash to the path when missing", () => {
|
|
122
|
+
expect(
|
|
123
|
+
buildPrometheusApiUrl("https://host.example.com", "api/v1/query", {
|
|
124
|
+
query: "up",
|
|
125
|
+
}),
|
|
126
|
+
).toBe("https://host.example.com/api/v1/query?query=up");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("URL-encodes PromQL query parameters", () => {
|
|
130
|
+
const url: string = buildPrometheusApiUrl(
|
|
131
|
+
"https://host.example.com",
|
|
132
|
+
"/api/v1/query_range",
|
|
133
|
+
{ query: 'rate(http_requests_total{job="api"}[5m])', step: "15" },
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const parsed: URL = new URL(url);
|
|
137
|
+
expect(parsed.searchParams.get("query")).toBe(
|
|
138
|
+
'rate(http_requests_total{job="api"}[5m])',
|
|
139
|
+
);
|
|
140
|
+
expect(parsed.searchParams.get("step")).toBe("15");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("assertPrometheusSuccess", () => {
|
|
145
|
+
test("returns the data object on a success envelope", () => {
|
|
146
|
+
const data: Record<string, unknown> = assertPrometheusSuccess(
|
|
147
|
+
successBody("vector", []),
|
|
148
|
+
);
|
|
149
|
+
expect(data["resultType"]).toBe("vector");
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("throws the server's error text on a status:error envelope", () => {
|
|
153
|
+
expect(() => {
|
|
154
|
+
return assertPrometheusSuccess({
|
|
155
|
+
status: "error",
|
|
156
|
+
errorType: "bad_data",
|
|
157
|
+
error: 'parse error at char 5: unexpected "{"',
|
|
158
|
+
});
|
|
159
|
+
}).toThrow(BadDataException);
|
|
160
|
+
|
|
161
|
+
expect(() => {
|
|
162
|
+
return assertPrometheusSuccess({
|
|
163
|
+
status: "error",
|
|
164
|
+
error: 'parse error at char 5: unexpected "{"',
|
|
165
|
+
});
|
|
166
|
+
}).toThrow(/parse error at char 5/);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("truncates very long error texts to 500 characters", () => {
|
|
170
|
+
const longError: string = "x".repeat(600);
|
|
171
|
+
let thrownMessage: string = "";
|
|
172
|
+
try {
|
|
173
|
+
assertPrometheusSuccess({ status: "error", error: longError });
|
|
174
|
+
} catch (error) {
|
|
175
|
+
thrownMessage = (error as Error).message;
|
|
176
|
+
}
|
|
177
|
+
expect(thrownMessage).toContain("x".repeat(500));
|
|
178
|
+
expect(thrownMessage).not.toContain("x".repeat(501));
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("throws on a non-object body", () => {
|
|
182
|
+
expect(() => {
|
|
183
|
+
return assertPrometheusSuccess("not json object");
|
|
184
|
+
}).toThrow(BadDataException);
|
|
185
|
+
expect(() => {
|
|
186
|
+
return assertPrometheusSuccess(null);
|
|
187
|
+
}).toThrow(BadDataException);
|
|
188
|
+
expect(() => {
|
|
189
|
+
return assertPrometheusSuccess([1, 2, 3]);
|
|
190
|
+
}).toThrow(BadDataException);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("throws on an unexpected status value", () => {
|
|
194
|
+
expect(() => {
|
|
195
|
+
return assertPrometheusSuccess({ status: "partial" });
|
|
196
|
+
}).toThrow(/unexpected status/);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("throws when the data field is missing", () => {
|
|
200
|
+
expect(() => {
|
|
201
|
+
return assertPrometheusSuccess({ status: "success" });
|
|
202
|
+
}).toThrow(/data field/);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe("parseRangeQueryResult", () => {
|
|
207
|
+
test("maps a matrix into points with labels excluding __name__", () => {
|
|
208
|
+
const body: unknown = successBody("matrix", [
|
|
209
|
+
{
|
|
210
|
+
metric: { __name__: "up", instance: "a:9090", job: "api" },
|
|
211
|
+
values: [
|
|
212
|
+
[1767225600, "1"],
|
|
213
|
+
[1767225660, "0.5"],
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
metric: { __name__: "up", instance: "b:9090", job: "api" },
|
|
218
|
+
values: [[1767225600, "2"]],
|
|
219
|
+
},
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
223
|
+
|
|
224
|
+
expect(result.truncated).toBe(false);
|
|
225
|
+
expect(result.data).toHaveLength(3);
|
|
226
|
+
expect(result.data[0]!.timestamp).toEqual(
|
|
227
|
+
new Date("2026-01-01T00:00:00.000Z"),
|
|
228
|
+
);
|
|
229
|
+
expect(result.data[0]!.value).toBe(1);
|
|
230
|
+
expect(result.data[0]!["attributes"]).toEqual({
|
|
231
|
+
instance: "a:9090",
|
|
232
|
+
job: "api",
|
|
233
|
+
});
|
|
234
|
+
expect(result.data[2]!["attributes"]).toEqual({
|
|
235
|
+
instance: "b:9090",
|
|
236
|
+
job: "api",
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("falls back to __name__ as the label when it is the only metric key", () => {
|
|
241
|
+
const body: unknown = successBody("matrix", [
|
|
242
|
+
{
|
|
243
|
+
metric: { __name__: "process_cpu_seconds_total" },
|
|
244
|
+
values: [[1767225600, "3"]],
|
|
245
|
+
},
|
|
246
|
+
]);
|
|
247
|
+
|
|
248
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
249
|
+
|
|
250
|
+
expect(result.data[0]!["attributes"]).toEqual({
|
|
251
|
+
__name__: "process_cpu_seconds_total",
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("omits attributes entirely when the metric object is empty", () => {
|
|
256
|
+
const body: unknown = successBody("matrix", [
|
|
257
|
+
{ metric: {}, values: [[1767225600, "4"]] },
|
|
258
|
+
]);
|
|
259
|
+
|
|
260
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
261
|
+
|
|
262
|
+
expect(result.data).toHaveLength(1);
|
|
263
|
+
expect(result.data[0]!["attributes"]).toBeUndefined();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test("skips NaN and infinite sample values", () => {
|
|
267
|
+
const body: unknown = successBody("matrix", [
|
|
268
|
+
{
|
|
269
|
+
metric: {},
|
|
270
|
+
values: [
|
|
271
|
+
[1767225600, "NaN"],
|
|
272
|
+
[1767225660, "+Inf"],
|
|
273
|
+
[1767225720, "-Inf"],
|
|
274
|
+
[1767225780, "7"],
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
]);
|
|
278
|
+
|
|
279
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
280
|
+
|
|
281
|
+
expect(result.data).toHaveLength(1);
|
|
282
|
+
expect(result.data[0]!.value).toBe(7);
|
|
283
|
+
expect(result.truncated).toBe(false);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("maps a vector into one point per series", () => {
|
|
287
|
+
const body: unknown = successBody("vector", [
|
|
288
|
+
{ metric: { instance: "a" }, value: [1767225600, "1"] },
|
|
289
|
+
{ metric: { instance: "b" }, value: [1767225600, "2"] },
|
|
290
|
+
]);
|
|
291
|
+
|
|
292
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
293
|
+
|
|
294
|
+
expect(result.data).toHaveLength(2);
|
|
295
|
+
expect(result.data[0]!["attributes"]).toEqual({ instance: "a" });
|
|
296
|
+
expect(result.data[1]!.value).toBe(2);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test("maps a scalar into a single unnamed point", () => {
|
|
300
|
+
const body: unknown = successBody("scalar", [1767225600, "42"]);
|
|
301
|
+
|
|
302
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
303
|
+
|
|
304
|
+
expect(result.data).toHaveLength(1);
|
|
305
|
+
expect(result.data[0]!.value).toBe(42);
|
|
306
|
+
expect(result.data[0]!["attributes"]).toBeUndefined();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test("returns an empty result for an empty matrix", () => {
|
|
310
|
+
const result: AggregatedResult = parseRangeQueryResult(
|
|
311
|
+
successBody("matrix", []),
|
|
312
|
+
);
|
|
313
|
+
expect(result.data).toEqual([]);
|
|
314
|
+
expect(result.truncated).toBe(false);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
test("drops series beyond the series cap and flags truncation", () => {
|
|
318
|
+
const body: unknown = successBody("matrix", [
|
|
319
|
+
{ metric: { instance: "a" }, values: [[1767225600, "1"]] },
|
|
320
|
+
{ metric: { instance: "b" }, values: [[1767225600, "2"]] },
|
|
321
|
+
{ metric: { instance: "c" }, values: [[1767225600, "3"]] },
|
|
322
|
+
]);
|
|
323
|
+
|
|
324
|
+
const result: AggregatedResult = parseRangeQueryResult(body, {
|
|
325
|
+
maxSeries: 2,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
expect(result.data).toHaveLength(2);
|
|
329
|
+
expect(result.truncated).toBe(true);
|
|
330
|
+
expect(result.data[1]!["attributes"]).toEqual({ instance: "b" });
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
test("clamps total points at the row cap and flags truncation", () => {
|
|
334
|
+
const body: unknown = successBody("matrix", [
|
|
335
|
+
{
|
|
336
|
+
metric: {},
|
|
337
|
+
values: [
|
|
338
|
+
[1767225600, "1"],
|
|
339
|
+
[1767225660, "2"],
|
|
340
|
+
[1767225720, "3"],
|
|
341
|
+
[1767225780, "4"],
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
]);
|
|
345
|
+
|
|
346
|
+
const result: AggregatedResult = parseRangeQueryResult(body, {
|
|
347
|
+
maxPoints: 3,
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
expect(result.data).toHaveLength(3);
|
|
351
|
+
expect(result.truncated).toBe(true);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
test("exactly cap-many points is not flagged as truncated", () => {
|
|
355
|
+
const body: unknown = successBody("matrix", [
|
|
356
|
+
{
|
|
357
|
+
metric: {},
|
|
358
|
+
values: [
|
|
359
|
+
[1767225600, "1"],
|
|
360
|
+
[1767225660, "2"],
|
|
361
|
+
[1767225720, "3"],
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
]);
|
|
365
|
+
|
|
366
|
+
const result: AggregatedResult = parseRangeQueryResult(body, {
|
|
367
|
+
maxPoints: 3,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
expect(result.data).toHaveLength(3);
|
|
371
|
+
expect(result.truncated).toBe(false);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
test("skipped non-finite values do not count toward the point cap", () => {
|
|
375
|
+
const body: unknown = successBody("matrix", [
|
|
376
|
+
{
|
|
377
|
+
metric: {},
|
|
378
|
+
values: [
|
|
379
|
+
[1767225600, "NaN"],
|
|
380
|
+
[1767225660, "1"],
|
|
381
|
+
[1767225720, "2"],
|
|
382
|
+
],
|
|
383
|
+
},
|
|
384
|
+
]);
|
|
385
|
+
|
|
386
|
+
const result: AggregatedResult = parseRangeQueryResult(body, {
|
|
387
|
+
maxPoints: 2,
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
expect(result.data).toHaveLength(2);
|
|
391
|
+
expect(result.truncated).toBe(false);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test("ignores malformed series entries and sample pairs", () => {
|
|
395
|
+
const body: unknown = successBody("matrix", [
|
|
396
|
+
"not-an-object",
|
|
397
|
+
{ metric: {}, values: "not-an-array" },
|
|
398
|
+
{
|
|
399
|
+
metric: {},
|
|
400
|
+
values: [["bad-ts", "1"], [1767225600], [1767225660, "5"]],
|
|
401
|
+
},
|
|
402
|
+
]);
|
|
403
|
+
|
|
404
|
+
const result: AggregatedResult = parseRangeQueryResult(body);
|
|
405
|
+
|
|
406
|
+
expect(result.data).toHaveLength(1);
|
|
407
|
+
expect(result.data[0]!.value).toBe(5);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
test("throws on an unsupported resultType", () => {
|
|
411
|
+
expect(() => {
|
|
412
|
+
return parseRangeQueryResult(successBody("streams", []));
|
|
413
|
+
}).toThrow(/unsupported resultType "streams"/);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
test("surfaces a status:error envelope as BadDataException", () => {
|
|
417
|
+
expect(() => {
|
|
418
|
+
return parseRangeQueryResult({
|
|
419
|
+
status: "error",
|
|
420
|
+
error: "query timed out in expression evaluation",
|
|
421
|
+
});
|
|
422
|
+
}).toThrow(/query timed out/);
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
describe("parseInstantQueryResult", () => {
|
|
427
|
+
test("maps a vector into rows with label, value and timestamp columns", () => {
|
|
428
|
+
const body: unknown = successBody("vector", [
|
|
429
|
+
{
|
|
430
|
+
metric: { __name__: "up", instance: "a:9090", job: "api" },
|
|
431
|
+
value: [1767225600, "1"],
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
metric: { __name__: "up", instance: "b:9090", job: "api" },
|
|
435
|
+
value: [1767225600.123, "0"],
|
|
436
|
+
},
|
|
437
|
+
]);
|
|
438
|
+
|
|
439
|
+
const result: DataSourceTableResult = parseInstantQueryResult(body);
|
|
440
|
+
|
|
441
|
+
expect(result.truncated).toBe(false);
|
|
442
|
+
expect(
|
|
443
|
+
result.columns.map((column: { key: string }) => {
|
|
444
|
+
return column.key;
|
|
445
|
+
}),
|
|
446
|
+
).toEqual(["__name__", "instance", "job", "value", "timestamp"]);
|
|
447
|
+
|
|
448
|
+
const valueColumn: { type: DataSourceTableColumnType } | undefined =
|
|
449
|
+
result.columns.find((column: { key: string }) => {
|
|
450
|
+
return column.key === "value";
|
|
451
|
+
});
|
|
452
|
+
expect(valueColumn?.type).toBe(DataSourceTableColumnType.Number);
|
|
453
|
+
|
|
454
|
+
const timestampColumn: { type: DataSourceTableColumnType } | undefined =
|
|
455
|
+
result.columns.find((column: { key: string }) => {
|
|
456
|
+
return column.key === "timestamp";
|
|
457
|
+
});
|
|
458
|
+
expect(timestampColumn?.type).toBe(DataSourceTableColumnType.Date);
|
|
459
|
+
|
|
460
|
+
const instanceColumn: { type: DataSourceTableColumnType } | undefined =
|
|
461
|
+
result.columns.find((column: { key: string }) => {
|
|
462
|
+
return column.key === "instance";
|
|
463
|
+
});
|
|
464
|
+
expect(instanceColumn?.type).toBe(DataSourceTableColumnType.Text);
|
|
465
|
+
|
|
466
|
+
expect(result.rows).toHaveLength(2);
|
|
467
|
+
expect(result.rows[0]!["__name__"]).toBe("up");
|
|
468
|
+
expect(result.rows[0]!["instance"]).toBe("a:9090");
|
|
469
|
+
expect(result.rows[0]!["value"]).toBe(1);
|
|
470
|
+
expect(result.rows[0]!["timestamp"]).toBe("2026-01-01T00:00:00.000Z");
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
test("takes the union of label keys and fills gaps with null", () => {
|
|
474
|
+
const body: unknown = successBody("vector", [
|
|
475
|
+
{ metric: { instance: "a" }, value: [1767225600, "1"] },
|
|
476
|
+
{ metric: { job: "api" }, value: [1767225600, "2"] },
|
|
477
|
+
]);
|
|
478
|
+
|
|
479
|
+
const result: DataSourceTableResult = parseInstantQueryResult(body);
|
|
480
|
+
|
|
481
|
+
expect(
|
|
482
|
+
result.columns.map((column: { key: string }) => {
|
|
483
|
+
return column.key;
|
|
484
|
+
}),
|
|
485
|
+
).toEqual(["instance", "job", "value", "timestamp"]);
|
|
486
|
+
expect(result.rows[0]!["job"]).toBeNull();
|
|
487
|
+
expect(result.rows[1]!["instance"]).toBeNull();
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
test("maps a scalar into a single value/timestamp row", () => {
|
|
491
|
+
const result: DataSourceTableResult = parseInstantQueryResult(
|
|
492
|
+
successBody("scalar", [1767225600, "42"]),
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
expect(
|
|
496
|
+
result.columns.map((column: { key: string }) => {
|
|
497
|
+
return column.key;
|
|
498
|
+
}),
|
|
499
|
+
).toEqual(["value", "timestamp"]);
|
|
500
|
+
expect(result.rows).toHaveLength(1);
|
|
501
|
+
expect(result.rows[0]!["value"]).toBe(42);
|
|
502
|
+
expect(result.rows[0]!["timestamp"]).toBe("2026-01-01T00:00:00.000Z");
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
test("renders non-finite values as null instead of dropping the row", () => {
|
|
506
|
+
const body: unknown = successBody("vector", [
|
|
507
|
+
{ metric: { instance: "a" }, value: [1767225600, "NaN"] },
|
|
508
|
+
]);
|
|
509
|
+
|
|
510
|
+
const result: DataSourceTableResult = parseInstantQueryResult(body);
|
|
511
|
+
|
|
512
|
+
expect(result.rows).toHaveLength(1);
|
|
513
|
+
expect(result.rows[0]!["value"]).toBeNull();
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
test("clamps rows at the cap and flags truncation", () => {
|
|
517
|
+
const body: unknown = successBody("vector", [
|
|
518
|
+
{ metric: { instance: "a" }, value: [1767225600, "1"] },
|
|
519
|
+
{ metric: { instance: "b" }, value: [1767225600, "2"] },
|
|
520
|
+
{ metric: { instance: "c" }, value: [1767225600, "3"] },
|
|
521
|
+
]);
|
|
522
|
+
|
|
523
|
+
const result: DataSourceTableResult = parseInstantQueryResult(body, {
|
|
524
|
+
maxRows: 2,
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
expect(result.rows).toHaveLength(2);
|
|
528
|
+
expect(result.truncated).toBe(true);
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
test("returns an empty table for an empty vector", () => {
|
|
532
|
+
const result: DataSourceTableResult = parseInstantQueryResult(
|
|
533
|
+
successBody("vector", []),
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
expect(result.columns).toEqual([]);
|
|
537
|
+
expect(result.rows).toEqual([]);
|
|
538
|
+
expect(result.truncated).toBe(false);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test("skips malformed vector entries", () => {
|
|
542
|
+
const body: unknown = successBody("vector", [
|
|
543
|
+
"nope",
|
|
544
|
+
{ metric: { instance: "a" } },
|
|
545
|
+
{ metric: { instance: "b" }, value: ["bad-ts", "1"] },
|
|
546
|
+
{ metric: { instance: "c" }, value: [1767225600, "3"] },
|
|
547
|
+
]);
|
|
548
|
+
|
|
549
|
+
const result: DataSourceTableResult = parseInstantQueryResult(body);
|
|
550
|
+
|
|
551
|
+
expect(result.rows).toHaveLength(1);
|
|
552
|
+
expect(result.rows[0]!["instance"]).toBe("c");
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
test("throws an actionable error for a matrix result", () => {
|
|
556
|
+
expect(() => {
|
|
557
|
+
return parseInstantQueryResult(successBody("matrix", []));
|
|
558
|
+
}).toThrow(/instant-vector query/);
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
describe("PrometheusConnector", () => {
|
|
563
|
+
const connector: PrometheusConnector = new PrometheusConnector();
|
|
564
|
+
|
|
565
|
+
test("declares the Prometheus data source type", () => {
|
|
566
|
+
expect(connector.dataSourceType).toBe(DataSourceType.Prometheus);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
describe("testConnection", () => {
|
|
570
|
+
test("probes /api/v1/query with vector(1) using the connect timeout", async () => {
|
|
571
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
572
|
+
httpResponse(successBody("vector", [])),
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
await connector.testConnection(makeSettings());
|
|
576
|
+
|
|
577
|
+
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
|
578
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
579
|
+
expect(request.method).toBe("GET");
|
|
580
|
+
expect(request.url).toBe(
|
|
581
|
+
"https://prometheus.example.com/api/v1/query?query=vector%281%29",
|
|
582
|
+
);
|
|
583
|
+
expect(request.timeoutInMs).toBe(DATA_SOURCE_CONNECT_TIMEOUT_IN_MS);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
test("sends bearer auth headers built from the api token", async () => {
|
|
587
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
588
|
+
httpResponse(successBody("vector", [])),
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
await connector.testConnection(
|
|
592
|
+
makeSettings({ apiToken: "token-abcd-1234" }),
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
596
|
+
expect(request.headers?.["Authorization"]).toBe("Bearer token-abcd-1234");
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
test("sends basic auth headers built from username and password", async () => {
|
|
600
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
601
|
+
httpResponse(successBody("vector", [])),
|
|
602
|
+
);
|
|
603
|
+
|
|
604
|
+
await connector.testConnection(
|
|
605
|
+
makeSettings({ username: "prom", password: "s3cretpass" }),
|
|
606
|
+
);
|
|
607
|
+
|
|
608
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
609
|
+
const expected: string = `Basic ${Buffer.from("prom:s3cretpass").toString(
|
|
610
|
+
"base64",
|
|
611
|
+
)}`;
|
|
612
|
+
expect(request.headers?.["Authorization"]).toBe(expected);
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
test("rejects when the settings have no URL", async () => {
|
|
616
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
617
|
+
httpResponse(successBody("vector", [])),
|
|
618
|
+
);
|
|
619
|
+
|
|
620
|
+
await expect(
|
|
621
|
+
connector.testConnection(makeSettings({ url: undefined })),
|
|
622
|
+
).rejects.toThrow(/missing a URL/);
|
|
623
|
+
expect(fetchSpy).not.toHaveBeenCalled();
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
test("rejects when the backend answers with a status:error envelope", async () => {
|
|
627
|
+
mockFetch(
|
|
628
|
+
httpResponse({
|
|
629
|
+
status: "error",
|
|
630
|
+
error: "unauthorized: bad credentials",
|
|
631
|
+
}),
|
|
632
|
+
);
|
|
633
|
+
|
|
634
|
+
await expect(connector.testConnection(makeSettings())).rejects.toThrow(
|
|
635
|
+
/bad credentials/,
|
|
636
|
+
);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
test("rejects when the backend answers with non-JSON", async () => {
|
|
640
|
+
mockFetch({
|
|
641
|
+
statusCode: 200,
|
|
642
|
+
bodyText: "<html>login page</html>",
|
|
643
|
+
bodyJson: undefined,
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
await expect(connector.testConnection(makeSettings())).rejects.toThrow(
|
|
647
|
+
/non-JSON response/,
|
|
648
|
+
);
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test("egress-guard failures inside the HTTP layer surface before any connection", async () => {
|
|
652
|
+
const guardSpy: jest.SpyInstance = jest
|
|
653
|
+
.spyOn(DataSourceEgressGuard, "assertUrlAllowed")
|
|
654
|
+
.mockRejectedValue(
|
|
655
|
+
new BadDataException(
|
|
656
|
+
"Data source host 127.0.0.1 is not allowed: loopback address.",
|
|
657
|
+
),
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
await expect(
|
|
661
|
+
connector.testConnection(
|
|
662
|
+
makeSettings({ url: "http://127.0.0.1:9090" }),
|
|
663
|
+
),
|
|
664
|
+
).rejects.toThrow(/not allowed: loopback address/);
|
|
665
|
+
|
|
666
|
+
expect(guardSpy).toHaveBeenCalledTimes(1);
|
|
667
|
+
expect(String(guardSpy.mock.calls[0]![0])).toContain(
|
|
668
|
+
"http://127.0.0.1:9090/api/v1/query",
|
|
669
|
+
);
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
describe("queryTimeSeries", () => {
|
|
674
|
+
test("calls /api/v1/query_range with unix seconds, derived step and query timeout", async () => {
|
|
675
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
676
|
+
httpResponse(successBody("matrix", [])),
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
await connector.queryTimeSeries(makeSettings(), "up", queryWindow);
|
|
680
|
+
|
|
681
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
682
|
+
const parsed: URL = new URL(request.url);
|
|
683
|
+
expect(parsed.pathname).toBe("/api/v1/query_range");
|
|
684
|
+
expect(parsed.searchParams.get("query")).toBe("up");
|
|
685
|
+
expect(parsed.searchParams.get("start")).toBe(
|
|
686
|
+
String(Math.floor(queryWindow.startDate.getTime() / 1000)),
|
|
687
|
+
);
|
|
688
|
+
expect(parsed.searchParams.get("end")).toBe(
|
|
689
|
+
String(Math.floor(queryWindow.endDate.getTime() / 1000)),
|
|
690
|
+
);
|
|
691
|
+
/*
|
|
692
|
+
* 1h window / 250 target buckets = 14.4s, ceil = 15s (above the 10s
|
|
693
|
+
* minimum step).
|
|
694
|
+
*/
|
|
695
|
+
expect(parsed.searchParams.get("step")).toBe("15");
|
|
696
|
+
expect(request.timeoutInMs).toBe(DATA_SOURCE_QUERY_TIMEOUT_IN_MS);
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
test("honors an explicit stepInSeconds and floors it to an integer", async () => {
|
|
700
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
701
|
+
httpResponse(successBody("matrix", [])),
|
|
702
|
+
);
|
|
703
|
+
|
|
704
|
+
await connector.queryTimeSeries(makeSettings(), "up", {
|
|
705
|
+
...queryWindow,
|
|
706
|
+
stepInSeconds: 42.9,
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
710
|
+
const parsed: URL = new URL(request.url);
|
|
711
|
+
expect(parsed.searchParams.get("step")).toBe("42");
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
test("preserves a base URL path prefix with a trailing slash", async () => {
|
|
715
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
716
|
+
httpResponse(successBody("matrix", [])),
|
|
717
|
+
);
|
|
718
|
+
|
|
719
|
+
await connector.queryTimeSeries(
|
|
720
|
+
makeSettings({ url: "https://metrics.example.com/prometheus/" }),
|
|
721
|
+
"up",
|
|
722
|
+
queryWindow,
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
726
|
+
expect(
|
|
727
|
+
request.url.startsWith(
|
|
728
|
+
"https://metrics.example.com/prometheus/api/v1/query_range?",
|
|
729
|
+
),
|
|
730
|
+
).toBe(true);
|
|
731
|
+
expect(request.url).not.toContain("//api");
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
test("returns the parsed matrix as an AggregatedResult", async () => {
|
|
735
|
+
mockFetch(
|
|
736
|
+
httpResponse(
|
|
737
|
+
successBody("matrix", [
|
|
738
|
+
{
|
|
739
|
+
metric: { __name__: "up", instance: "a" },
|
|
740
|
+
values: [
|
|
741
|
+
[1767225600, "1"],
|
|
742
|
+
[1767225660, "2"],
|
|
743
|
+
],
|
|
744
|
+
},
|
|
745
|
+
]),
|
|
746
|
+
),
|
|
747
|
+
);
|
|
748
|
+
|
|
749
|
+
const result: AggregatedResult = await connector.queryTimeSeries(
|
|
750
|
+
makeSettings(),
|
|
751
|
+
"up",
|
|
752
|
+
queryWindow,
|
|
753
|
+
);
|
|
754
|
+
|
|
755
|
+
expect(result.data).toHaveLength(2);
|
|
756
|
+
expect(result.data[0]!["attributes"]).toEqual({ instance: "a" });
|
|
757
|
+
expect(result.truncated).toBe(false);
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
test("flags truncation when the backend returns more series than the cap", async () => {
|
|
761
|
+
const manySeries: Array<unknown> = [];
|
|
762
|
+
for (let i: number = 0; i < 101; i++) {
|
|
763
|
+
manySeries.push({
|
|
764
|
+
metric: { instance: `host-${i}` },
|
|
765
|
+
values: [[1767225600, "1"]],
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
mockFetch(httpResponse(successBody("matrix", manySeries)));
|
|
769
|
+
|
|
770
|
+
const result: AggregatedResult = await connector.queryTimeSeries(
|
|
771
|
+
makeSettings(),
|
|
772
|
+
"up",
|
|
773
|
+
queryWindow,
|
|
774
|
+
);
|
|
775
|
+
|
|
776
|
+
expect(result.data).toHaveLength(100);
|
|
777
|
+
expect(result.truncated).toBe(true);
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
test("propagates HTTP-layer errors (already sanitized by HttpFetch)", async () => {
|
|
781
|
+
jest
|
|
782
|
+
.spyOn(DataSourceHttpFetch, "fetch")
|
|
783
|
+
.mockRejectedValue(
|
|
784
|
+
new BadDataException(
|
|
785
|
+
"Data source responded with HTTP 500: internal error",
|
|
786
|
+
),
|
|
787
|
+
);
|
|
788
|
+
|
|
789
|
+
await expect(
|
|
790
|
+
connector.queryTimeSeries(makeSettings(), "up", queryWindow),
|
|
791
|
+
).rejects.toThrow(/HTTP 500/);
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
test("never leaks credentials through error messages", async () => {
|
|
795
|
+
jest
|
|
796
|
+
.spyOn(DataSourceHttpFetch, "fetch")
|
|
797
|
+
.mockRejectedValue(
|
|
798
|
+
new Error(
|
|
799
|
+
"connect failed: authentication with password hunter2secret rejected for token token-abcd-1234",
|
|
800
|
+
),
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
let thrownMessage: string = "";
|
|
804
|
+
try {
|
|
805
|
+
await connector.queryTimeSeries(
|
|
806
|
+
makeSettings({
|
|
807
|
+
password: "hunter2secret",
|
|
808
|
+
apiToken: "token-abcd-1234",
|
|
809
|
+
}),
|
|
810
|
+
"up",
|
|
811
|
+
queryWindow,
|
|
812
|
+
);
|
|
813
|
+
} catch (error) {
|
|
814
|
+
expect(error).toBeInstanceOf(BadDataException);
|
|
815
|
+
thrownMessage = (error as Error).message;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
expect(thrownMessage).not.toContain("hunter2secret");
|
|
819
|
+
expect(thrownMessage).not.toContain("token-abcd-1234");
|
|
820
|
+
expect(thrownMessage).toContain("***");
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
describe("queryTable", () => {
|
|
825
|
+
test("calls /api/v1/query with the window end as the evaluation time", async () => {
|
|
826
|
+
const fetchSpy: jest.SpyInstance = mockFetch(
|
|
827
|
+
httpResponse(successBody("vector", [])),
|
|
828
|
+
);
|
|
829
|
+
|
|
830
|
+
await connector.queryTable(makeSettings(), "up", queryWindow);
|
|
831
|
+
|
|
832
|
+
const request: DataSourceHttpRequest = lastRequest(fetchSpy);
|
|
833
|
+
const parsed: URL = new URL(request.url);
|
|
834
|
+
expect(parsed.pathname).toBe("/api/v1/query");
|
|
835
|
+
expect(parsed.searchParams.get("query")).toBe("up");
|
|
836
|
+
expect(parsed.searchParams.get("time")).toBe(
|
|
837
|
+
String(Math.floor(queryWindow.endDate.getTime() / 1000)),
|
|
838
|
+
);
|
|
839
|
+
expect(parsed.searchParams.has("start")).toBe(false);
|
|
840
|
+
expect(request.timeoutInMs).toBe(DATA_SOURCE_QUERY_TIMEOUT_IN_MS);
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
test("returns the parsed vector as a table result", async () => {
|
|
844
|
+
mockFetch(
|
|
845
|
+
httpResponse(
|
|
846
|
+
successBody("vector", [
|
|
847
|
+
{
|
|
848
|
+
metric: { __name__: "up", instance: "a:9090" },
|
|
849
|
+
value: [1767225600, "1"],
|
|
850
|
+
},
|
|
851
|
+
]),
|
|
852
|
+
),
|
|
853
|
+
);
|
|
854
|
+
|
|
855
|
+
const result: DataSourceTableResult = await connector.queryTable(
|
|
856
|
+
makeSettings(),
|
|
857
|
+
"up",
|
|
858
|
+
queryWindow,
|
|
859
|
+
);
|
|
860
|
+
|
|
861
|
+
expect(result.rows).toHaveLength(1);
|
|
862
|
+
expect(result.rows[0]!["instance"]).toBe("a:9090");
|
|
863
|
+
expect(result.rows[0]!["value"]).toBe(1);
|
|
864
|
+
expect(result.rows[0]!["timestamp"]).toBe("2026-01-01T00:00:00.000Z");
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
test("surfaces backend query errors with the server's message", async () => {
|
|
868
|
+
mockFetch(
|
|
869
|
+
httpResponse({
|
|
870
|
+
status: "error",
|
|
871
|
+
errorType: "bad_data",
|
|
872
|
+
error: 'invalid parameter "query": unknown function',
|
|
873
|
+
}),
|
|
874
|
+
);
|
|
875
|
+
|
|
876
|
+
await expect(
|
|
877
|
+
connector.queryTable(makeSettings(), "nope(", queryWindow),
|
|
878
|
+
).rejects.toThrow(/unknown function/);
|
|
879
|
+
});
|
|
880
|
+
});
|
|
881
|
+
});
|