From ed1aa0f4abf30b53eac2ecfdc0a3d29512799988 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 (cherry picked from commit 49ee68245b78779ffd6766f143315b5bf526afda) --- .../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 e1aa7a07cafc2..644012cda3bf4 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 @@ -142,7 +142,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]; @@ -162,13 +161,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