Skip to content

Commit

Permalink
feat: handling few exceptions in linking
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Jun 10, 2024
1 parent 87c2e62 commit 4183615
Show file tree
Hide file tree
Showing 11 changed files with 1,128 additions and 187 deletions.
17 changes: 14 additions & 3 deletions cmd/tools/grafana/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,17 @@ func checkVariablesAreFSxFriendly(t *testing.T, path string, data []byte) {
}

var linkPath = regexp.MustCompile(`/d/(.*?)/`)
var supportedLinkedObjects = []string{"cluster", "datacenter", "aggr", "svm", "volume", "node", "qtree", "home_node"}
var supportedLinkedObjects = []string{"cluster", "datacenter", "aggr", "svm", "volume", "node", "qtree", "home_node", "tenant"}
var exceptionPathPanelObject = []string{
"cmode/s3ObjectStorage.json-Bucket Overview-volume", // bucket volumes starts with fg_oss_xx and volume dashboard don't support them
"storagegrid/fabricpool.json-Aggregates-cluster", // There is no datacenter var to be passed for linking to cluster dashboard
"storagegrid/fabricpool.json-Aggregates-aggr", // There is no datacenter var to be passed for linking to aggregate dashboard
"storagegrid/fabricpool.json-Buckets-cluster", // There is no storagegrid cluster dashboard available
"storagegrid/overview.json-Data space usage breakdown-cluster", // There is no storagegrid cluster dashboard available
"storagegrid/overview.json-Metadata allowed space usage breakdown-cluster", // There is no storagegrid cluster dashboard available
"storagegrid/tenant.json-Tenant Quota-cluster", // There is no storagegrid cluster dashboard available
"storagegrid/tenant.json-Buckets-cluster", // There is no storagegrid cluster dashboard available
}

func TestLinks(t *testing.T) {
hasLinks := map[string][]string{}
Expand Down Expand Up @@ -1708,6 +1718,7 @@ func checkPanelLinks(t *testing.T, value gjson.Result, path string, hasLinks map
if value.Get("type").String() == "table" {
value.Get("fieldConfig.overrides").ForEach(func(_, anOverride gjson.Result) bool {
if name := anOverride.Get("matcher.options").String(); slices.Contains(supportedLinkedObjects, name) {
title := value.Get("title").String()
linkFound = false
anOverride.Get("properties").ForEach(func(_, propValue gjson.Result) bool {
propValue.Get("value").ForEach(func(_, value gjson.Result) bool {
Expand All @@ -1720,8 +1731,8 @@ func checkPanelLinks(t *testing.T, value gjson.Result, path string, hasLinks map
})
return true
})
if !linkFound {
t.Errorf(`dashboard=%s panel="%s" column=%s is missing the links`, path, value.Get("title").String(), name)
if !linkFound && !slices.Contains(exceptionPathPanelObject, path+"-"+title+"-"+name) {
t.Errorf(`dashboard=%s panel="%s" column=%s is missing the links`, path, title, name)
}
}
return true
Expand Down
278 changes: 265 additions & 13 deletions grafana/dashboards/cmode/changelogMonitor.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,72 @@
"value": "left"
}
]
},
{
"matcher": {
"id": "byName",
"options": "cluster"
},
"properties": [
{
"id": "displayName",
"value": "Cluster"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-cluster/ontap-cluster?orgId=1&${Datacenter:queryparam}&${__url_time_range}&var-Cluster=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "datacenter"
},
"properties": [
{
"id": "displayName",
"value": "Datacenter"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-datacenter/ontap-datacenter?orgId=1&${__url_time_range}&var-Datacenter=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "node"
},
"properties": [
{
"id": "displayName",
"value": "Node"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-node/ontap-node?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-Node=${__value.raw}"
}
]
}
]
}
]
},
Expand Down Expand Up @@ -434,10 +500,7 @@
"renameByName": {
"Time": "Poller Time",
"Value": "",
"cluster": "Cluster",
"datacenter": "Datacenter",
"new_value": "New Value",
"node": "Node",
"object": "Object",
"old_value": "Old Value",
"op": "OP",
Expand Down Expand Up @@ -702,6 +765,94 @@
"value": "left"
}
]
},
{
"matcher": {
"id": "byName",
"options": "cluster"
},
"properties": [
{
"id": "displayName",
"value": "Cluster"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-cluster/ontap-cluster?orgId=1&${Datacenter:queryparam}&${__url_time_range}&var-Cluster=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "datacenter"
},
"properties": [
{
"id": "displayName",
"value": "Datacenter"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-datacenter/ontap-datacenter?orgId=1&${__url_time_range}&var-Datacenter=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "node"
},
"properties": [
{
"id": "displayName",
"value": "Node"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-node/ontap-node?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-Node=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "svm"
},
"properties": [
{
"id": "displayName",
"value": "SVM"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-svm/ontap-svm?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-SVM=${__value.raw}"
}
]
}
]
}
]
},
Expand Down Expand Up @@ -789,14 +940,10 @@
"renameByName": {
"Time": "Poller Time",
"Value": "",
"cluster": "Cluster",
"datacenter": "Datacenter",
"new_value": "New Value",
"node": "Node",
"object": "Object",
"old_value": "Old Value",
"op": "OP",
"svm": "SVM",
"track": "Track"
}
}
Expand Down Expand Up @@ -1058,6 +1205,116 @@
"value": "left"
}
]
},
{
"matcher": {
"id": "byName",
"options": "cluster"
},
"properties": [
{
"id": "displayName",
"value": "Cluster"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-cluster/ontap-cluster?orgId=1&${Datacenter:queryparam}&${__url_time_range}&var-Cluster=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "datacenter"
},
"properties": [
{
"id": "displayName",
"value": "Datacenter"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-datacenter/ontap-datacenter?orgId=1&${__url_time_range}&var-Datacenter=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "node"
},
"properties": [
{
"id": "displayName",
"value": "Node"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-node/ontap-node?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-Node=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "svm"
},
"properties": [
{
"id": "displayName",
"value": "SVM"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-svm/ontap-svm?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${__url_time_range}&var-SVM=${__value.raw}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "volume"
},
"properties": [
{
"id": "displayName",
"value": "Volume"
},
{
"id": "links",
"value": [
{
"targetBlank": true,
"title": "",
"url": "/d/cdot-volume/ontap-volume?orgId=1&${Datacenter:queryparam}&${Cluster:queryparam}&${SVM:queryparam}&${__url_time_range}&var-Volume=${__value.raw}"
}
]
}
]
}
]
},
Expand Down Expand Up @@ -1148,17 +1405,12 @@
"renameByName": {
"Time": "Poller Time",
"Value": "",
"cluster": "Cluster",
"datacenter": "Datacenter",
"new_value": "New Value",
"node": "Node",
"object": "Object",
"old_value": "Old Value",
"op": "OP",
"style": "Style",
"svm": "SVM",
"track": "Track",
"volume": "Volume"
"track": "Track"
}
}
},
Expand Down
Loading

0 comments on commit 4183615

Please sign in to comment.