Repository: NetApp/harvest
Pull request #1722 (2023-02-13 13:35:00)

fix: topk in table and info expanded as default in fsa dashboard
<img width="1750" alt="image" src="https://user-images.githubusercontent.com/83282894/218471852-953769cd-7ff1-4297-a8eb-110068eac83e.png">



Patch:
diff --git a/grafana/dashboards/cmode/cluster.json b/grafana/dashboards/cmode/cluster.json
index 8dbe3e6b..e0ac10a1 100644
--- a/grafana/dashboards/cmode/cluster.json
+++ b/grafana/dashboards/cmode/cluster.json
@@ -71,7 +71,7 @@
   "gnetId": null,
   "graphTooltip": 1,
   "id": null,
-  "iteration": 1671103687756,
+  "iteration": 1676294378696,
   "links": [
     {
       "asDropdown": true,
@@ -129,18 +129,6 @@
           "unit": "ms"
         },
         "overrides": [
-          {
-            "matcher": {
-              "id": "byName",
-              "options": "Node"
-            },
-            "properties": [
-              {
-                "id": "custom.width",
-                "value": 137
-              }
-            ]
-          },
           {
             "matcher": {
               "id": "byName",
@@ -149,7 +137,7 @@
             "properties": [
               {
                 "id": "custom.width",
-                "value": 159
+                "value": null
               }
             ]
           }
@@ -157,11 +145,11 @@
       },
       "gridPos": {
         "h": 6,
-        "w": 4,
+        "w": 8,
         "x": 0,
         "y": 1
       },
-      "id": 228,
+      "id": 238,
       "options": {
         "footer": {
           "fields": "",
@@ -247,7 +235,7 @@
             "properties": [
               {
                 "id": "custom.width",
-                "value": 145
+                "value": null
               }
             ]
           }
@@ -255,8 +243,8 @@
       },
       "gridPos": {
         "h": 6,
-        "w": 4,
-        "x": 4,
+        "w": 8,
+        "x": 8,
         "y": 1
       },
       "id": 233,
@@ -345,7 +333,7 @@
             "properties": [
               {
                 "id": "custom.width",
-                "value": 149
+                "value": null
               }
             ]
           }
@@ -353,8 +341,8 @@
       },
       "gridPos": {
         "h": 6,
-        "w": 4,
-        "x": 8,
+        "w": 8,
+        "x": 16,
         "y": 1
       },
       "id": 232,
@@ -443,7 +431,7 @@
             "properties": [
               {
                 "id": "custom.width",
-                "value": 141
+                "value": null
               }
             ]
           }
@@ -451,9 +439,9 @@
       },
       "gridPos": {
         "h": 6,
-        "w": 4,
-        "x": 12,
-        "y": 1
+        "w": 8,
+        "x": 0,
+        "y": 7
       },
       "id": 230,
       "options": {
@@ -541,7 +529,7 @@
             "properties": [
               {
                 "id": "custom.width",
-                "value": 141
+                "value": null
               }
             ]
           }
@@ -549,9 +537,9 @@
       },
       "gridPos": {
         "h": 6,
-        "w": 4,
-        "x": 16,
-        "y": 1
+        "w": 8,
+        "x": 8,
+        "y": 7
       },
       "id": 236,
       "options": {
@@ -639,7 +627,7 @@
             "properties": [
               {
                 "id": "custom.width",
-                "value": 141
+                "value": null
               }
             ]
           }
@@ -647,9 +635,9 @@
       },
       "gridPos": {
         "h": 6,
-        "w": 4,
-        "x": 20,
-        "y": 1
+        "w": 8,
+        "x": 16,
+        "y": 7
       },
       "id": 237,
       "options": {
@@ -762,7 +750,7 @@
         "h": 8,
         "w": 8,
         "x": 0,
-        "y": 7
+        "y": 13
       },
       "id": 234,
       "options": {
@@ -853,7 +841,7 @@
         "h": 8,
         "w": 8,
         "x": 8,
-        "y": 7
+        "y": 13
       },
       "id": 231,
       "options": {
@@ -944,7 +932,7 @@
         "h": 8,
         "w": 8,
         "x": 16,
-        "y": 7
+        "y": 13
       },
       "id": 235,
       "options": {
@@ -983,7 +971,7 @@
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 15
+        "y": 21
       },
       "id": 79,
       "panels": [
@@ -1055,7 +1043,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 292
+                    "value": null
                   }
                 ]
               },
