diff --git a/Common/Server/Utils/Monitor/MonitorResource.ts b/Common/Server/Utils/Monitor/MonitorResource.ts index 54b47d2004..41c480e50f 100644 --- a/Common/Server/Utils/Monitor/MonitorResource.ts +++ b/Common/Server/Utils/Monitor/MonitorResource.ts @@ -603,7 +603,7 @@ export default class MonitorResourceUtil { monitorMetric.name = MonitorMetricType.IsOnline; monitorMetric.description = CheckOn.IsOnline + " status for monitor"; monitorMetric.value = isOnline ? 1 : 0; - monitorMetric.unit = CheckOn.IsOnline; + monitorMetric.unit = ""; monitorMetric.attributes = { monitorId: data.monitorId.toString(), projectId: data.projectId.toString(), @@ -632,7 +632,7 @@ export default class MonitorResourceUtil { monitorMetric.name = MonitorMetricType.CPUUsagePercent; monitorMetric.description = CheckOn.CPUUsagePercent + " of Server/VM"; monitorMetric.value = basicMetrics.cpuMetrics.percentUsed; - monitorMetric.unit = "Percent"; + monitorMetric.unit = "%"; monitorMetric.attributes = { monitorId: data.monitorId.toString(), projectId: data.projectId.toString(), @@ -654,7 +654,7 @@ export default class MonitorResourceUtil { monitorMetric.description = CheckOn.MemoryUsagePercent + " of Server/VM"; monitorMetric.value = basicMetrics.memoryMetrics.percentUsed; - monitorMetric.unit = "Percent"; + monitorMetric.unit = "%"; monitorMetric.attributes = { monitorId: data.monitorId.toString(), projectId: data.projectId.toString(), @@ -677,7 +677,7 @@ export default class MonitorResourceUtil { monitorMetric.description = CheckOn.DiskUsagePercent + " of Server/VM"; monitorMetric.value = diskMetric.percentUsed; - monitorMetric.unit = "Percent"; + monitorMetric.unit = "%"; monitorMetric.attributes = { monitorId: data.monitorId.toString(), projectId: data.projectId.toString(), @@ -796,7 +796,7 @@ export default class MonitorResourceUtil { .isOnline ? 1 : 0; - monitorMetric.unit = CheckOn.IsOnline; + monitorMetric.unit = ""; monitorMetric.attributes = { monitorId: data.monitorId.toString(), projectId: data.projectId.toString(), @@ -823,7 +823,7 @@ export default class MonitorResourceUtil { monitorMetric.value = ( data.dataToProcess as ProbeMonitorResponse ).responseCode; - monitorMetric.unit = CheckOn.ResponseStatusCode; + monitorMetric.unit = "Status Code"; monitorMetric.attributes = { monitorId: data.monitorId.toString(), projectId: data.projectId.toString(), diff --git a/Common/Utils/Monitor/MonitorMetricType.ts b/Common/Utils/Monitor/MonitorMetricType.ts index 33914fbbd0..dc40eb0d7a 100644 --- a/Common/Utils/Monitor/MonitorMetricType.ts +++ b/Common/Utils/Monitor/MonitorMetricType.ts @@ -4,11 +4,9 @@ import MonitorMetricType from "../../Types/Monitor/MonitorMetricType"; import MonitorType from "../../Types/Monitor/MonitorType"; class MonitorMetricTypeUtil { - - public static getAggregationTypeByMonitorMetricType( monitorMetricType: MonitorMetricType, - ): AggregationType { + ): AggregationType { switch (monitorMetricType) { case MonitorMetricType.ResponseTime: return AggregationType.Avg; @@ -60,18 +58,19 @@ class MonitorMetricTypeUtil { monitorType === MonitorType.Website ) { return [ + MonitorMetricType.IsOnline, MonitorMetricType.ResponseTime, MonitorMetricType.ResponseStatusCode, - MonitorMetricType.IsOnline, ]; } if (monitorType === MonitorType.Server) { return [ + MonitorMetricType.IsOnline, MonitorMetricType.DiskUsagePercent, MonitorMetricType.CPUUsagePercent, MonitorMetricType.MemoryUsagePercent, - MonitorMetricType.IsOnline, + ]; } @@ -88,7 +87,7 @@ class MonitorMetricTypeUtil { monitorType === MonitorType.IP || monitorType === MonitorType.Port ) { - return [MonitorMetricType.ResponseTime, MonitorMetricType.IsOnline]; + return [MonitorMetricType.IsOnline, MonitorMetricType.ResponseTime ]; } return []; diff --git a/Dashboard/src/Components/Metrics/MetricView.tsx b/Dashboard/src/Components/Metrics/MetricView.tsx index 3decf3318f..4aa4bd2aa1 100644 --- a/Dashboard/src/Components/Metrics/MetricView.tsx +++ b/Dashboard/src/Components/Metrics/MetricView.tsx @@ -234,17 +234,20 @@ const MetricView: FunctionComponent = ( }, yAxis: { // legend is the unit of the metric - legend: - metricNamesAndUnits.find((m: MetricNameAndUnit) => { - return ( - m.metricName === - queryConfig.metricQueryData.filterData.metricName - ); - })?.unit || "", + legend: "", + options: { type: YAxisType.Number, formatter: (value: number) => { - return `${value}`; + const metricNameAndUnit: MetricNameAndUnit | undefined = + metricNamesAndUnits.find((m: MetricNameAndUnit) => { + return ( + m.metricName === + queryConfig.metricQueryData.filterData.metricName + ); + }); + + return `${value} ${metricNameAndUnit?.unit || ""}`; }, precision: YAxisPrecision.NoDecimals, max: "auto", @@ -291,6 +294,7 @@ const MetricView: FunctionComponent = ( }, groupBy: { name: true, + unit: true, }, }); @@ -444,7 +448,12 @@ const MetricView: FunctionComponent = ( }); // if hideQueryElements is true then we should fetch the results immediately because apply button is hidden - if (props.hideQueryElements) { + if ( + props.hideQueryElements && + startAndEndDate && + startAndEndDate.startValue && + startAndEndDate.endValue + ) { fetchAggregatedResults().catch((err: Error) => { setMetricResultsError( API.getFriendlyErrorMessage(err as Error), diff --git a/Dashboard/src/Components/Monitor/MonitorMetrics.tsx b/Dashboard/src/Components/Monitor/MonitorMetrics.tsx index bd667fed77..c20c36e003 100644 --- a/Dashboard/src/Components/Monitor/MonitorMetrics.tsx +++ b/Dashboard/src/Components/Monitor/MonitorMetrics.tsx @@ -11,7 +11,6 @@ import InBetween from "Common/Types/BaseDatabase/InBetween"; import MetricView from "../Metrics/MetricView"; import { MetricQueryConfigData } from "../Metrics/MetricQueryConfig"; import DashboardNavigation from "../../Utils/Navigation"; -import AggregationType from "Common/Types/BaseDatabase/AggregationType"; import MonitorMetricType from "Common/Types/Monitor/MonitorMetricType"; import MonitorType from "Common/Types/Monitor/MonitorType"; import API from "Common/UI/Utils/API/API"; @@ -110,9 +109,10 @@ const MonitorMetricsElement: FunctionComponent = ( monitorId: props.monitorId.toString(), projectId: DashboardNavigation.getProjectId()?.toString() || "", }, - aggegationType: MonitorMetricTypeUtil.getAggregationTypeByMonitorMetricType( - monitorMetricType, - ), + aggegationType: + MonitorMetricTypeUtil.getAggregationTypeByMonitorMetricType( + monitorMetricType, + ), }, }, });