diff --git a/cmd/tools/grafana/dashboard_test.go b/cmd/tools/grafana/dashboard_test.go index 62d3694f4..46c3844b1 100644 --- a/cmd/tools/grafana/dashboard_test.go +++ b/cmd/tools/grafana/dashboard_test.go @@ -3,6 +3,7 @@ package grafana import ( "fmt" "github.com/tidwall/gjson" + "maps" "net/url" "os" "path/filepath" @@ -1779,3 +1780,34 @@ func checkPanelLinks(t *testing.T, value gjson.Result, path string, hasLinks map }) } } + +func TestTags(t *testing.T) { + VisitDashboards(dashboards, + func(path string, data []byte) { + checkTags(t, path, data) + }) +} + +func checkTags(t *testing.T, path string, data []byte) { + allowedTagsMap := map[string]bool{ + "cdot": true, + "fsx": true, + "harvest": true, + "ontap": true, + "storagegrid": true, + } + + path = ShortPath(path) + tags := gjson.GetBytes(data, "tags").Array() + if len(tags) == 0 { + t.Errorf(`dashboard=%s got tags are empty, but should have tags`, path) + return + } + + for _, tag := range tags { + if !allowedTagsMap[tag.String()] { + allowedTags := slices.Sorted(maps.Keys(allowedTagsMap)) + t.Errorf(`dashboard=%s got tag=%s, which is not in the allowed set=%v`, path, tag.String(), allowedTags) + } + } +} diff --git a/grafana/dashboards/cmode/metadata.json b/grafana/dashboards/cmode/metadata.json index df472b148..61eb388fe 100644 --- a/grafana/dashboards/cmode/metadata.json +++ b/grafana/dashboards/cmode/metadata.json @@ -3144,7 +3144,9 @@ "refresh": "", "schemaVersion": 30, "style": "dark", - "tags": [], + "tags": [ + "harvest" + ], "templating": { "list": [ { diff --git a/grafana/dashboards/cmode/vscan.json b/grafana/dashboards/cmode/vscan.json index 02a49d1c9..6844c7813 100644 --- a/grafana/dashboards/cmode/vscan.json +++ b/grafana/dashboards/cmode/vscan.json @@ -1093,7 +1093,11 @@ "refresh": "", "schemaVersion": 30, "style": "dark", - "tags": [], + "tags": [ + "cdot", + "harvest", + "ontap" + ], "templating": { "list": [ {