From f8656d269de017efc3cba71e1476ea7fa9570481 Mon Sep 17 00:00:00 2001 From: Andreas Christou Date: Mon, 21 Nov 2022 12:03:16 +0000 Subject: [PATCH] AzureMonitor: Separate subscription health check API version (#58253) Separate subscription health check API version --- pkg/tsdb/azuremonitor/azuremonitor.go | 3 ++- pkg/tsdb/azuremonitor/azuremonitor_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/azuremonitor/azuremonitor.go b/pkg/tsdb/azuremonitor/azuremonitor.go index 826b63e4246..b56256ad808 100644 --- a/pkg/tsdb/azuremonitor/azuremonitor.go +++ b/pkg/tsdb/azuremonitor/azuremonitor.go @@ -216,7 +216,8 @@ func (s *Service) getDSInfo(pluginCtx backend.PluginContext) (types.DatasourceIn } func checkAzureMonitorMetricsHealth(dsInfo types.DatasourceInfo) (*http.Response, error) { - url := fmt.Sprintf("%v/subscriptions?api-version=%v", dsInfo.Routes["Azure Monitor"].URL, metrics.AzureMonitorAPIVersion) + subscriptionsApiVersion := "2020-01-01" + url := fmt.Sprintf("%v/subscriptions?api-version=%v", dsInfo.Routes["Azure Monitor"].URL, subscriptionsApiVersion) request, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { return nil, err diff --git a/pkg/tsdb/azuremonitor/azuremonitor_test.go b/pkg/tsdb/azuremonitor/azuremonitor_test.go index e2d428b9ddd..74a479564af 100644 --- a/pkg/tsdb/azuremonitor/azuremonitor_test.go +++ b/pkg/tsdb/azuremonitor/azuremonitor_test.go @@ -425,7 +425,7 @@ func TestCheckHealth(t *testing.T) { Status: backend.HealthStatusError, Message: "One or more health checks failed. See details below.", JSONDetails: []byte( - `{"verboseMessage": "1. Error connecting to Azure Monitor endpoint: health check failed: Get \"https://management.azure.com/subscriptions?api-version=2021-05-01\": not found\n2. Error connecting to Azure Log Analytics endpoint: health check failed: Get \"https://management.azure.com/subscriptions//providers/Microsoft.OperationalInsights/workspaces?api-version=2017-04-26-preview\": not found\n3. Error connecting to Azure Resource Graph endpoint: health check failed: Post \"https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-06-01-preview\": not found" }`), + `{"verboseMessage": "1. Error connecting to Azure Monitor endpoint: health check failed: Get \"https://management.azure.com/subscriptions?api-version=2020-01-01\": not found\n2. Error connecting to Azure Log Analytics endpoint: health check failed: Get \"https://management.azure.com/subscriptions//providers/Microsoft.OperationalInsights/workspaces?api-version=2017-04-26-preview\": not found\n3. Error connecting to Azure Resource Graph endpoint: health check failed: Post \"https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-06-01-preview\": not found" }`), }, customServices: map[string]types.DatasourceService{ azureMonitor: {