From: Aashish Sharma Date: Fri, 20 Sep 2024 05:36:21 +0000 (+0530) Subject: mgr/dashboard: fix handling NaN values in dashboard charts X-Git-Tag: testing/wip-vshankar-testing-20241106.074359-squid-debug~114^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3d0667a3c315e7523c2d1f862574a898bc6c068b;p=ceph-ci.git 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) --- 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 e1aa7a07caf..644012cda3b 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'; } - } + }); }); } });