AzureMonitor: Fix logs query multi-resource and timespan values (#67914)

* Update TimeGrain interface methods

- Make them util functions because it's simpler

* Update logs ds to appropiately set resources and timespan

* Set timespan using RCF times

* Update tests
This commit is contained in:
Andreas Christou
2023-05-05 16:47:31 +01:00
committed by GitHub
parent 765ae6cd90
commit 9d16718acc
5 changed files with 35 additions and 17 deletions
@@ -393,11 +393,15 @@ func appendErrorNotice(frame *data.Frame, err *AzureLogAnalyticsAPIError) *data.
}
func (e *AzureLogAnalyticsDatasource) createRequest(ctx context.Context, logger log.Logger, queryURL string, query *AzureLogAnalyticsQuery) (*http.Request, error) {
from := query.TimeRange.From.Format(time.RFC3339)
to := query.TimeRange.To.Format(time.RFC3339)
timespan := fmt.Sprintf("%s/%s", from, to)
body := map[string]interface{}{
"query": query.Query,
"query": query.Query,
"timespan": timespan,
}
if len(query.Resources) > 1 {
body["resources"] = query.Resources
body["workspaces"] = query.Resources
}
jsonValue, err := json.Marshal(body)
if err != nil {