@@ -1067,7 +1055,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 240
+                    "value": null
                   }
                 ]
               },
@@ -1079,7 +1067,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 224
+                    "value": null
                   }
                 ]
               },
@@ -1091,7 +1079,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 384
+                    "value": null
                   }
                 ]
               },
@@ -1103,7 +1091,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 205
+                    "value": null
                   }
                 ]
               }
@@ -1551,7 +1539,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 384
+                    "value": null
                   }
                 ]
               },
@@ -1595,7 +1583,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 187
+                    "value": null
                   }
                 ]
               },
@@ -1607,7 +1595,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 301
+                    "value": null
                   }
                 ]
               },
@@ -1619,7 +1607,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 321
+                    "value": null
                   }
                 ]
               },
@@ -1631,7 +1619,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 254
+                    "value": null
                   }
                 ]
               },
@@ -1643,7 +1631,7 @@
                 "properties": [
                   {
                     "id": "custom.width",
-                    "value": 225
+                    "value": null
                   }
                 ]
               }
@@ -1981,7 +1969,7 @@
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 39
+        "y": 22
       },
       "id": 198,
       "panels": [
@@ -2907,7 +2895,7 @@
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 40
+        "y": 23
       },
       "id": 97,
       "panels": [
@@ -3467,7 +3455,7 @@
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 41
+        "y": 24
       },
       "id": 184,
       "panels": [
@@ -4141,7 +4129,7 @@
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 42
+        "y": 25
       },
       "id": 214,
       "panels": [
@@ -4497,8 +4485,8 @@
         "allValue": null,
         "current": {
           "selected": true,
-          "text": "2",
-          "value": "2"
+          "text": "5",
+          "value": "5"
         },
         "description": null,
         "error": null,
@@ -4514,7 +4502,7 @@
             "value": "1"
           },
           {
-            "selected": true,
+            "selected": false,
             "text": "2",
             "value": "2"
           },
@@ -4529,7 +4517,7 @@
             "value": "4"
           },
           {
-            "selected": false,
+            "selected": true,
             "text": "5",
             "value": "5"
           },
@@ -4790,5 +4778,5 @@
   "timezone": "",
   "title": "ONTAP: Cluster",
   "uid": "",
-  "version": 14
+  "version": 15
 }
