]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix handling NaN values in dashboard charts 59962/head
authorAashish Sharma <aasharma@li-e74156cc-2f67-11b2-a85c-e98659a63c5c.ibm.com>
Fri, 20 Sep 2024 05:36:21 +0000 (11:06 +0530)
committerAashish Sharma <aasharma@li-e74156cc-2f67-11b2-a85c-e98659a63c5c.ibm.com>
Wed, 25 Sep 2024 05:11:22 +0000 (10:41 +0530)
Fixes: https://tracker.ceph.com/issues/68162
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
(cherry picked from commit 49ee68245b78779ffd6766f143315b5bf526afda)

src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts

index e1aa7a07cafc223150ac7951c5ead88e76f6b335..644012cda3bf475425ba109d2549bc8dc8b3bd10 100644 (file)
@@ -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';
                     }
-                  }
+                  });
                 });
               }
             });