[v11.3.x] Azure: Fix duplicated traces in multi-resource trace query (#95247)

Azure: Fix duplicated traces in multi-resource trace query (#95156)

Use first resource as base resource for query

(cherry picked from commit 8bb7475e4f)

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
pull/95264/head
grafana-delivery-bot[bot] 8 months ago committed by GitHub
parent f8cb0ccb71
commit c76d97bb13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      pkg/tsdb/azuremonitor/loganalytics/azure-log-analytics-datasource.go
  2. 2
      pkg/tsdb/azuremonitor/loganalytics/azure-log-analytics-datasource_test.go

@ -497,7 +497,7 @@ func (e *AzureLogAnalyticsDatasource) createRequest(ctx context.Context, queryUR
}
if query.AppInsightsQuery {
body["applications"] = query.Resources
body["applications"] = []string{query.Resources[0]}
}
jsonValue, err := json.Marshal(body)

@ -649,7 +649,7 @@ func TestLogAnalyticsCreateRequest(t *testing.T) {
TimeColumn: "timestamp",
})
require.NoError(t, err)
expectedBody := fmt.Sprintf(`{"applications":["/subscriptions/test-sub/resourceGroups/test-rg/providers/Microsoft.Insights/components/r1","/subscriptions/test-sub/resourceGroups/test-rg/providers/Microsoft.Insights/components/r2"],"query":"","query_datetimescope_column":"timestamp","query_datetimescope_from":"%s","query_datetimescope_to":"%s","timespan":"%s/%s"}`, from.Format(time.RFC3339), to.Format(time.RFC3339), from.Format(time.RFC3339), to.Format(time.RFC3339))
expectedBody := fmt.Sprintf(`{"applications":["/subscriptions/test-sub/resourceGroups/test-rg/providers/Microsoft.Insights/components/r1"],"query":"","query_datetimescope_column":"timestamp","query_datetimescope_from":"%s","query_datetimescope_to":"%s","timespan":"%s/%s"}`, from.Format(time.RFC3339), to.Format(time.RFC3339), from.Format(time.RFC3339), to.Format(time.RFC3339))
body, err := io.ReadAll(req.Body)
require.NoError(t, err)
if !cmp.Equal(string(body), expectedBody) {

Loading…
Cancel
Save