From 6f5c2ad8ca3a05b17482d56603f6c002bb951438 Mon Sep 17 00:00:00 2001 From: Hardikl <83282894+Hardikl@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:35:01 +0530 Subject: [PATCH] fix: changed var label to ne null from empty (#3385) --- cmd/tools/grafana/dashboard_test.go | 18 ++++++++++++++++++ grafana/dashboards/cmode/cdot.json | 10 +++++----- grafana/dashboards/cmode/changelogMonitor.json | 4 ++-- grafana/dashboards/cmode/cluster.json | 6 +++--- grafana/dashboards/cmode/datacenter.json | 4 ++-- grafana/dashboards/cmode/health.json | 4 ++-- grafana/dashboards/cmode/mcc_cluster.json | 2 +- grafana/dashboards/cmode/metadata.json | 2 +- grafana/dashboards/cmode/network.json | 10 +++++----- 9 files changed, 39 insertions(+), 21 deletions(-) diff --git a/cmd/tools/grafana/dashboard_test.go b/cmd/tools/grafana/dashboard_test.go index b3eea70e0..d89f9831b 100644 --- a/cmd/tools/grafana/dashboard_test.go +++ b/cmd/tools/grafana/dashboard_test.go @@ -1713,6 +1713,24 @@ func checkVariablesAreFSxFriendly(t *testing.T, path string, data []byte) { }) } +func TestLabelsNullVariables(t *testing.T) { + VisitDashboards(cDotDashboards, + func(path string, data []byte) { + checkVariablesLabelNull(t, path, data) + }) +} + +func checkVariablesLabelNull(t *testing.T, path string, data []byte) { + gjson.GetBytes(data, "templating.list").ForEach(func(key, value gjson.Result) bool { + if value.Get("label").Type != gjson.Null && value.Get("label").ClonedString() == "" { + varName := value.Get("name").ClonedString() + t.Errorf("dashboard=%s path=templating.list[%s]. variable=%s label should not be empty", + ShortPath(path), key.ClonedString(), varName) + } + return true + }) +} + var linkPath = regexp.MustCompile(`/d/(.*?)/`) var supportedLinkedObjects = []string{"cluster", "datacenter", "aggr", "svm", "volume", "node", "qtree", "home_node", "tenant"} var exceptionPathPanelObject = []string{ diff --git a/grafana/dashboards/cmode/cdot.json b/grafana/dashboards/cmode/cdot.json index 2028603bc..be7a9711e 100644 --- a/grafana/dashboards/cmode/cdot.json +++ b/grafana/dashboards/cmode/cdot.json @@ -2054,7 +2054,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": true, "name": "Datacenter", "options": [], @@ -2080,7 +2080,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Cluster", "options": [], @@ -2106,7 +2106,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "SVM", "options": [], @@ -2132,7 +2132,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Volume", "options": [], @@ -2251,7 +2251,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": false, "name": "IncludeRoot", "options": [ diff --git a/grafana/dashboards/cmode/changelogMonitor.json b/grafana/dashboards/cmode/changelogMonitor.json index 1057fb049..929540e99 100644 --- a/grafana/dashboards/cmode/changelogMonitor.json +++ b/grafana/dashboards/cmode/changelogMonitor.json @@ -1473,7 +1473,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": true, "name": "Datacenter", "options": [], @@ -1499,7 +1499,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Cluster", "options": [], diff --git a/grafana/dashboards/cmode/cluster.json b/grafana/dashboards/cmode/cluster.json index 6f1ffb3df..7f7d0685b 100644 --- a/grafana/dashboards/cmode/cluster.json +++ b/grafana/dashboards/cmode/cluster.json @@ -5107,7 +5107,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": true, "name": "Datacenter", "options": [], @@ -5131,7 +5131,7 @@ "definition": "label_values(cluster_tags{system_type!=\"7mode\", datacenter=~\"$Datacenter\"},tag)", "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Tag", "options": [], @@ -5157,7 +5157,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Cluster", "options": [], diff --git a/grafana/dashboards/cmode/datacenter.json b/grafana/dashboards/cmode/datacenter.json index 57aca3ccb..2c4d60d57 100644 --- a/grafana/dashboards/cmode/datacenter.json +++ b/grafana/dashboards/cmode/datacenter.json @@ -3954,7 +3954,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": true, "name": "Datacenter", "options": [], @@ -3980,7 +3980,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Cluster", "options": [], diff --git a/grafana/dashboards/cmode/health.json b/grafana/dashboards/cmode/health.json index e4fbb722f..36bcedff2 100644 --- a/grafana/dashboards/cmode/health.json +++ b/grafana/dashboards/cmode/health.json @@ -4436,7 +4436,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": true, "name": "Datacenter", "options": [], @@ -4462,7 +4462,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Cluster", "options": [], diff --git a/grafana/dashboards/cmode/mcc_cluster.json b/grafana/dashboards/cmode/mcc_cluster.json index 35eac2043..9bc844361 100644 --- a/grafana/dashboards/cmode/mcc_cluster.json +++ b/grafana/dashboards/cmode/mcc_cluster.json @@ -4241,7 +4241,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": false, "name": "TopResources", "options": [ diff --git a/grafana/dashboards/cmode/metadata.json b/grafana/dashboards/cmode/metadata.json index 61eb388fe..10740ba0b 100644 --- a/grafana/dashboards/cmode/metadata.json +++ b/grafana/dashboards/cmode/metadata.json @@ -3204,7 +3204,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Hostname", "options": [], diff --git a/grafana/dashboards/cmode/network.json b/grafana/dashboards/cmode/network.json index 3df2b900e..5f2a21858 100644 --- a/grafana/dashboards/cmode/network.json +++ b/grafana/dashboards/cmode/network.json @@ -4924,7 +4924,7 @@ "error": null, "hide": 0, "includeAll": false, - "label": "", + "label": null, "multi": true, "name": "Datacenter", "options": [], @@ -4950,7 +4950,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Cluster", "options": [], @@ -4976,7 +4976,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Node", "options": [], @@ -5002,7 +5002,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "Eth", "options": [], @@ -5028,7 +5028,7 @@ "error": null, "hide": 0, "includeAll": true, - "label": "", + "label": null, "multi": true, "name": "FCP", "options": [],