From ab3dc51baededf9f989085c16af26e176e84979f Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Fri, 3 Feb 2023 13:36:40 -0500 Subject: [PATCH 1/3] fix: variable DS_PROMETHEUS should exist in dashboard test: add unit test to ensure variable exists --- cmd/tools/grafana/dashboard_test.go | 20 ++++++++++++++++++++ grafana/dashboards/storagegrid/overview.json | 20 ++++++++++++++++++++ grafana/dashboards/storagegrid/tenant.json | 20 ++++++++++++++++++++ harvest.yml | 11 ++++++++++- 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/cmd/tools/grafana/dashboard_test.go b/cmd/tools/grafana/dashboard_test.go index 31427079c..a0d56ecf8 100644 --- a/cmd/tools/grafana/dashboard_test.go +++ b/cmd/tools/grafana/dashboard_test.go @@ -28,6 +28,26 @@ func checkDashboardForDatasource(t *testing.T, path string, data []byte) { } return true }) + + // Check that the variable DS_PROMETHEUS exist + doesDsPromExist := false + gjson.GetBytes(data, "templating.list").ForEach(func(key, value gjson.Result) bool { + if value.Get("name").String() == "DS_PROMETHEUS" { + doesDsPromExist = true + query := value.Get("query").String() + if query != "prometheus" { + t.Errorf("dashboard=%s var=DS_PROMETHEUS query want=prometheus got=%s", path, query) + } + theType := value.Get("type").String() + if theType != "datasource" { + t.Errorf("dashboard=%s var=DS_PROMETHEUS type want=datasource got=%s", path, theType) + } + } + return true + }) + if !doesDsPromExist { + t.Errorf("dashboard=%s should define variable has DS_PROMETHEUS", path) + } } func TestUnitsAndExprMatch(t *testing.T) { diff --git a/grafana/dashboards/storagegrid/overview.json b/grafana/dashboards/storagegrid/overview.json index 4268f7e02..cc0bdb0ea 100644 --- a/grafana/dashboards/storagegrid/overview.json +++ b/grafana/dashboards/storagegrid/overview.json @@ -1600,6 +1600,26 @@ ], "templating": { "list": [ + { + "current": { + "selected": false, + "text": "Prometheus", + "value": "Prometheus" + }, + "description": null, + "error": null, + "hide": 2, + "includeAll": false, + "label": "Data Source", + "multi": false, + "name": "DS_PROMETHEUS", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, { "allValue": null, "current": {}, diff --git a/grafana/dashboards/storagegrid/tenant.json b/grafana/dashboards/storagegrid/tenant.json index 5b2ee2613..f48b48cc1 100644 --- a/grafana/dashboards/storagegrid/tenant.json +++ b/grafana/dashboards/storagegrid/tenant.json @@ -454,6 +454,26 @@ ], "templating": { "list": [ + { + "current": { + "selected": false, + "text": "Prometheus", + "value": "Prometheus" + }, + "description": null, + "error": null, + "hide": 2, + "includeAll": false, + "label": "Data Source", + "multi": false, + "name": "DS_PROMETHEUS", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, { "allValue": null, "current": {}, diff --git a/harvest.yml b/harvest.yml index 0c451bc17..fe069ea02 100644 --- a/harvest.yml +++ b/harvest.yml @@ -70,4 +70,13 @@ Pollers: # ssl_key: /path/to/key.key # ca_cert: /path/to/server.crt # exporters: - # - prometheus1 \ No newline at end of file + # - prometheus1 + + # StorageGRID example + # grid-01: + # datacenter: DC-01 + # addr: 10.0.0.3 + # username: myuser + # password: mypass + # collectors: + # - StorageGrid From 0ce64a1e3dff68cbf1c3b05225daacbfbdd66c98 Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Mon, 6 Feb 2023 07:56:21 -0500 Subject: [PATCH 2/3] fix: variable DS_PROMETHEUS should exist in dashboard test: add unit test to ensure variable exists --- harvest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/harvest.yml b/harvest.yml index fe069ea02..15763c395 100644 --- a/harvest.yml +++ b/harvest.yml @@ -78,5 +78,7 @@ Pollers: # addr: 10.0.0.3 # username: myuser # password: mypass + # exporters: + # - prometheus1 # collectors: # - StorageGrid From a4c6f131c69008a45de3b804ae7a7266e0ca9754 Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Mon, 6 Feb 2023 10:47:14 -0500 Subject: [PATCH 3/3] fix: variable DS_PROMETHEUS should exist in dashboard test: add unit test to ensure variable exists --- harvest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harvest.yml b/harvest.yml index 15763c395..bfc22e06f 100644 --- a/harvest.yml +++ b/harvest.yml @@ -61,7 +61,7 @@ Pollers: # no need to add collectors, since they're already defined in Defaults # example with certificate authentication - # See https://github.com/NetApp/harvest/blob/main/docs/AuthAndPermissions.md#using-certificate-authentication + # See https://netapp.github.io/harvest/latest/prepare-cdot-clusters/#using-certificate-authentication # cluster-01: # datacenter: DC-01 # addr: 10.0.0.2