]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: fix handling NaN values in dashboard charts
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>
Mon, 23 Sep 2024 07:01:50 +0000 (12:31 +0530)
Fixes: https://tracker.ceph.com/issues/68162
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts

index 1a241361f7f25fd7f07c8efa60e51e194ddf54f7..317293be07ce0179536ff8c49d6be140483fe5f0 100644 (file)
@@ -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';
                     }
-                  }
+                  });
                 });
               }
             });