mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AzureMonitor: Fail rather than warn if Log credentials are set (#36652)
This commit is contained in:
parent
7dbe388d4e
commit
114f6714c4
@ -135,7 +135,13 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, query *A
|
|||||||
return dataResponse
|
return dataResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If azureLogAnalyticsSameAs is defined and set to false, return an error
|
||||||
|
if sameAs, ok := dsInfo.JSONData["azureLogAnalyticsSameAs"]; ok && !sameAs.(bool) {
|
||||||
|
return dataResponseErrorWithExecuted(fmt.Errorf("Log Analytics credentials are no longer supported. Go to the data source configuration to update Azure Monitor credentials")) //nolint:golint,stylecheck
|
||||||
|
}
|
||||||
|
|
||||||
req, err := e.createRequest(ctx, dsInfo)
|
req, err := e.createRequest(ctx, dsInfo)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dataResponse.Error = err
|
dataResponse.Error = err
|
||||||
return dataResponse
|
return dataResponse
|
||||||
@ -163,9 +169,6 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, query *A
|
|||||||
azlog.Debug("AzureLogAnalytics", "Request ApiURL", req.URL.String())
|
azlog.Debug("AzureLogAnalytics", "Request ApiURL", req.URL.String())
|
||||||
res, err := ctxhttp.Do(ctx, dsInfo.Services[azureLogAnalytics].HTTPClient, req)
|
res, err := ctxhttp.Do(ctx, dsInfo.Services[azureLogAnalytics].HTTPClient, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !dsInfo.Settings.AzureLogAnalyticsSameAs {
|
|
||||||
return dataResponseErrorWithExecuted(fmt.Errorf("Log Analytics credentials are no longer supported. Go to the data source configuration to update Azure Monitor credentials")) //nolint:golint,stylecheck
|
|
||||||
}
|
|
||||||
return dataResponseErrorWithExecuted(err)
|
return dataResponseErrorWithExecuted(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,10 +213,6 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, query *A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !dsInfo.Settings.AzureLogAnalyticsSameAs {
|
|
||||||
frame.AppendNotices(data.Notice{Severity: data.NoticeSeverityWarning, Text: "Log Analytics credentials are no longer supported. Go to the data source configuration to update Azure Monitor credentials"})
|
|
||||||
}
|
|
||||||
|
|
||||||
dataResponse.Frames = data.Frames{frame}
|
dataResponse.Frames = data.Frames{frame}
|
||||||
return dataResponse
|
return dataResponse
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,9 @@ func Test_executeQueryErrorWithDifferentLogAnalyticsCreds(t *testing.T) {
|
|||||||
Services: map[string]datasourceService{
|
Services: map[string]datasourceService{
|
||||||
azureLogAnalytics: {URL: "http://ds"},
|
azureLogAnalytics: {URL: "http://ds"},
|
||||||
},
|
},
|
||||||
Settings: azureMonitorSettings{AzureLogAnalyticsSameAs: false},
|
JSONData: map[string]interface{}{
|
||||||
|
"azureLogAnalyticsSameAs": false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
query := &AzureLogAnalyticsQuery{
|
query := &AzureLogAnalyticsQuery{
|
||||||
|
@ -49,7 +49,6 @@ type azureMonitorSettings struct {
|
|||||||
SubscriptionId string `json:"subscriptionId"`
|
SubscriptionId string `json:"subscriptionId"`
|
||||||
LogAnalyticsDefaultWorkspace string `json:"logAnalyticsDefaultWorkspace"`
|
LogAnalyticsDefaultWorkspace string `json:"logAnalyticsDefaultWorkspace"`
|
||||||
AppInsightsAppId string `json:"appInsightsAppId"`
|
AppInsightsAppId string `json:"appInsightsAppId"`
|
||||||
AzureLogAnalyticsSameAs bool `json:"azureLogAnalyticsSameAs"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type datasourceInfo struct {
|
type datasourceInfo struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user