From 5d3885c8a5ecf92ab162b96f6607af32e23615d8 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Wed, 1 Apr 2026 18:54:11 +0100 Subject: [PATCH] feat: enhance MonitorCustomMetrics to include ListResult type for API response; improve query documentation --- .../Monitor/MonitorCustomMetrics.tsx | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/App/FeatureSet/Dashboard/src/Components/Monitor/MonitorCustomMetrics.tsx b/App/FeatureSet/Dashboard/src/Components/Monitor/MonitorCustomMetrics.tsx index 96beb42ba2..f890aa5e1b 100644 --- a/App/FeatureSet/Dashboard/src/Components/Monitor/MonitorCustomMetrics.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Monitor/MonitorCustomMetrics.tsx @@ -25,7 +25,9 @@ import Card from "Common/UI/Components/Card/Card"; import EmptyState from "Common/UI/Components/EmptyState/EmptyState"; import IconProp from "Common/Types/Icon/IconProp"; import Metric from "Common/Models/AnalyticsModels/Metric"; -import AnalyticsModelAPI from "Common/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI"; +import AnalyticsModelAPI, { + ListResult, +} from "Common/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI"; import SortOrder from "Common/Types/BaseDatabase/SortOrder"; import OneUptimeDate from "Common/Types/Date"; import Search from "Common/Types/BaseDatabase/Search"; @@ -46,32 +48,35 @@ const MonitorCustomMetrics: FunctionComponent = ( setIsLoading(true); try { - // Query ClickHouse for recent metrics belonging to this monitor - // with names starting with "custom.monitor." - // monitorId is stored as serviceId in the Metric table. - const listResult = await AnalyticsModelAPI.getList({ - modelType: Metric, - query: { - projectId: ProjectUtil.getCurrentProjectId()!, - serviceId: props.monitorId, - name: new Search("custom.monitor.") as any, - time: new InBetween( - OneUptimeDate.addRemoveDays( + /* + * Query ClickHouse for recent metrics belonging to this monitor + * with names starting with "custom.monitor." + * monitorId is stored as serviceId in the Metric table. + */ + const listResult: ListResult = + await AnalyticsModelAPI.getList({ + modelType: Metric, + query: { + projectId: ProjectUtil.getCurrentProjectId()!, + serviceId: props.monitorId, + name: new Search("custom.monitor.") as any, + time: new InBetween( + OneUptimeDate.addRemoveDays( + OneUptimeDate.getCurrentDate(), + -30, + ), OneUptimeDate.getCurrentDate(), - -30, - ), - OneUptimeDate.getCurrentDate(), - ) as any, - }, - select: { - name: true, - }, - limit: 1000, - skip: 0, - sort: { - name: SortOrder.Ascending, - }, - }); + ) as any, + }, + select: { + name: true, + }, + limit: 1000, + skip: 0, + sort: { + name: SortOrder.Ascending, + }, + }); // Extract distinct metric names const nameSet: Set = new Set();