From 49ee68245b78779ffd6766f143315b5bf526afda Mon Sep 17 00:00:00 2001 From: Aashish Sharma Date: Fri, 20 Sep 2024 11:06:21 +0530 Subject: [PATCH] mgr/dashboard: fix handling NaN values in dashboard charts Fixes: https://tracker.ceph.com/issues/68162 Signed-off-by: Aashish Sharma --- .../src/app/shared/api/prometheus.service.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts index 1a241361f7f..317293be07c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts @@ -143,7 +143,6 @@ export class PrometheusService { } this.timerGetPrometheusDataSub = timer(0, this.timerTime).subscribe(() => { selectedTime = this.updateTimeStamp(selectedTime); - for (const queryName in queries) { if (queries.hasOwnProperty(queryName)) { const query = queries[queryName]; @@ -163,13 +162,12 @@ export class PrometheusService { queriesResults[queryName] !== '' && checkNan ) { - queriesResults[queryName].forEach((valueArray: string[]) => { - if (valueArray.includes('NaN')) { - const index = valueArray.indexOf('NaN'); - if (index !== -1) { - valueArray[index] = '0'; + queriesResults[queryName].forEach((valueArray: any[]) => { + valueArray.forEach((val, index) => { + if (isNaN(parseFloat(val[1]))) { + valueArray[index][1] = '0'; } - } + }); }); } }); -- 2.39.5