\ No newline at end of file
diff --git a/grafana/dashboards/cmode/fsa.json b/grafana/dashboards/cmode/fsa.json
index c95718c4..cc3b0ebc 100644
--- a/grafana/dashboards/cmode/fsa.json
+++ b/grafana/dashboards/cmode/fsa.json
@@ -102,8 +102,7 @@
   ],
   "panels": [
     {
-      "collapsed": true,
-      "datasource": null,
+      "collapsed": false,
       "gridPos": {
         "h": 1,
         "w": 24,
@@ -111,27 +110,26 @@
         "y": 0
       },
       "id": 101,
-      "panels": [
-        {
-          "datasource": "${DS_PROMETHEUS}",
-          "gridPos": {
-            "h": 2,
-            "w": 24,
-            "x": 0,
-            "y": 1
-          },
-          "id": 99,
-          "options": {
-            "content": "This dashboard requires ONTAP 9.8+ and the APIs are only available via REST. Please enable the REST collector in your harvest config.",
-            "mode": "markdown"
-          },
-          "pluginVersion": "8.1.8",
-          "type": "text"
-        }
-      ],
+      "panels": [],
       "title": "Important Information about FSA dashboard",
       "type": "row"
     },
+    {
+      "datasource": "${DS_PROMETHEUS}",
+      "gridPos": {
+        "h": 2,
+        "w": 24,
+        "x": 0,
+        "y": 1
+      },
+      "id": 99,
+      "options": {
+        "content": "This dashboard requires ONTAP 9.8+ and the APIs are only available via REST. Please enable the REST collector in your harvest config.",
+        "mode": "markdown"
+      },
+      "pluginVersion": "8.4.11",
+      "type": "text"
+    },
     {
       "collapsed": false,
       "datasource": "${DS_PROMETHEUS}",
@@ -524,7 +522,7 @@
       "targets": [
         {
           "exemplar": true,
-          "expr": "topk($TopResources,volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",svm=~\"$SVM\",volume=~\"$TopVolumeDirUsed\",dir_name!=\".\"})",
+          "expr": "topk($TopResources,volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",svm=~\"$SVM\",volume=~\"$Volume\",dir_name=~\"$TopDirUsed\"})",
           "interval": "",
           "legendFormat": "{{svm}}-{{volume}}-{{dir_name}}",
           "refId": "A"
@@ -668,7 +666,7 @@
       "targets": [
         {
           "exemplar": true,
-          "expr": "volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",volume=~\"$Volume\",dir_name!=\".\"}",
+          "expr": "topk($TopResources,volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",volume=~\"$Volume\",dir_name=~\"$TopDirUsed\"})",
           "format": "table",
           "instant": true,
           "interval": "",
@@ -677,7 +675,7 @@
         },
         {
           "exemplar": true,
-          "expr": "volume_analytics_dir_file_count{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",volume=~\"$Volume\",dir_name!=\".\"}",
+          "expr": "topk($TopResources,volume_analytics_dir_file_count{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",volume=~\"$Volume\",dir_name=~\"$TopDirUsed\"})",
           "format": "table",
           "hide": false,
           "instant": true,
@@ -687,7 +685,7 @@
         },
         {
           "exemplar": true,
-          "expr": "volume_analytics_dir_subdir_count{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",volume=~\"$Volume\",dir_name!=\".\"}",
+          "expr": "topk($TopResources,volume_analytics_dir_subdir_count{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",volume=~\"$Volume\",dir_name=~\"$TopDirUsed\"})",
           "format": "table",
           "hide": false,
           "instant": true,
@@ -1643,21 +1641,18 @@
         "allValue": null,
         "current": {},
         "datasource": "${DS_PROMETHEUS}",
-        "definition": "query_result(topk($TopResources, avg_over_time(volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",svm=~\"$SVM\",volume=~\"$Volume\"}[${__range}])))",
-        "description": null,
-        "error": null,
+        "definition": "query_result(topk($TopResources, avg_over_time(volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",svm=~\"$SVM\",volume=~\"$Volume\",dir_name!=\".\",}[${__range}])))",
         "hide": 2,
-        "includeAll": false,
-        "label": null,
+        "includeAll": true,
         "multi": false,
-        "name": "TopVolumeDirUsed",
+        "name": "TopDirUsed",
         "options": [],
         "query": {
-          "query": "query_result(topk($TopResources, avg_over_time(volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",svm=~\"$SVM\",volume=~\"$Volume\"}[${__range}])))",
+          "query": "query_result(topk($TopResources, avg_over_time(volume_analytics_dir_bytes_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",svm=~\"$SVM\",volume=~\"$Volume\",dir_name!=\".\",}[${__range}])))",
           "refId": "StandardVariableQuery"
         },
         "refresh": 1,
-        "regex": ".*volume=\\\"(.*?)\\\".*",
+        "regex": ".*dir_name=\\\"(.*?)\\\".*",
         "skipUrlSync": false,
         "sort": 0,
         "type": "query"


Test patch:
diff --git a/cmd/tools/grafana/dashboard_test.go b/cmd/tools/grafana/dashboard_test.go
index 1e3f41a2..5262d88c 100644
--- a/cmd/tools/grafana/dashboard_test.go
+++ b/cmd/tools/grafana/dashboard_test.go
@@ -543,6 +543,7 @@ func TestOnlyHighlightsExpanded(t *testing.T) {
 	exceptions := map[string]int{
 		"cmode/shelf.json":    2,
 		"cmode/security.json": 3,
+		"cmode/fsa.json":      2,
 	}
 	// count number of expanded sections in dashboard and ensure num expanded = 1
 	visitDashboards(